diff options
author | Kartik Agaram <vc@akkartik.com> | 2018-08-12 22:46:49 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2018-08-12 22:46:49 -0700 |
commit | 9bc51a5249dd2e286eb1e15bb18004f061a8121f (patch) | |
tree | fd66eef5d7f9dccc3ea0008e17890b2ce2721bbf | |
parent | d33fa1c5edd9240b91b83a3eb0807b7751d01a28 (diff) | |
download | mu-9bc51a5249dd2e286eb1e15bb18004f061a8121f.tar.gz |
4514 - prefix jump targets with function name
I'd been planning next to automatically namespace jump targets in different functions. But just a check for duplicate labels should suffice, and managing unique names isn't a huge burden. I'm wary of growing the translator too much. All this will eventually need to be self-hosted in SubX.
-rw-r--r-- | subx/ex7.subx | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/subx/ex7.subx b/subx/ex7.subx index b386df82..86e018c8 100644 --- a/subx/ex7.subx +++ b/subx/ex7.subx @@ -38,7 +38,7 @@ factorial: b8/copy . . . . . . . 1/imm32 # copy 1 to EAX # if (n <= 1) jump exit 81 7/subop/compare 3/mod/direct 2/rm32/EDX . . . . . 1/imm32 # compare EDX with 1 - 7e/jump-if-<= . . . . . . $exit/disp8 # jump if <= to $exit + 7e/jump-if-<= . . . . . . $factorial:exit/disp8 # jump if <= to $factorial:exit # EBX: n-1 89/copy 3/mod/direct 3/rm32/EBX . . . 2/r32/EDX . . # copy EDX to EBX 81 5/subop/subtract 3/mod/direct 3/rm32/EBX . . . . . 1/imm32 # subtract 1 from EBX @@ -58,7 +58,7 @@ factorial: # return n * factorial(n-1) 0f af/multiply 3/mod/direct 2/rm32/EDX . . . 0/r32/EAX . . # multiply EDX (n) into EAX (factorial(n-1)) # TODO: check for overflow -$exit: +$factorial:exit: c3/return # vim:ft=subx:nowrap:so=0 |