diff --git a/subx/apps/survey b/subx/apps/survey index 28224ac6..aeb2290b 100755 Binary files a/subx/apps/survey and b/subx/apps/survey differ diff --git a/subx/apps/survey.subx b/subx/apps/survey.subx index c7f7b0a9..a3e5cb5a 100644 --- a/subx/apps/survey.subx +++ b/subx/apps/survey.subx @@ -593,53 +593,53 @@ $compute-offsets:construct-next-segment: e8/call next-word/disp32 # . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # dump curr-segment-name if not null (clobbering EAX) {{{ - # . if (curr-segment-name == 0) goto update-curr-segment-name - 81 7/subop/compare 3/mod/direct 6/rm32/ESI . . . . . 0/imm32 # compare ESI - 74/jump-if-equal $compute-offsets:update-curr-segment-name/disp8 - # . write(2/stderr, "setting segment to: ") - # . . push args - 68/push "setting segment to: "/imm32 - 68/push 2/imm32/stderr - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . clear-stream(Stderr+4) - # . . push args - b8/copy-to-EAX Stderr/imm32 - 05/add-to-EAX 4/imm32 - 50/push-EAX - # . . call - e8/call clear-stream/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - # . . restore EAX - 58/pop-to-EAX - # . write-buffered(Stderr, curr-segment-name) - # . . push args - 56/push-ESI - 68/push Stderr/imm32 - # . . call - e8/call write-buffered/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . flush(Stderr) - # . . push args - 68/push Stderr/imm32 - # . . call - e8/call flush/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - # . write(2/stderr, "$\n") - # . . push args - 68/push "$\n"/imm32 - 68/push 2/imm32/stderr - # . . call - e8/call write/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # }}} +#? # dump curr-segment-name if not null (clobbering EAX) {{{ +#? # . if (curr-segment-name == 0) goto update-curr-segment-name +#? 81 7/subop/compare 3/mod/direct 6/rm32/ESI . . . . . 0/imm32 # compare ESI +#? 74/jump-if-equal $compute-offsets:update-curr-segment-name/disp8 +#? # . write(2/stderr, "setting segment to: ") +#? # . . push args +#? 68/push "setting segment to: "/imm32 +#? 68/push 2/imm32/stderr +#? # . . call +#? e8/call write/disp32 +#? # . . discard args +#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +#? # . clear-stream(Stderr+4) +#? # . . push args +#? b8/copy-to-EAX Stderr/imm32 +#? 05/add-to-EAX 4/imm32 +#? 50/push-EAX +#? # . . call +#? e8/call clear-stream/disp32 +#? # . . discard args +#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +#? # . . restore EAX +#? 58/pop-to-EAX +#? # . write-buffered(Stderr, curr-segment-name) +#? # . . push args +#? 56/push-ESI +#? 68/push Stderr/imm32 +#? # . . call +#? e8/call write-buffered/disp32 +#? # . . discard args +#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +#? # . flush(Stderr) +#? # . . push args +#? 68/push Stderr/imm32 +#? # . . call +#? e8/call flush/disp32 +#? # . . discard args +#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +#? # . write(2/stderr, "$\n") +#? # . . push args +#? 68/push "$\n"/imm32 +#? 68/push 2/imm32/stderr +#? # . . call +#? e8/call write/disp32 +#? # . . discard args +#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +#? # }}} $compute-offsets:update-curr-segment-name: # curr-segment-name = slice-to-string(segment-tmp) # . EAX = slice-to-string(Heap, segment-tmp) @@ -731,9 +731,10 @@ $compute-offsets:case-label: e8/call get-or-insert-slice/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP +$compute-offsets:save-label-offset: # x->segment-offset = segment-offset # . EBX = segment-offset - 8f 0/subop/pop 0/mod/indirect 5/rm32/.disp32 . . . compute-offsets:segment-offset/disp32 + 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/EBX compute-offsets:segment-offset/disp32 # copy *segment-offset to EBX # . x->segment-offset = EBX 89/copy 1/mod/*+disp8 0/rm32/EAX . . . 3/r32/EBX 4/disp8 . # copy EBX to *(EAX+4) # trace-slsss("label '" word-slice/EDX "' is in segment '" current-segment-name "'.") @@ -776,6 +777,53 @@ $compute-offsets:case-default: 01/add 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX compute-offsets:segment-offset/disp32 # add EAX to *segment-offset # file-offset += width 01/add 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX compute-offsets:file-offset/disp32 # add EAX to *file-offset +#? # dump segment-offset {{{ +#? # . write(2/stderr, "segment-offset: ") +#? # . . push args +#? 68/push "segment-offset: "/imm32 +#? 68/push 2/imm32/stderr +#? # . . call +#? e8/call write/disp32 +#? # . . discard args +#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +#? # . clear-stream(Stderr+4) +#? # . . save EAX +#? 50/push-EAX +#? # . . push args +#? b8/copy-to-EAX Stderr/imm32 +#? 05/add-to-EAX 4/imm32 +#? 50/push-EAX +#? # . . call +#? e8/call clear-stream/disp32 +#? # . . discard args +#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +#? # . . restore EAX +#? 58/pop-to-EAX +#? # . print-int32-buffered(Stderr, segment-offset) +#? # . . push args +#? 52/push-EDX +#? ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . compute-offsets:segment-offset/disp32 # push *segment-offset +#? 68/push Stderr/imm32 +#? # . . call +#? e8/call print-int32-buffered/disp32 +#? # . . discard args +#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +#? # . flush(Stderr) +#? # . . push args +#? 68/push Stderr/imm32 +#? # . . call +#? e8/call flush/disp32 +#? # . . discard args +#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +#? # . write(2/stderr, "\n") +#? # . . push args +#? 68/push "\n"/imm32 +#? 68/push 2/imm32/stderr +#? # . . call +#? e8/call write/disp32 +#? # . . discard args +#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +#? # }}} e9/jump $compute-offsets:word-loop/disp32 $compute-offsets:break-line-loop: # seg/EAX = get-or-insert(segments, curr-segment-name, row-size=16) @@ -801,7 +849,7 @@ $compute-offsets:break-line-loop: # . restore ECX 59/pop-to-ECX # trace-sssns("segment '", curr-segment-name, "' has size ", seg->size, ".") - # . trace-sssns("segment '", curr-segment-name, "' has size ", EAX, ".") + # . trace-sssns("segment '", curr-segment-name, "' has size ", EBX, ".") # . . push args 68/push "."/imm32 53/push-EBX