diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-08-22 13:59:57 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-08-22 13:59:57 -0700 |
commit | ef8e98dd062473e3dff77a4a576c6078a9a3d028 (patch) | |
tree | 26a0cc9ce3e35fc768c2097f30a3f59a885d906b /apps | |
parent | 0361a76d86a38ca02778afc915d86c4ffa608bf7 (diff) | |
download | mu-ef8e98dd062473e3dff77a4a576c6078a9a3d028.tar.gz |
6725 - support negative literals
Diffstat (limited to 'apps')
-rwxr-xr-x | apps/mu | bin | 388302 -> 388330 bytes | |||
-rw-r--r-- | apps/mu.subx | 36 |
2 files changed, 27 insertions, 9 deletions
diff --git a/apps/mu b/apps/mu index aa90ea16..b57801de 100755 --- a/apps/mu +++ b/apps/mu Binary files differdiff --git a/apps/mu.subx b/apps/mu.subx index 52070ad7..28a8c886 100644 --- a/apps/mu.subx +++ b/apps/mu.subx @@ -10346,8 +10346,10 @@ lookup-var-or-literal: # name: (addr slice), vars: (addr stack live-var), out: 8b/-> *esi 1/r32/ecx 8a/copy-byte *ecx 1/r32/CL 81 4/subop/and %ecx 0xff/imm32 - # if is-decimal-digit?(c) return new var(name) + # if (is-decimal-digit?(c) || c == '-') return new var(name) { + 81 7/subop/compare %ecx 0x2d/imm32/dash + 74/jump-if-= $lookup-var-or-literal:literal/disp8 (is-decimal-digit? %ecx) # => eax 3d/compare-eax-and 0/imm32/false 74/jump-if-= break/disp8 @@ -11050,21 +11052,37 @@ check-mu-hex-int: # name: (addr slice), err: (addr buffered-file), ed: (addr ex 50/push-eax 51/push-ecx 52/push-edx - # + # ecx = name 8b/-> *(ebp+8) 1/r32/ecx - # var start/ecx: (addr byte) = name->start - 8b/-> *(ecx+4) 2/r32/edx + # var start/edx: (addr byte) = name->start + 8b/-> *ecx 2/r32/edx + # if (*start == '-') ++start + b8/copy-to-eax 0/imm32 + 8a/copy-byte *edx 0/r32/AL + 3d/compare-eax-and 0x2d/imm32/dash + { + 75/jump-if-!= break/disp8 + 42/increment-edx + } # var end/ecx: (addr byte) = name->end - 8b/-> *ecx 1/r32/ecx + 8b/-> *(ecx+4) 1/r32/ecx # var len/eax: int = name->end - name->start - 89/<- %eax 2/r32/edx - 29/subtract-from %eax 1/r32/ecx + 89/<- %eax 1/r32/ecx + 29/subtract-from %eax 2/r32/edx # if (len <= 1) return 3d/compare-eax-with 1/imm32 0f 8e/jump-if-<= $check-mu-hex-int:end/disp32 $check-mu-hex-int:length->-1: - # if slice-starts-with?("0x") return - (slice-starts-with? *(ebp+8) "0x") # => eax + # if slice-starts-with?({start, end}, "0x") return + # . var tmp = {start, end} + 51/push-ecx + 52/push-edx + 89/<- %eax 4/r32/esp + # . + (slice-starts-with? %eax "0x") # => eax + # . reclaim tmp + 81 0/subop/add %esp 8/imm32 + # . 3d/compare-eax-with 0/imm32/false 75/jump-if-!= $check-mu-hex-int:end/disp8 $check-mu-hex-int:abort: |