diff options
author | Kartik Agaram <vc@akkartik.com> | 2018-09-21 15:28:11 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2018-09-21 15:29:59 -0700 |
commit | 9c50655a26712727d2b9020373967470139b90d7 (patch) | |
tree | f8d2d5291883c013f9edbfe2cc4d7bb94ff07ffd /subx/examples | |
parent | d9818a5333805148586b7ac14c22f5dd413f593e (diff) | |
download | mu-9c50655a26712727d2b9020373967470139b90d7.tar.gz |
4576
Diffstat (limited to 'subx/examples')
-rw-r--r-- | subx/examples/ex3.subx | 4 | ||||
-rw-r--r-- | subx/examples/ex8.subx | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/subx/examples/ex3.subx b/subx/examples/ex3.subx index eb4d6c01..41a8900a 100644 --- a/subx/examples/ex3.subx +++ b/subx/examples/ex3.subx @@ -19,13 +19,13 @@ $loop: # while (counter <= 10) 81 7/subop/compare 3/mod/direct 1/rm32/ECX 0xa/imm32 # compare ECX, 10/imm - 7f/jump-if $exit/disp8 # jump-if-greater $exit + 7f/jump-if-greater $exit/disp8 # result += counter 01/add 3/mod/direct 3/rm32/EBX 1/r32/ECX # add ECX to EBX # ++counter 81 0/subop/add 3/mod/direct 1/rm32/ECX 1/imm32 # add 1 to ECX # loop - eb/jump $loop/disp8 # jump $loop + eb/jump $loop/disp8 $exit: # exit(EBX) diff --git a/subx/examples/ex8.subx b/subx/examples/ex8.subx index 1d9e9341..6ec8d4b0 100644 --- a/subx/examples/ex8.subx +++ b/subx/examples/ex8.subx @@ -27,7 +27,7 @@ # push args 53/push . . . . . . . . # push EBX # call - e8/call . . . . . . ascii_length/disp32 + e8/call ascii_length/disp32 # discard args 5a/pop . . . . . . . . # pop into EDX # clean up after call @@ -49,13 +49,13 @@ $al_loop: 8a/copy 0/mod/* 2/rm32/EDX . . . 1/r32/ECX . . # copy byte at *EDX to lower byte of ECX # if c == '\0' break 81 7/subop/compare 3/mod/direct 1/rm32/ECX . . . . . 0/imm32 # compare ECX with 0 - 74/jump-if-zero . . . . . . . $al_ret/disp8 # jump if equal + 74/jump-if-equal $al_ret/disp8 # ++s 81 0/subop/add 3/mod/direct 2/rm32/EDX . . . . . 1/imm32 # add 1 to EDX # ++result 81 0/subop/add 3/mod/direct 0/rm32/EAX . . . . . 1/imm32 # add 1 to EAX # loop - eb/jump . . . . . . . $al_loop/disp8 # jump $al_loop + eb/jump $al_loop/disp8 $al_ret: # return (result in EAX) c3/return |