Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SubX in SubX: computing addresses for labels #34

Merged
merged 172 commits into from
Jul 14, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
172 commits
Select commit Hold shift + click to select a range
2a72df4
initial skeleton for survey.subx
akkartik May 18, 2019
90fd6a6
.
akkartik May 19, 2019
d3d452e
.
akkartik May 20, 2019
886097a
.
akkartik May 25, 2019
7c06e10
.
akkartik May 25, 2019
0b2d2d9
new primitive for tests: check-string-equal
akkartik May 25, 2019
6c03f2e
new primitive: array-equal?
akkartik May 25, 2019
bd31dbe
.
akkartik May 25, 2019
5610284
new primitive: parse-array-of-ints
akkartik May 26, 2019
cb3d96b
new primitive: check-array-equal
akkartik May 26, 2019
7c575de
.
akkartik May 26, 2019
965dd1b
.
akkartik May 27, 2019
43f1c41
start fleshing out trace support some more
akkartik Jun 6, 2019
d9c4825
added tests for compute-width
charles-l Jun 8, 2019
0d0af0a
implement compute-width
charles-l Jun 8, 2019
21cb677
.
akkartik Jun 8, 2019
627b35b
.
akkartik Jun 8, 2019
3527296
Fix stale `initialize-trace-stream`
akkartik Jun 8, 2019
35dd69f
.
akkartik Jun 8, 2019
c437318
snapshot of trace primitives
akkartik Jun 8, 2019
53f5c71
fix stale docs
akkartik Jun 8, 2019
eb75af0
.
akkartik Jun 8, 2019
2879505
.
akkartik Jun 8, 2019
6928eb9
.
akkartik Jun 9, 2019
f47066a
.
akkartik Jun 12, 2019
5ac0786
new Vim convenience macro
akkartik Jun 12, 2019
fa66b0a
only open the trace if test fails
akkartik Jun 12, 2019
fc95aaf
fork vimrc for Mu and SubX
akkartik Jun 12, 2019
edac54a
rerun most recent test if cursor not in a test
akkartik Jun 12, 2019
bf569a9
.
akkartik Jun 12, 2019
66bce43
.
akkartik Jun 12, 2019
ab107e1
.
akkartik Jun 12, 2019
55ea211
flesh out survey tests
akkartik Jun 12, 2019
acdd7a7
.
akkartik Jun 13, 2019
b5f8041
pseudocode skeletons for all functions
akkartik Jun 13, 2019
fbb92d8
implement skip-next-line
charles-l Jun 15, 2019
1efabd2
implement next-line-matches?
charles-l Jun 15, 2019
07ef071
fix bug in skip-next-line
charles-l Jun 16, 2019
e9860d2
.
akkartik Jun 17, 2019
01b6cfe
support `CFLAGS=-g ./run_one_test.sh ...`
akkartik Jun 17, 2019
382029b
bugfix to opcode 8f; it requires subops
akkartik Jun 17, 2019
8effbb4
move test data to bottom of file
akkartik Jun 17, 2019
21299a3
fix two hangs in trace-scan
akkartik Jun 17, 2019
ff30b00
.
akkartik Jun 17, 2019
f3d3c4e
.
akkartik Jun 17, 2019
3b2d621
.
akkartik Jun 17, 2019
5be5fcd
fix layout and some comments
akkartik Jun 17, 2019
a7e21db
.
akkartik Jun 28, 2019
33ba3de
.
akkartik Jun 28, 2019
397f7c4
.
akkartik Jun 29, 2019
8e9fde4
initial draft of solution for 'compute-addresses'
akkartik Jun 29, 2019
aa09f29
.
akkartik Jun 29, 2019
0721fb5
Implement is-label?
charles-l Jun 29, 2019
676a80b
add test data
charles-l Jun 29, 2019
b41c2c7
.
akkartik Jun 29, 2019
5df043b
.
akkartik Jun 29, 2019
89a7cac
.
akkartik Jun 29, 2019
0fab3de
.
akkartik Jun 30, 2019
5a91762
.
akkartik Jun 30, 2019
7a276d6
.
akkartik Jun 30, 2019
eada7e3
.
akkartik Jun 30, 2019
954133e
.
akkartik Jun 30, 2019
51c311d
unsigned comparison for addresses in more places
akkartik Jul 1, 2019
4d0a047
.
akkartik Jul 1, 2019
120a740
some primitives for emitting traces
akkartik Jul 2, 2019
065b82a
.
akkartik Jul 2, 2019
0e51077
.
akkartik Jul 2, 2019
22cea31
.
akkartik Jul 2, 2019
13be43d
.
akkartik Jul 2, 2019
1c576e9
error in pseudocode for compute-offsets
akkartik Jul 2, 2019
dc84843
.
akkartik Jul 2, 2019
9d5ba2d
.
akkartik Jul 2, 2019
7895d0a
.
akkartik Jul 2, 2019
34cf8a7
subx/survey: now computing label addresses
akkartik Jul 2, 2019
87ef858
updates to survey - part of compute-offsets implemented
charles-l Jul 4, 2019
98096ca
add is-label block
charles-l Jul 4, 2019
d818fdd
add todo for section thats not quite complete
charles-l Jul 4, 2019
85cc81a
.
akkartik Jul 4, 2019
76aec0e
.
akkartik Jul 4, 2019
06abba2
Merge branch 'master' into survey
akkartik Jul 4, 2019
c015791
.
akkartik Jul 4, 2019
f80a025
implement segment section in compute-offsets
charles-l Jul 4, 2019
9ac5834
more progress in compute-offset
charles-l Jul 5, 2019
b950602
cleanup in compute-offset and fix bug in compute-width
charles-l Jul 7, 2019
764b572
move phase 3 out of helpers
akkartik Jul 7, 2019
633c289
.
akkartik Jul 7, 2019
fb8474a
new failing test: emit-segments
akkartik Jul 7, 2019
c17643b
remove segfaults in survey.subx
charles-l Jul 7, 2019
c0a9043
made first compute-offset test pass
charles-l Jul 8, 2019
c38b36e
move `is-label?` to `subx-common`
akkartik Jul 8, 2019
23bc365
.
akkartik Jul 8, 2019
195d62f
build `num-bytes`
akkartik Jul 8, 2019
6a9d56f
.
akkartik Jul 8, 2019
7ba3337
.
akkartik Jul 8, 2019
761833a
.
akkartik Jul 8, 2019
58b60a6
.
akkartik Jul 8, 2019
7af8f4e
preserve truthiness of non-booleans
akkartik Jul 8, 2019
597ce7a
.
akkartik Jul 8, 2019
fc07ee4
.
akkartik Jul 8, 2019
e5cffe3
.
akkartik Jul 8, 2019
925fc49
.
akkartik Jul 8, 2019
de3d481
pull a couple more functions into subx-common
akkartik Jul 8, 2019
01b4530
colocate compute-offsets with its globals
akkartik Jul 8, 2019
b5da792
.
akkartik Jul 8, 2019
fe77a29
.
akkartik Jul 8, 2019
476049a
.
akkartik Jul 9, 2019
c01f78f
update library docs
akkartik Jul 9, 2019
7761194
switch to global Heap
akkartik Jul 9, 2019
b8b9225
keep labels definitions on a separate line
akkartik Jul 9, 2019
acc83b6
there's a variant of get-or-insert for slices
akkartik Jul 9, 2019
dc7066c
there's a variant of compute-width for slices
akkartik Jul 9, 2019
eb4b45d
.
akkartik Jul 9, 2019
ba93234
move 'segment-start' to a global variable as well
akkartik Jul 9, 2019
d6c6aeb
.
akkartik Jul 9, 2019
ca32bfb
.
akkartik Jul 9, 2019
7a752f8
this looks like a bug
akkartik Jul 9, 2019
f6ea256
preserve truthiness of non-booleans
akkartik Jul 9, 2019
5821a0f
clean up after a few calls
akkartik Jul 9, 2019
b14457a
.
akkartik Jul 9, 2019
c7564b7
.
akkartik Jul 9, 2019
4a73902
.
akkartik Jul 10, 2019
7bc9240
.
akkartik Jul 10, 2019
4a96b65
.
akkartik Jul 10, 2019
58d03e4
bug: null address messing up instruction decode
akkartik Jul 10, 2019
20a5277
done with emit-segments
akkartik Jul 10, 2019
48aabc8
mostly done with emit-output
akkartik Jul 10, 2019
57714dd
.
akkartik Jul 10, 2019
7e9cdf3
.
akkartik Jul 10, 2019
84aa2fa
.
akkartik Jul 10, 2019
1e4f110
.
akkartik Jul 10, 2019
3f097f3
finally tracked down binary character in traces
akkartik Jul 10, 2019
c6ec8fa
zero out new rows returned by get-or-insert
akkartik Jul 10, 2019
304bce5
start distinguishing table lookups from inserts
akkartik Jul 10, 2019
c5f7d9d
.
akkartik Jul 10, 2019
4ae08e0
.
akkartik Jul 10, 2019
551112f
.
akkartik Jul 10, 2019
538f24c
.
akkartik Jul 10, 2019
c2725b6
made test 2 pass
charles-l Jul 12, 2019
2805308
updated test so 'x' is relative to file-offset not segment offset
charles-l Jul 12, 2019
3a3e7a9
move discard instruction to correct spot
charles-l Jul 12, 2019
f57a458
.
akkartik Jul 12, 2019
be995e2
revert compute-offsets to segment-relative offsets
akkartik Jul 12, 2019
554bd09
label offset computation still has a bug
akkartik Jul 12, 2019
bbfa2ac
.
akkartik Jul 12, 2019
98994d5
the problem: curr-segment-name is stale
akkartik Jul 12, 2019
2c45de0
.
akkartik Jul 12, 2019
7fed723
.
akkartik Jul 12, 2019
a0c877f
one failure remaining in test-compute-offsets
akkartik Jul 12, 2019
022075e
.
akkartik Jul 12, 2019
0be794d
.
akkartik Jul 12, 2019
38a314d
rearrange compute-offsets cases
akkartik Jul 12, 2019
e150e6e
the pseudocode is pretty long, so add an outline
akkartik Jul 12, 2019
f0eb631
compute-offsets test now passing
akkartik Jul 12, 2019
2870525
.
akkartik Jul 12, 2019
066e01f
.
akkartik Jul 12, 2019
94f2de6
.
akkartik Jul 12, 2019
8ba17d8
.
akkartik Jul 13, 2019
fb935ea
fixed one bug, hit another
akkartik Jul 13, 2019
f518bd9
.
akkartik Jul 13, 2019
a259389
fixed second bug, hit third
akkartik Jul 13, 2019
4c81119
.
akkartik Jul 13, 2019
195a0d7
fixed third bug, hit fourth
akkartik Jul 13, 2019
50ac5ca
fixed fourth bug, hit fifth
akkartik Jul 13, 2019
d30c716
.
akkartik Jul 13, 2019
58c643c
fixed fifth bug, hit sixth
akkartik Jul 13, 2019
62bb910
.
akkartik Jul 13, 2019
c6f91e1
`test-convert-computes-addresses` bugfix six
akkartik Jul 14, 2019
17fb42c
grow the output stream; test now completes
akkartik Jul 14, 2019
2773d5a
survey.subx now passing all tests
akkartik Jul 14, 2019
e63ec16
.
akkartik Jul 14, 2019
ae30c46
add subx/apps/survey to CI
akkartik Jul 14, 2019
7f23be0
.
akkartik Jul 14, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
.
  • Loading branch information
