From 9d43ebe2aa32be615104a0dc3aec386b2017ccac Mon Sep 17 00:00:00 2001 From: pommicket Date: Wed, 5 Jan 2022 23:44:04 -0500 Subject: number terms! --- 04b/in04b | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to '04b/in04b') diff --git a/04b/in04b b/04b/in04b index 4a1e7e3..badf963 100644 --- a/04b/in04b +++ b/04b/in04b @@ -1,3 +1,6 @@ +:test + return -0x3874f + ; declaration: ; global ; local @@ -10,8 +13,8 @@ ; += ; -= ; (, , ...) -; syscall ... ; return +; string ; byte ; term: ; @@ -22,17 +25,13 @@ ; 0xabc ; lvalue: ; -; * -; [] +; *1 / *2 / *4 / *8 ; rvalue: -; `` ; ; & ; *1 / *2 / *4 / *8 -; [] ; ~ ; (, , ...) -; syscall , , ... ; + ; - ; NOTE: *, /, % are signed (imul and idiv) @@ -51,6 +50,12 @@ global x global y ;123 global z +:syscall +function + ; ... + byte 0x0f + byte 0x05 + :strlen function argument s @@ -72,7 +77,7 @@ function argument c local p p = &c - syscall 1 1 p 1 0 0 0 0 + syscall(1, 1, p, 1) return :puts @@ -80,17 +85,17 @@ function argument s local len len = strlen(s) - syscall 1 1 s len 0 0 0 0 + syscall(1, 1, s, len) return :main function - local hello - hello = `Hello, world! -` - puts(hello) - syscall 0x3c 0 0 0 0 0 0 0 - + puts(str_hello_world) + syscall(0x3c, 0) +:str_hello_world +string Hello, world! +byte 10 +byte 0 :f function @@ -103,6 +108,8 @@ function *4p = v if v == 0 goto something *1p = v + 1 - return *2p + v = *2p + return v :something - return *4p + v = *4p + return v -- cgit v1.2.3