diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-04-06 06:39:28 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-04-06 06:41:49 -0700 |
commit | a17df22d308237f4da184bf983d01bf35710b0a9 (patch) | |
tree | 9bce4ff3df2d7c231e80a8cdb3424d9912909a72 /apps | |
parent | edfc3e2e2ccc3aac04b316db3972150443c84673 (diff) | |
download | mu-a17df22d308237f4da184bf983d01bf35710b0a9.tar.gz |
6188
Diffstat (limited to 'apps')
-rw-r--r-- | apps/survey.subx | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/apps/survey.subx b/apps/survey.subx index a74f7273..4a84baa4 100644 --- a/apps/survey.subx +++ b/apps/survey.subx @@ -620,6 +620,10 @@ compute-offsets:segment-tmp: # slice == code +# write segments->file-offset, +# segments->size, +# labels->segment-name, and +# labels->segment-offset compute-offsets: # in: (addr stream byte), segments: (addr stream {string, segment-info}), labels: (addr stream {string, label-info}) # skeleton: # for lines in 'in' @@ -631,7 +635,9 @@ compute-offsets: # in: (addr stream byte), segments: (addr stream {string, segm # default # # pseudocode: - # curr-segment-name: (addr string) = 0 + # var curr-segment-name: (addr string) = 0 + # var file-offset = 0 + # var segment-offset = 0 # var line: (stream byte 512) # while true # line loop # clear-stream(line) @@ -646,7 +652,7 @@ compute-offsets: # in: (addr stream byte), segments: (addr stream {string, segm # else if slice-equal?(word-slice, "==") # if curr-segment-name != 0 # seg = get-or-insert(segments, curr-segment-name) - # seg->size = *file-offset - seg->file-offset + # seg->size = file-offset - seg->file-offset # trace("segment '", curr-segment-name, "' has size ", seg->size) # segment-tmp = next-word(line) # curr-segment-name = slice-to-string(segment-tmp) @@ -657,7 +663,7 @@ compute-offsets: # in: (addr stream byte), segments: (addr stream {string, segm # abort # seg = get-or-insert(segments, curr-segment-name) # seg->starting-address = parse-hex-int-from-slice(segment-tmp) - # seg->file-offset = *file-offset + # seg->file-offset = file-offset # trace("segment '", curr-segment-name, "' is at file offset ", seg->file-offset) # segment-offset = 0 # break (next line) @@ -671,8 +677,10 @@ compute-offsets: # in: (addr stream byte), segments: (addr stream {string, segm # # labels occupy no space, so no need to increment offsets # else # width = compute-width-of-slice(word-slice) - # *segment-offset += width - # *file-offset += width + # segment-offset += width + # file-offset += width + # seg = get-or-insert-handle(segments, curr-segment-name) + # seg->size = file-offset - seg->file-offset # # . prologue 55/push-ebp @@ -687,9 +695,9 @@ compute-offsets: # in: (addr stream byte), segments: (addr stream {string, segm # curr-segment-name/esi = 0 31/xor 3/mod/direct 6/rm32/esi . . . 6/r32/esi . . # clear esi # file-offset = 0 - c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . compute-offsets:file-offset/disp32 0/imm32 # copy to *compute-offsets:word-slice + c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . compute-offsets:file-offset/disp32 0/imm32 # copy to *compute-offsets:file-offset # segment-offset = 0 - c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . compute-offsets:segment-offset/disp32 0/imm32 # copy to *compute-offsets:word-slice + c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . compute-offsets:segment-offset/disp32 0/imm32 # copy to *compute-offsets:segment-offset # var line/ecx: (stream byte 512) 81 5/subop/subtract 3/mod/direct 4/rm32/esp . . . . . 0x200/imm32 # subtract from esp 68/push 0x200/imm32/size @@ -1377,6 +1385,9 @@ test-compute-offsets: 5d/pop-to-ebp c3/return +# write segments->file-offset, +# segments->address, and +# labels->address compute-addresses: # segments: (addr stream {string, segment-info}), labels: (addr stream {string, label-info}) # pseudocode: # srow: (addr segment-info) = segments->data |