akkartik committed Jul 13, 2019
commit f518bd972e7830cbc99481ce9a31631a282a3f8d
6 changes: 3 additions & 3 deletions subx/apps/assort.subx
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ read-segments: # in : (address buffered-file), table : (address stream {string,
# continue
# if slice-equal?(word-slice, "==")
# var segment-name = next-word(line)
# segment-slot = get-or-insert-slice(table, segment-name, row-size=8)
# segment-slot = leaky-get-or-insert-slice(table, segment-name, row-size=8)
# curr-segment = *segment-slot
# if curr-segment != 0
# continue
Expand Down Expand Up @@ -669,13 +669,13 @@ $read-segments:check-for-segment-header:
#? # . . discard args
#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP
#? # }}}
# segment-slot/EAX = get-or-insert-slice(table, segment-name, row-size=8)
# segment-slot/EAX = leaky-get-or-insert-slice(table, segment-name, row-size=8)
# . . push args
68/push 8/imm32/row-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-slice/disp32
e8/call leaky-get-or-insert-slice/disp32
# . . discard args
81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP
# curr-segment = *segment-slot
Expand Down
70 changes: 34 additions & 36 deletions subx/apps/subx-common.subx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
# inserts if not found
# get-slice(stream, slice, row-size)
# aborts if not found
# get-or-insert-slice(stream, slice, row-size)
# leaky-get-or-insert-slice(stream, slice, row-size)
# inserts if not found
# Beware: the '-slice' variants leak memory on every call.

