From d36d51429d604f0ab3b2076c4c05e28ebf9b52c5 Mon Sep 17 00:00:00 2001 From: Melodi <62381002+Melodi17@users.noreply.github.com> Date: Sat, 9 Aug 2025 00:16:57 +1000 Subject: updated block syntax and removed body grammar, fixed issue with if requiring an else branch --- ROMs/.DS_Store | Bin 6148 -> 6148 bytes ROMs/hello_c.asm | 14 +++++++++++--- ROMs/hello_c.c | 4 +++- 3 files changed, 14 insertions(+), 4 deletions(-) (limited to 'ROMs') diff --git a/ROMs/.DS_Store b/ROMs/.DS_Store index 775e323..4906c1a 100644 Binary files a/ROMs/.DS_Store and b/ROMs/.DS_Store differ diff --git a/ROMs/hello_c.asm b/ROMs/hello_c.asm index 6eba849..e06d4e0 100644 --- a/ROMs/hello_c.asm +++ b/ROMs/hello_c.asm @@ -1,9 +1,17 @@ _main: ; comment mov 5, [$51FF] ; int a = 5 - add [$51FF], 5 ; compute addition - mov AX, [$51FF] ; store back into left param - mov [$51FF], V0 ; return value + push [$51FF] ; left operand + mov 5, V1 ; right operand + pop V0 ; get left operand back + cmp V0, V1 ; compute equality check + bz LX ; check if condition + not + jmp _end_1 ; if succeeds, continue, else jump to end + mov 99, V0 ; return value + ret +_end_1: + mov 0, V0 ; return value ret mov 0, V0 ; fallback return 0 ret diff --git a/ROMs/hello_c.c b/ROMs/hello_c.c index d0abdd5..3310b6b 100644 --- a/ROMs/hello_c.c +++ b/ROMs/hello_c.c @@ -2,5 +2,7 @@ int main() { //comment int a = 5; - return a += 5; + if (a == 5) + return 99; + return 0; } \ No newline at end of file -- cgit v1.3.1