diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-05-06 14:24:37 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-05-18 00:44:48 -0700 |
commit | ed91d9b0950109cbe69139ebf025f06410e10580 (patch) | |
tree | f0603ff6d7764230349d55abe6fdf91fb5257660 | |
parent | 5a66c5dea9029d3dfffc92835adab9b292017b51 (diff) | |
download | mu-ed91d9b0950109cbe69139ebf025f06410e10580.tar.gz |
mu.subx: find-in-function-outputs
-rw-r--r-- | apps/mu.subx | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/apps/mu.subx b/apps/mu.subx index 451b7bfa..2840b124 100644 --- a/apps/mu.subx +++ b/apps/mu.subx @@ -5710,36 +5710,52 @@ $lookup-or-define-var:end: 5d/pop-to-ebp c3/return -# TODO find-in-function-outputs: # fn: (addr function), name: (addr slice), out: (addr handle var) # . prologue 55/push-ebp 89/<- %ebp 4/r32/esp # . save registers + 50/push-eax 51/push-ecx - # var curr/ecx: (handle list var) = fn->outputs + # var curr/ecx: (addr list var) = lookup(fn->outputs) 8b/-> *(ebp+8) 1/r32/ecx - 8b/-> *(ecx+0xc) 1/r32/ecx + (lookup *(ecx+0x10) *(ecx+0x14)) # => eax + 89/<- %ecx 0/r32/eax # while curr != null { 81 7/subop/compare %ecx 0/imm32 74/jump-if-= break/disp8 - # var v: (handle var) = *curr - 8b/-> *ecx 0/r32/eax # List-value - # if (curr->name == name) return curr - 50/push-eax - (slice-equal? *(ebp+0xc) *eax) # => eax + # var v/eax: (addr var) = lookup(curr->value) + (lookup *ecx *(ecx+4)) # List-value List-value => eax + # var s/eax: (addr array byte) = lookup(v->name) + (lookup *eax *(eax+4)) # Var-name Var-name => eax + # if (s == name) return curr->value + (slice-equal? *(ebp+0xc) %eax) # => eax 3d/compare-eax-and 0/imm32/false - 58/pop-to-eax - 75/jump-if-!= $find-in-function-outputs:end/disp8 + { + 74/jump-if-= break/disp8 + # var edi = out + 57/push-edi + 89/<- *(ebp+0x10) 7/r32/edi + # *out = curr->value + 8b/-> *ecx 0/r32/eax + 89/<- *edi 0/r32/eax + 8b/-> *(ecx+4) 0/r32/eax + 89/<- *(edi+4) 0/r32/eax + # + 5f/pop-to-edi + eb/jump $find-in-function-outputs:end/disp8 + } # curr = curr->next - 8b/-> *(ecx+4) 1/r32/ecx # List-next + (lookup *(ecx+8) *(ecx+0xc)) # List-next List-next => eax + 89/<- %ecx 0/r32/eax eb/jump loop/disp8 } b8/copy-to-eax 0/imm32 $find-in-function-outputs:end: # . restore registers 59/pop-to-ecx + 58/pop-to-eax # . epilogue 89/<- %esp 5/r32/ebp 5d/pop-to-ebp |