diff options
author | Kartik Agaram <vc@akkartik.com> | 2019-08-31 23:56:24 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2019-08-31 23:58:19 -0700 |
commit | 075354cd175fdf0c778fdf09b0d26fae5c8e959a (patch) | |
tree | 0e4b71e8ebc1d9e772a54eb08b828b042921b871 /apps | |
parent | 282681c729857026e3713d45e9027fdfccda0880 (diff) | |
download | mu-075354cd175fdf0c778fdf09b0d26fae5c8e959a.tar.gz |
5601
Diffstat (limited to 'apps')
-rw-r--r-- | apps/sigils.subx | 136 |
1 files changed, 68 insertions, 68 deletions
diff --git a/apps/sigils.subx b/apps/sigils.subx index 53452f1e..94bc643d 100644 --- a/apps/sigils.subx +++ b/apps/sigils.subx @@ -1272,19 +1272,19 @@ test-convert-register-indirect-mode-with-sib-byte-negative-displacement: 5d/pop-to-ebp c3/return -# BEWARE: modifies 'word' -emit-direct-mode: # word : (address slice), out : (address buffered-file) +# BEWARE: modifies 'word-slice' +emit-direct-mode: # word-slice : (address slice), out : (address buffered-file) # . prolog 55/push-ebp 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp # . save registers 50/push-eax - # ++word->start - # . eax = word + # ++word-slice->start + # . eax = word-slice 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 0/r32/eax 8/disp8 . # copy *(ebp+8) to eax # . ++(*eax) ff 0/subop/increment 0/mod/indirect 0/rm32/eax . . . . . . # increment *eax - # word = next-token-from-slice(word->start, word->end, "/") + # word-slice = next-token-from-slice(word-slice->start, word-slice->end, "/") # . . push args 50/push-eax 68/push 0x2f/imm32/slash @@ -1294,7 +1294,7 @@ emit-direct-mode: # word : (address slice), out : (address buffered-file) e8/call next-token-from-slice/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0x10/imm32 # add to esp - # reg-num/eax = get-slice(Registers, word, row-size=8) + # reg-num/eax = get-slice(Registers, word-slice, row-size=8) # . . push args 68/push "Registers"/imm32 68/push 8/imm32/row-size @@ -2105,52 +2105,52 @@ test-next-word-or-expression-returns-whole-expression: # *(reg1+reg2<<s+disp) -> 2/mod 4/rm32 reg1/base reg2/index s/scale disp/disp32 # Intermediate structure: base, index, scale, disp # Default values: base: 0, index: 4 (none), scale: 0, disp: 0 -# BEWARE: modifies 'word' -parse-effective-address: # word : (address slice) -> base/eax, index/ecx, scale/edx, disp/ebx +# BEWARE: modifies 'word-slice' +parse-effective-address: # word-slice : (address slice) -> base/eax, index/ecx, scale/edx, disp/ebx # pseudocode: - # ++word->start to skip '*' + # ++word-slice->start to skip '*' # initialize defaults: base=0, index=4, scale=0, disp=0 - # if (*word->start != '(') { - # word = next-token-from-slice(word->start, word->end, "/") - # base = get-slice(Registers, word, row-size=8) + # if (*word-slice->start != '(') { + # word-slice = next-token-from-slice(word-slice->start, word-slice->end, "/") + # base = get-slice(Registers, word-slice, row-size=8) # return # } # # compound expressions # skip whitespace # read register into base # skip whitespace - # if (*word->start == ')') goto end - # if (*word->start == '-') goto displacement - # if (*word->start != '+') goto error1 - # ++word->start to skip '+' + # if (*word-slice->start == ')') goto end + # if (*word-slice->start == '-') goto displacement + # if (*word-slice->start != '+') goto error1 + # ++word-slice->start to skip '+' # skip whitespace # if next 3 characters don't make a register, goto displacement # read register into index # skip whitespace - # if (*word->start == ')') goto end - # if (*word->start == '<') { - # ++word->start to skip '<' - # if (*word->start != '<') goto error2 - # ++word->start to skip '<' + # if (*word-slice->start == ')') goto end + # if (*word-slice->start == '<') { + # ++word-slice->start to skip '<' + # if (*word-slice->start != '<') goto error2 + # ++word-slice->start to skip '<' # skip whitespace # read integer into scale # skip whitespace - # if (*word->start == ')') goto end + # if (*word-slice->start == ')') goto end # } - # if (*word->start not in '+' '-') goto error3 + # if (*word-slice->start not in '+' '-') goto error3 # displacement: # read integer into disp # skip whitespace - # if (*word->start != ')') goto error4 + # if (*word-slice->start != ')') goto error4 # . prolog 55/push-ebp 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp # . save registers 56/push-esi 57/push-edi - # esi = word + # esi = word-slice 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 6/r32/esi 8/disp8 . # copy *(ebp+8) to esi - # ++word->start to skip '*' + # ++word-slice->start to skip '*' ff 0/subop/increment 0/mod/indirect 6/rm32/esi . . . . . . # increment *esi # initialize defaults # base is in edi; we'll move it to eax just before we return @@ -2159,14 +2159,14 @@ parse-effective-address: # word : (address slice) -> base/eax, index/ecx, scale ba/copy-to-edx 0/imm32/.scale bb/copy-to-ebx 0/imm32/disp $parse-effective-address:check-for-simple-register: - # if (*word->start == '(') goto compound expression + # if (*word-slice->start == '(') goto compound expression 8b/copy 0/mod/indirect 6/rm32/esi . . . 0/r32/eax . . # copy *esi to eax 8a/copy-byte 0/mod/indirect 0/rm32/eax . . . 0/r32/AL . . # copy byte at *eax to AL 81 4/subop/and 3/mod/direct 0/rm32/eax . . . . . 0xff/imm32 # bitwise and of eax 3d/compare-eax-and 0x28/imm32/open-paren 74/jump-if-equal $parse-effective-address:compound-expression/disp8 $parse-effective-address:simple-register: - # word = next-token-from-slice(word->start, word->end, "/") + # word-slice = next-token-from-slice(word-slice->start, word-slice->end, "/") # . . push args 56/push-esi 68/push 0x2f/imm32/slash @@ -2176,8 +2176,8 @@ $parse-effective-address:simple-register: e8/call next-token-from-slice/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0x10/imm32 # add to esp - # base = get-slice(Registers, word, row-size=8) - # . eax = get-slice(Registers, word, row-size=8) + # base = get-slice(Registers, word-slice, row-size=8) + # . eax = get-slice(Registers, word-slice, row-size=8) # . . push args 68/push "Registers"/imm32 68/push 8/imm32/row-size @@ -2192,10 +2192,10 @@ $parse-effective-address:simple-register: # return e9/jump $parse-effective-address:end/disp32 $parse-effective-address:compound-expression: - # ++word->start to skip '(' + # ++word-slice->start to skip '(' ff 0/subop/increment 0/mod/indirect 6/rm32/esi . . . . . . # increment *esi # skip whitespace - # . eax = skip-chars-matching-whitespace-in-slice(word->start, word->end) + # . eax = skip-chars-matching-whitespace-in-slice(word-slice->start, word-slice->end) # . . push args ff 6/subop/push 1/mod/*+disp8 6/rm32/esi . . . . 4/disp8 . # push *(esi+4) ff 6/subop/push 0/mod/indirect 6/rm32/esi . . . . . . # push *esi @@ -2203,10 +2203,10 @@ $parse-effective-address:compound-expression: e8/call skip-chars-matching-whitespace-in-slice/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp - # . word->start = eax + # . word-slice->start = eax 89/copy 0/mod/indirect 6/rm32/esi . . . 0/r32/eax . . # copy eax to *esi # read register into base - # . eax = next-register(word) + # . eax = next-register(word-slice) # . . push args ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 . # push *(ebp+8) # . . call @@ -2216,7 +2216,7 @@ $parse-effective-address:compound-expression: # . edi = *eax 8b/copy 0/mod/indirect 0/rm32/eax . . . 7/r32/edi . . # copy *eax to edi # skip whitespace - # . eax = skip-chars-matching-whitespace-in-slice(word->start, word->end) + # . eax = skip-chars-matching-whitespace-in-slice(word-slice->start, word-slice->end) # . . push args ff 6/subop/push 1/mod/*+disp8 6/rm32/esi . . . . 4/disp8 . # push *(esi+4) ff 6/subop/push 0/mod/indirect 6/rm32/esi . . . . . . # push *esi @@ -2224,24 +2224,24 @@ $parse-effective-address:compound-expression: e8/call skip-chars-matching-whitespace-in-slice/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp - # . word->start = eax + # . word-slice->start = eax 89/copy 0/mod/indirect 6/rm32/esi . . . 0/r32/eax . . # copy eax to *esi - # if (*word->start == ')') goto end + # if (*word-slice->start == ')') goto end 8a/copy-byte 0/mod/indirect 0/rm32/eax . . . 0/r32/AL . . # copy byte at *eax to AL 81 4/subop/and 3/mod/direct 0/rm32/eax . . . . . 0xff/imm32 # bitwise and of eax 3d/compare-eax-and 0x29/imm32/close-paren 0f 84/jump-if-equal $parse-effective-address:end/disp32 - # if (*word->start == '-') goto displacement + # if (*word-slice->start == '-') goto displacement 3d/compare-eax-and 0x2d/imm32/minus 0f 84/jump-if-equal $parse-effective-address:displacement/disp32 - # if (*word->start != '+') goto error1 + # if (*word-slice->start != '+') goto error1 3d/compare-eax-and 0x2b/imm32/plus 0f 85/jump-if-not-equal $parse-effective-address:error1/disp32 $parse-effective-address:check-for-index: - # ++word->start to skip '+' + # ++word-slice->start to skip '+' ff 0/subop/increment 0/mod/indirect 6/rm32/esi . . . . . . # increment *esi # skip whitespace - # . eax = skip-chars-matching-whitespace-in-slice(word->start, word->end) + # . eax = skip-chars-matching-whitespace-in-slice(word-slice->start, word-slice->end) # . . push args ff 6/subop/push 1/mod/*+disp8 6/rm32/esi . . . . 4/disp8 . # push *(esi+4) ff 6/subop/push 0/mod/indirect 6/rm32/esi . . . . . . # push *esi @@ -2249,16 +2249,16 @@ $parse-effective-address:check-for-index: e8/call skip-chars-matching-whitespace-in-slice/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp - # . word->start = eax + # . word-slice->start = eax 89/copy 0/mod/indirect 6/rm32/esi . . . 0/r32/eax . . # copy eax to *esi $parse-effective-address:resolve-ambiguity: # if next 3 characters don't make a register, goto displacement # . spill ecx 51/push-ecx - # . var tmp/ecx = {word->start, word->start+3} - # . . ecx = word->start + # . var tmp/ecx = {word-slice->start, word-slice->start+3} + # . . ecx = word-slice->start 89/copy 3/mod/direct 1/rm32/ecx . . . 0/r32/eax . . # copy eax to ecx - # . . eax = word->start+3 + # . . eax = word-slice->start+3 05/add-to-eax 3/imm32 # . . push 50/push-eax @@ -2283,7 +2283,7 @@ $parse-effective-address:resolve-ambiguity: 0f 84/jump-if-equal $parse-effective-address:displacement/disp32 $parse-effective-address:index: # read register into index - # . eax = next-register(word) + # . eax = next-register(word-slice) # . . push args ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 . # push *(ebp+8) # . . call @@ -2293,7 +2293,7 @@ $parse-effective-address:index: # . ecx = *eax 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . . # copy *eax to ecx # skip whitespace - # . eax = skip-chars-matching-whitespace-in-slice(word->start, word->end) + # . eax = skip-chars-matching-whitespace-in-slice(word-slice->start, word-slice->end) # . . push args ff 6/subop/push 1/mod/*+disp8 6/rm32/esi . . . . 4/disp8 . # push *(esi+4) ff 6/subop/push 0/mod/indirect 6/rm32/esi . . . . . . # push *esi @@ -2301,29 +2301,29 @@ $parse-effective-address:index: e8/call skip-chars-matching-whitespace-in-slice/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp - # . word->start = eax + # . word-slice->start = eax 89/copy 0/mod/indirect 6/rm32/esi . . . 0/r32/eax . . # copy eax to *esi - # if (*word->start == ')') goto end + # if (*word-slice->start == ')') goto end 8a/copy-byte 0/mod/indirect 0/rm32/eax . . . 0/r32/AL . . # copy byte at *eax to AL 81 4/subop/and 3/mod/direct 0/rm32/eax . . . . . 0xff/imm32 # bitwise and of eax 3d/compare-eax-and 0x29/imm32/close-paren 0f 84/jump-if-equal $parse-effective-address:end/disp32 $parse-effective-address:check-for-scale: - # if (*word->start != '<') goto next check + # if (*word-slice->start != '<') goto next check 3d/compare-eax-and 0x3c/imm32/less-than 75/jump-if-not-equal $parse-effective-address:check-for-displacement/disp8 - # ++word->start to skip '<' + # ++word-slice->start to skip '<' ff 0/subop/increment 0/mod/indirect 6/rm32/esi . . . . . . # increment *esi - # if (*word->start != '<') goto error2 + # if (*word-slice->start != '<') goto error2 8b/copy 0/mod/indirect 6/rm32/esi . . . 0/r32/eax . . # copy *esi to eax 8a/copy-byte 0/mod/indirect 0/rm32/eax . . . 0/r32/AL . . # copy byte at *eax to AL 81 4/subop/and 3/mod/direct 0/rm32/eax . . . . . 0xff/imm32 # bitwise and of eax 3d/compare-eax-and 0x3c/imm32/less-than 0f 85/jump-if-not-equal $parse-effective-address:error2/disp32 - # ++word->start to skip '<' + # ++word-slice->start to skip '<' ff 0/subop/increment 0/mod/indirect 6/rm32/esi . . . . . . # increment *esi # skip whitespace - # . eax = skip-chars-matching-whitespace-in-slice(word->start, word->end) + # . eax = skip-chars-matching-whitespace-in-slice(word-slice->start, word-slice->end) # . . push args ff 6/subop/push 1/mod/*+disp8 6/rm32/esi . . . . 4/disp8 . # push *(esi+4) ff 6/subop/push 0/mod/indirect 6/rm32/esi . . . . . . # push *esi @@ -2331,11 +2331,11 @@ $parse-effective-address:check-for-scale: e8/call skip-chars-matching-whitespace-in-slice/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp - # . word->start = eax + # . word-slice->start = eax 89/copy 0/mod/indirect 6/rm32/esi . . . 0/r32/eax . . # copy eax to *esi $parse-effective-address:scale: # read positive integer into scale - # . eax = next-positive-hex-int(word) + # . eax = next-positive-hex-int(word-slice) # . . push args ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 . # push *(ebp+8) # . . call @@ -2345,7 +2345,7 @@ $parse-effective-address:scale: # . edx = eax 89/copy 3/mod/direct 2/rm32/edx . . . 0/r32/eax . . # copy eax to edx # skip whitespace - # . eax = skip-chars-matching-whitespace-in-slice(word->start, word->end) + # . eax = skip-chars-matching-whitespace-in-slice(word-slice->start, word-slice->end) # . . push args ff 6/subop/push 1/mod/*+disp8 6/rm32/esi . . . . 4/disp8 . # push *(esi+4) ff 6/subop/push 0/mod/indirect 6/rm32/esi . . . . . . # push *esi @@ -2353,15 +2353,15 @@ $parse-effective-address:scale: e8/call skip-chars-matching-whitespace-in-slice/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp - # . word->start = eax + # . word-slice->start = eax 89/copy 0/mod/indirect 6/rm32/esi . . . 0/r32/eax . . # copy eax to *esi - # if (*word->start == ')') goto end + # if (*word-slice->start == ')') goto end 8a/copy-byte 0/mod/indirect 0/rm32/eax . . . 0/r32/AL . . # copy byte at *eax to AL 81 4/subop/and 3/mod/direct 0/rm32/eax . . . . . 0xff/imm32 # bitwise and of eax 3d/compare-eax-and 0x29/imm32/close-paren 74/jump-if-equal $parse-effective-address:end/disp8 $parse-effective-address:check-for-displacement: - # if (*word->start not in '+' '-') goto error3 + # if (*word-slice->start not in '+' '-') goto error3 3d/compare-eax-and 0x2b/imm32/plus 74/jump-if-equal $parse-effective-address:displacement/disp8 3d/compare-eax-and 0x2d/imm32/minus @@ -2369,7 +2369,7 @@ $parse-effective-address:check-for-displacement: e9/jump $parse-effective-address:error3/disp32 $parse-effective-address:displacement: # read integer into disp - # . eax = next-hex-int(word) + # . eax = next-hex-int(word-slice) # . . push args ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 . # push *(ebp+8) # . . call @@ -2379,7 +2379,7 @@ $parse-effective-address:displacement: # . ebx = eax 89/copy 3/mod/direct 3/rm32/ebx . . . 0/r32/eax . . # copy eax to ebx # skip whitespace - # . eax = skip-chars-matching-whitespace-in-slice(word->start, word->end) + # . eax = skip-chars-matching-whitespace-in-slice(word-slice->start, word-slice->end) # . . push args ff 6/subop/push 1/mod/*+disp8 6/rm32/esi . . . . 4/disp8 . # push *(esi+4) ff 6/subop/push 0/mod/indirect 6/rm32/esi . . . . . . # push *esi @@ -2387,9 +2387,9 @@ $parse-effective-address:displacement: e8/call skip-chars-matching-whitespace-in-slice/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp - # . word->start = eax + # . word-slice->start = eax 89/copy 0/mod/indirect 6/rm32/esi . . . 0/r32/eax . . # copy eax to *esi - # if (*word->start != ')') goto error4 + # if (*word-slice->start != ')') goto error4 8a/copy-byte 0/mod/indirect 0/rm32/eax . . . 0/r32/AL . . # copy byte at *eax to AL 81 4/subop/and 3/mod/direct 0/rm32/eax . . . . . 0xff/imm32 # bitwise and of eax 3d/compare-eax-and 0x29/imm32/close-paren @@ -2580,7 +2580,7 @@ next-register: # in : (address slice) -> reg/eax : int 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . . # copy esp to ecx # in->start += 3 81 0/subop/add 0/mod/indirect 6/rm32/esi . . . . . 3/imm32 # add to *esi - # eax = get-slice(Registers, word, row-size=8) + # eax = get-slice(Registers, reg-slice, row-size=8) # . . push args 68/push "next-register"/imm32 68/push 8/imm32/row-size @@ -4138,7 +4138,7 @@ $next-hex-int:need-to-negate: $next-hex-int:skip-whitespace: # spill eax 50/push-eax - # eax = skip-chars-matching-whitespace-in-slice(word->start, word->end) + # eax = skip-chars-matching-whitespace-in-slice(word-slice->start, word-slice->end) # . . push args 52/push-edx 51/push-ecx @@ -4204,7 +4204,7 @@ $next-hex-int:break: $next-hex-int:negate: f7 3/subop/negate 3/mod/direct 7/rm32/edi . . . . . . # negate edi $next-hex-int:end: - # word->start = curr + # word-slice->start = curr 89/copy 0/mod/indirect 6/rm32/esi . . . 1/r32/ecx . . # copy ecx to *esi # return edi 89/copy 3/mod/direct 0/rm32/eax . . . 7/r32/edi . . # copy edi to eax @@ -4583,7 +4583,7 @@ $next-positive-hex-int:loop: # loop eb/jump $next-positive-hex-int:loop/disp8 $next-positive-hex-int:end: - # word->start = curr + # word-slice->start = curr 89/copy 0/mod/indirect 6/rm32/esi . . . 1/r32/ecx . . # copy ecx to *esi # return edi 89/copy 3/mod/direct 0/rm32/eax . . . 7/r32/edi . . # copy edi to eax |