# 'table' is a stream of (key, value) rows
# keys are always strings (addresses; size 4 bytes)
Expand Down Expand Up @@ -194,7 +193,6 @@ $test-get:end:
# values may be any type, but rows (key+value) always occupy 'row-size' bytes
# scan 'table' for a row with a key 'key' and return the address of the corresponding value
# if no row is found, abort
# WARNING: leaks memory
get-slice: # table : (address stream {string, _}), key : (address slice), row-size : int -> EAX : (address _)
# pseudocode:
# curr = table->data
Expand Down Expand Up @@ -641,7 +639,7 @@ $test-get-or-insert:end:
# if there are no rows free, abort
# WARNING: leaks memory
# TODO: pass in an allocation descriptor
get-or-insert-slice: # table : (address stream {string, _}), key : (address slice), row-size : int -> EAX : (address _)
leaky-get-or-insert-slice: # table : (address stream {string, _}), key : (address slice), row-size : int -> EAX : (address _)
# pseudocode:
# curr = table->data
# max = &table->data[table->write]
Expand Down Expand Up @@ -670,10 +668,10 @@ get-or-insert-slice: # table : (address stream {string, _}), key : (address sli
# max/EDX = table->data + table->write
8b/copy 0/mod/indirect 6/rm32/ESI . . . 2/r32/EDX . . # copy *ESI to EDX
8d/copy-address 0/mod/indirect 4/rm32/sib 1/base/ECX 2/index/EDX . 2/r32/EDX . . # copy ECX+EDX to EDX
$get-or-insert-slice:search-loop:
$leaky-get-or-insert-slice:search-loop:
# if (curr >= max) break
39/compare 3/mod/direct 1/rm32/ECX . . . 2/r32/EDX . . # compare ECX with EDX
73/jump-if-greater-or-equal-unsigned $get-or-insert-slice:not-found/disp8
73/jump-if-greater-or-equal-unsigned $leaky-get-or-insert-slice:not-found/disp8
# if (slice-equal?(key, *curr)) return curr+4
# . EAX = slice-equal?(key, *curr)
# . . push args
Expand All @@ -685,21 +683,21 @@ $get-or-insert-slice:search-loop:
81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP
# . if (EAX != 0) return EAX = curr+4
3d/compare-EAX-and 0/imm32
74/jump-if-equal $get-or-insert-slice:mismatch/disp8
74/jump-if-equal $leaky-get-or-insert-slice:mismatch/disp8
8d/copy-address 1/mod/*+disp8 1/rm32/ECX . . . 0/r32/EAX 4/disp8 . # copy ECX+4 to EAX
eb/jump $get-or-insert-slice:end/disp8
$get-or-insert-slice:mismatch:
eb/jump $leaky-get-or-insert-slice:end/disp8
$leaky-get-or-insert-slice:mismatch:
# curr += row-size
03/add 1/mod/*+disp8 5/rm32/EBP . . . 1/r32/ECX 0x10/disp8 . # add *(EBP+16) to ECX
# loop
eb/jump $get-or-insert-slice:search-loop/disp8
$get-or-insert-slice:not-found:
eb/jump $leaky-get-or-insert-slice:search-loop/disp8
$leaky-get-or-insert-slice:not-found:
# result/EAX = 0
31/xor 3/mod/direct 0/rm32/EAX . . . 0/r32/EAX . . # clear EAX
# if (table->write >= table->length) abort
8b/copy 0/mod/indirect 6/rm32/ESI . . . 1/r32/ECX . . # copy *ESI to ECX
3b/compare 1/mod/*+disp8 6/rm32/ESI . . . 1/r32/ECX 8/disp8 . # compare ECX with *(ESI+8)
7d/jump-if-greater-or-equal $get-or-insert-slice:abort/disp8
7d/jump-if-greater-or-equal $leaky-get-or-insert-slice:abort/disp8
# zero-out(max, row-size)
# . . push args
ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x10/disp8 . # push *(EBP+16)
Expand Down Expand Up @@ -729,7 +727,7 @@ $get-or-insert-slice:not-found:
89/copy 3/mod/direct 0/rm32/EAX . . . 2/r32/EDX . . # copy EDX to EAX
# . EAX += 4
05/add-to-EAX 4/imm32
$get-or-insert-slice:end:
$leaky-get-or-insert-slice:end:
# . restore registers
5e/pop-to-ESI
5a/pop-to-EDX
Expand All @@ -739,10 +737,10 @@ $get-or-insert-slice:end:
5d/pop-to-EBP
c3/return

$get-or-insert-slice:abort:
$leaky-get-or-insert-slice:abort:
# . _write(2/stderr, error)
# . . push args
68/push "get-or-insert-slice: too many segments"/imm32
68/push "leaky-get-or-insert-slice: too many segments"/imm32
68/push 2/imm32/stderr
# . . call
e8/call _write/disp32
Expand All @@ -754,7 +752,7 @@ $get-or-insert-slice:abort:
cd/syscall 0x80/imm8
# never gets here

test-get-or-insert-slice:
test-leaky-get-or-insert-slice:
# . prolog
55/push-EBP
89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP
Expand All @@ -773,32 +771,32 @@ test-get-or-insert-slice:
52/push-EDX
50/push-EAX
89/copy 3/mod/direct 2/rm32/EDX . . . 4/r32/ESP . . # copy ESP to EDX
$test-get-or-insert-slice:first-call:
$test-leaky-get-or-insert-slice:first-call:
# - start with an empty table, insert one key, verify that it was inserted
# EAX = get-or-insert-slice(table, "code" slice, 8 bytes per row)
# EAX = leaky-get-or-insert-slice(table, "code" slice, 8 bytes per row)
# . . push args
68/push 8/imm32/row-size
52/push-EDX
51/push-ECX
# . . call
e8/call get-or-insert-slice/disp32
e8/call leaky-get-or-insert-slice/disp32
# . . discard args
81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP
# check-ints-equal(EAX - table->data, 4, msg) # first row's value slot returned
# . check-ints-equal(EAX - table, 16, msg)
# . . push args
68/push "F - test-get-or-insert-slice/0"/imm32
68/push "F - test-leaky-get-or-insert-slice/0"/imm32
68/push 0x10/imm32
29/subtract 3/mod/direct 0/rm32/EAX . . . 1/r32/ECX . . # subtract ECX from EAX
50/push-EAX
# . . call
e8/call check-ints-equal/disp32
# . . discard args
81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP
$test-get-or-insert-slice:check2:
$test-leaky-get-or-insert-slice:check2:
# check-ints-equal(table->write, row-size = 8, msg)
# . . push args
68/push "F - test-get-or-insert-slice/1"/imm32
68/push "F - test-leaky-get-or-insert-slice/1"/imm32
68/push 8/imm32/row-size
ff 6/subop/push 0/mod/indirect 1/rm32/ECX . . . . . . # push *ECX
# . . call
Expand All @@ -807,28 +805,28 @@ $test-get-or-insert-slice:check2:
81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP
# check-string-equal(*table->data, "code", msg)
# . . push args
68/push "F - test-get-or-insert-slice/2"/imm32
68/push "F - test-leaky-get-or-insert-slice/2"/imm32
68/push "code"/imm32
ff 6/subop/push 1/mod/*+disp8 1/rm32/ECX . . . . 0xc/disp8 . # push *(ECX+12)
# . . call
e8/call check-string-equal/disp32
# . . discard args
81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP
$test-get-or-insert-slice:second-call:
$test-leaky-get-or-insert-slice:second-call:
# - insert the same key again, verify that it was reused
# EAX = get-or-insert-slice(table, "code" slice, 8 bytes per row)
# EAX = leaky-get-or-insert-slice(table, "code" slice, 8 bytes per row)
# . . push args
68/push 8/imm32/row-size
52/push-EDX
51/push-ECX
# . . call
e8/call get-or-insert-slice/disp32
e8/call leaky-get-or-insert-slice/disp32
# . . discard args
81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP
# check-ints-equal(EAX - table->data, 4, msg)
# . check-ints-equal(EAX - table, 16, msg)
# . . push args
68/push "F - test-get-or-insert-slice/3"/imm32
68/push "F - test-leaky-get-or-insert-slice/3"/imm32
68/push 0x10/imm32
29/subtract 3/mod/direct 0/rm32/EAX . . . 1/r32/ECX . . # subtract ECX from EAX
50/push-EAX
Expand All @@ -839,7 +837,7 @@ $test-get-or-insert-slice:second-call:
# no new row inserted
# . check-ints-equal(table->write, row-size = 8, msg)
# . . push args
68/push "F - test-get-or-insert-slice/4"/imm32
68/push "F - test-leaky-get-or-insert-slice/4"/imm32
68/push 8/imm32/row-size
ff 6/subop/push 0/mod/indirect 1/rm32/ECX . . . . . . # push *ECX
# . . call
Expand All @@ -848,14 +846,14 @@ $test-get-or-insert-slice:second-call:
81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP
# check-string-equal(*table->data, "code", msg)
# . . push args
68/push "F - test-get-or-insert-slice/5"/imm32
68/push "F - test-leaky-get-or-insert-slice/5"/imm32
68/push "code"/imm32
ff 6/subop/push 1/mod/*+disp8 1/rm32/ECX . . . . 0xc/disp8 . # push *(ECX+12)
# . . call
e8/call check-string-equal/disp32
# . . discard args
81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP
$test-get-or-insert-slice:third-call:
$test-leaky-get-or-insert-slice:third-call:
# - insert a new key, verify that it was inserted
# (EAX..EDX) = "data"
b8/copy-to-EAX "data"/imm32
Expand All @@ -866,20 +864,20 @@ $test-get-or-insert-slice:third-call:
52/push-EDX
50/push-EAX
89/copy 3/mod/direct 2/rm32/EDX . . . 4/r32/ESP . . # copy ESP to EDX
# EAX = get-or-insert-slice(table, "data" slice, 8 bytes per row)
# EAX = leaky-get-or-insert-slice(table, "data" slice, 8 bytes per row)
# . . push args
68/push 8/imm32/row-size
52/push-EDX
51/push-ECX
# . . call
e8/call get-or-insert-slice/disp32
e8/call leaky-get-or-insert-slice/disp32
# . . discard args
81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP
# table gets a new row
# check-ints-equal(EAX - table->data, 12, msg) # second row's value slot returned
# . check-ints-equal(EAX - table, 24, msg)
# . . push args
68/push "F - test-get-or-insert-slice/6"/imm32
68/push "F - test-leaky-get-or-insert-slice/6"/imm32
68/push 0x18/imm32
29/subtract 3/mod/direct 0/rm32/EAX . . . 1/r32/ECX . . # subtract ECX from EAX
50/push-EAX
Expand All @@ -889,7 +887,7 @@ $test-get-or-insert-slice:third-call:
81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP
# check-ints-equal(table->write, 2 rows = 16, msg)
# . . push args
68/push "F - test-get-or-insert-slice/7"/imm32
68/push "F - test-leaky-get-or-insert-slice/7"/imm32
68/push 0x10/imm32/two-rows
ff 6/subop/push 0/mod/indirect 1/rm32/ECX . . . . . . # push *ECX
# . . call
Expand All @@ -899,14 +897,14 @@ $test-get-or-insert-slice:third-call:
# check-string-equal(*table->data+8, "data", msg)
# check-string-equal(*(table+20), "data", msg)
# . . push args
68/push "F - test-get-or-insert-slice/8"/imm32
68/push "F - test-leaky-get-or-insert-slice/8"/imm32
68/push "data"/imm32
ff 6/subop/push 1/mod/*+disp8 1/rm32/ECX . . . . 0x14/disp8 . # push *(ECX+20)
# . . call
e8/call check-string-equal/disp32
# . . discard args
81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP
$test-get-or-insert-slice:end:
$test-leaky-get-or-insert-slice:end:
# . epilog
89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP
5d/pop-to-EBP
Expand Down
4 changes: 2 additions & 2 deletions subx/apps/survey.subx
Original file line number Diff line number Diff line change
Expand Up @@ -723,13 +723,13 @@ $compute-offsets:case-label:
74/jump-if-equal $compute-offsets:case-default/disp8
# strip trailing ':' from word-slice
ff 1/subop/decrement 1/mod/*+disp8 2/rm32/EDX . . . . 4/disp8 . # decrement *(EDX+4)
# x/EAX = get-or-insert-slice(labels, word-slice, row-size=16)
# x/EAX = leaky-get-or-insert-slice(labels, word-slice, row-size=16)
# . . push args
68/push 0x10/imm32/row-size
52/push-EDX
ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x10/disp8 . # push *(EBP+16)
# . . call
e8/call get-or-insert-slice/disp32
e8/call leaky-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:
Expand Down