interpretated language
Released under GPL v3
$ meson build
$ cd build
$ ninja
$ sudo ninja install
chip32 -f ./examples/hellowrold.asm -o ./examples/helloworld.chip32
chip32 -r -o ./examples/helloworld.chip32
chip32 -r -i ./examples -f helloworld.chip32 -o ./examples/helloworld.chip32
; this is a comment
initialize ram, this command need is first command on your software
initr 4096; this is a first command you need to write, initialize ram with size 4096 or do you want
this is not command but macro that create a variable.
declare <NAME>, <ADDR/?>, (optional<SIZE/?>), (optional<"str"/N,N,N/'c','c','c'>
declare symbol with address ADDR or ? for automatic ADDR, can add an optional SIZE or ? for automatic size calcolated with sucessive argument. Last argument is initialization ov variable, all variable create in this mode reside in ram example:
declare zero, ? ; create variable named zero
declare r0, 0 ; create variable mapped in address 0
declare hi, ?, ?, "Hello" ; create variable initialized with value hello
declare var, $ ; create variable
move $0, 0 ; set 0 memory at 0 address, $ tell compiler to use value/name as address of ram
; on default 0-31 ar unused address of ram, you can use for general register
; addr 32 is PC
; addr 33 is STK
; addr 34 is FRM
move $var, $0 ; set value of $0 to $var
move $1, &var ; set r1 with address of var
move *1, 1 ; set var to 1, because $1 contain address of var
nop ; nothing
move $0, $1 ; r0 = r1
move $0, &r ; r0 = &r
move *0, 123 ; *r0 = 123
inc $r ; ++r
inc *r ; ++(*r)
dec $r ; --r
dec *r ; --(*r)
sum $r0, $r1 ; r0 += r1
dif $r0, $r1 ; r0 -= r1
mul $r0, $r1 ; r0 *= r1
div $0, $1 ; r0 /= r1
mod $0, $1 ; r0 %= r1
or $0, $1 ; r0 |= r1
xor $0, $1 ; r0 ^= r1
and $0, $1 ; r0 &= r1
not $0, $1 ; r0 ~= r1
shl $r0, $r1 ; r0 <<= r1
shr $0, $1 ; r0 >>= r1
* 0x0F rol rdst,rsrc ; r0 = (r0<<r1) | (r0 >> 32-r1)
ror $0, $1 ; r0 = (r0>>r1) | (r0 << 32-r1)
bor $0, $1 ; r0 = r0 || r1
band $0, $1 ; r0 = r0 && r1
bnot $0 ; r0 = !r0
jmp $r ; goto addr
jmpi 12 ; goto currentaddress+12
ift $r radr ; if( r ) ... else goto curaddr+addr
iff $r radr ; if( !r ) ... else goto curaddr+addr
call $r ; r()
ret ; return
push r ; *stack-- =r
pop r ; r = *(--stack)
logi r ; printf("%d", r)
logu r ; printf("%u", r)
logc r ; printf("%c", r)
logs r ; printf("%s", r)
logln ; putchar('\n')
strcpy $0, $1; strcpy(r0, r1)
- 0.0 begin