diff options
Diffstat (limited to 'subx/apps/assort.subx')
-rw-r--r-- | subx/apps/assort.subx | 53 |
1 files changed, 34 insertions, 19 deletions
diff --git a/subx/apps/assort.subx b/subx/apps/assort.subx index 14956d82..8c5fd184 100644 --- a/subx/apps/assort.subx +++ b/subx/apps/assort.subx @@ -453,13 +453,14 @@ read-segments: # in : (address buffered-file), table : (address stream {string, # continue # if slice-equal?(word-slice, "==") # var segment-name = next-word(line) - # curr-segment = get-or-insert-stream(table, segment-name, Segment-size) - # if curr-segment->write == 0 - # rewind-stream(line) - # write-stream(curr-segment, line) - # else - # rewind-stream(line) - # write-stream(curr-segment, line) # abort if curr-segment overflows + # segment-slot = get-or-insert(table, segment-name, row-size=8) + # curr-segment = *segment-slot + # if curr-segment != 0 + # continue + # curr-segment = new-stream(Segment-size) + # *segment-slot = curr-segment + # rewind-stream(line) + # write-stream(curr-segment, line) # abort if curr-segment overflows # # word-slice and segment-name are both slices with disjoint lifetimes, so # we'll use the same address for them. @@ -609,10 +610,7 @@ $read-segments:check-for-segment-header: #? # . . discard args #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP #? # }}} - # if slice-equal?(word-slice, "==") - # segment-name = next-word(line) - # curr-segment = get-or-insert-stream(table, segment-name) - # if (curr-segment->write > 0) continue + # if !slice-equal?(word-slice, "==") goto next check # . EAX = slice-equal?(word-slice, "==") # . . push args 68/push "=="/imm32 @@ -624,7 +622,7 @@ $read-segments:check-for-segment-header: # . if (EAX == 0) goto check3 3d/compare-EAX-and 0/imm32 0f 84/jump-if-equal $read-segments:regular-line/disp32 - # . next-word(line, segment-name) + # segment-name = next-word(line) # . . push args 52/push-EDX 51/push-ECX @@ -674,21 +672,38 @@ $read-segments:check-for-segment-header: #? # . . discard args #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP #? # }}} - # . EAX = get-or-insert-stream(table, segment-name, Segment-size) + # segment-slot/EAX = get-or-insert(table, segment-name, value-size=8) # . . push args - ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Segment-size/disp32 # push *Segment-size + 68/push 8/imm32/value-size 52/push-EDX ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . call - e8/call get-or-insert-stream/disp32 + e8/call get-or-insert/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP + # curr-segment = *segment-slot + 8b/copy 0/mod/indirect 0/rm32/EAX . . . 3/r32/EBX . . # copy *EAX to EBX + # if (curr-segment != 0) continue + 81 7/subop/compare 3/mod/direct 3/rm32/EBX . . . . . 0/imm32 # compare EBX + 0f 85/jump-if-not-equal $read-segments:loop/disp32 + # curr-segment = new-stream(Heap, Segment-size, 1) + # . save segment-slot + 50/push-EAX + # . EAX = new-stream(Heap, Segment-size, 1) + # . . push args + 68/push 1/imm32 + ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Segment-size/disp32 # push *Segment-size + 68/push Heap/imm32 + # . . call + e8/call new-stream/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP # . curr-segment = EAX 89/copy 3/mod/direct 3/rm32/EBX . . . 0/r32/EAX . . # copy EAX to EBX - # . if (curr-segment->write > 0) continue - 8b/copy 0/mod/indirect 0/rm32/EAX . . . 0/r32/EAX . . # copy *EAX to EAX - 3d/compare-EAX-and 0/imm32 - 0f 8f/jump-if-greater $read-segments:loop/disp32 + # . restore segment-slot + 58/pop-to-EAX + # *segment-slot = curr-segment + 89/copy 0/mod/indirect 0/rm32/EAX . . . 3/r32/EBX . . # copy EBX to *EAX # fall through $read-segments:regular-line: # rewind-stream(line) |