diff options
author | Kartik Agaram <vc@akkartik.com> | 2019-03-27 23:24:46 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2019-03-27 23:24:46 -0700 |
commit | 95d811259c93883fc1963d57f137051e2d3d9679 (patch) | |
tree | 42da05589b86850afc500aab8c28ec91f846b541 /subx/073next-token.subx | |
parent | 63e48e9034f4067437c385c7f64df2ff0508a80b (diff) | |
download | mu-95d811259c93883fc1963d57f137051e2d3d9679.tar.gz |
5027
Testing conversion of multiple lines in a data segment. Bugs fixed: 1. Stack issues in next-token helpers. 2. Needed to teach next-token to avoid newlines. 3. rewind-stream(line) before passing it to convert-code or convert-instruction.
Diffstat (limited to 'subx/073next-token.subx')
-rw-r--r-- | subx/073next-token.subx | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/subx/073next-token.subx b/subx/073next-token.subx index e65d5e60..de9f3928 100644 --- a/subx/073next-token.subx +++ b/subx/073next-token.subx @@ -351,6 +351,7 @@ skip-chars-matching: # in : (address stream), delimiter : byte 50/push-EAX 51/push-ECX 52/push-EDX + 53/push-EBX 56/push-ESI # ESI = in 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 6/r32/ESI 8/disp8 . # copy *(EBP+8) to ESI @@ -378,6 +379,7 @@ $skip-chars-matching:end: 89/copy 1/mod/*+disp8 6/rm32/ESI . . . 1/r32/ECX 4/disp8 . # copy ECX to *(ESI+4) # . restore registers 5e/pop-to-ESI + 5b/pop-to-EBX 5a/pop-to-EDX 59/pop-to-ECX 58/pop-to-EAX @@ -473,6 +475,7 @@ skip-chars-not-matching: # in : (address stream), delimiter : byte 50/push-EAX 51/push-ECX 52/push-EDX + 53/push-EBX 56/push-ESI # ESI = in 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 6/r32/ESI 8/disp8 . # copy *(EBP+8) to ESI @@ -500,6 +503,7 @@ $skip-chars-not-matching:end: 89/copy 1/mod/*+disp8 6/rm32/ESI . . . 1/r32/ECX 4/disp8 . # copy ECX to *(ESI+4) # . restore registers 5e/pop-to-ESI + 5b/pop-to-EBX 5a/pop-to-EDX 59/pop-to-ECX 58/pop-to-EAX @@ -625,6 +629,56 @@ test-skip-chars-not-matching-all: # end c3/return +skip-chars-not-matching-whitespace: # in : (address stream) + # . prolog + 55/push-EBP + 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP + # . save registers + 50/push-EAX + 51/push-ECX + 53/push-EBX + 56/push-ESI + # ESI = in + 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 6/r32/ESI 8/disp8 . # copy *(EBP+8) to ESI + # ECX = in->read + 8b/copy 1/mod/*+disp8 6/rm32/ESI . . . 1/r32/ECX 4/disp8 . # copy *(ESI+4) to ECX + # EBX = in->write + 8b/copy 0/mod/indirect 6/rm32/ESI . . . 3/r32/EBX . . # copy *ESI to EBX +$skip-chars-not-matching-whitespace:loop: + # if (in->read >= in->write) break + 39/compare 3/mod/direct 1/rm32/ECX . . . 3/r32/EBX . . # compare ECX with EBX + 7d/jump-if-greater-or-equal $skip-chars-not-matching-whitespace:end/disp8 + # EAX = in->data[in->read] + 31/xor 3/mod/direct 0/rm32/EAX . . . 0/r32/EAX . . # clear EAX + 8a/copy-byte 1/mod/*+disp8 4/rm32/sib 6/base/ESI 1/index/ECX . 0/r32/AL 0xc/disp8 . # copy byte at *(ESI+ECX+12) to AL + # if (EAX == ' ') break + 3d/compare-with-EAX 0x20/imm32/space + 74/jump-if-equal $skip-chars-not-matching-whitespace:end/disp8 + # if (EAX == '\n') break + 3d/compare-with-EAX 0x0a/imm32/newline + 74/jump-if-equal $skip-chars-not-matching-whitespace:end/disp8 + # if (EAX == '\t') break + 3d/compare-with-EAX 0x09/imm32/tab + 74/jump-if-equal $skip-chars-not-matching-whitespace:end/disp8 + # if (EAX == '\r') break + 3d/compare-with-EAX 0x0d/imm32/cr + 74/jump-if-equal $skip-chars-not-matching-whitespace:end/disp8 + # ++in->read + 41/inc-ECX + eb/jump $skip-chars-not-matching-whitespace:loop/disp8 +$skip-chars-not-matching-whitespace:end: + # persist in->read + 89/copy 1/mod/*+disp8 6/rm32/ESI . . . 1/r32/ECX 4/disp8 . # copy ECX to *(ESI+4) + # . restore registers + 5e/pop-to-ESI + 5b/pop-to-EBX + 59/pop-to-ECX + 58/pop-to-EAX + # . epilog + 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP + 5d/pop-to-EBP + c3/return + skip-chars-matching-in-slice: # curr : (address byte), end : (address byte), delimiter : byte -> curr/EAX # . prolog 55/push-EBP |