6507 - use syscall names everywhere

This commit is contained in:
Kartik Agaram 2020-06-10 23:09:30 -07:00
parent 72d893b6b1
commit 7dac9ade15
54 changed files with 108 additions and 213 deletions

View File

@ -6,10 +6,8 @@
# . 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes
Entry: # just exit; can't test _write just yet
# . syscall(exit, 0)
bb/copy-to-ebx 0/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
_write: # fd: int, s: (addr array byte)
# . prologue
@ -30,8 +28,7 @@ _write: # fd: int, s: (addr array byte)
8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 2/r32/edx 0xc/disp8 . # copy *(ebp+12) to edx
8b/copy 0/mod/indirect 2/rm32/edx . . . 2/r32/edx . . # copy *edx to edx
# . syscall
b8/copy-to-eax 4/imm32/write
cd/syscall 0x80/imm8
e8/call syscall_write/disp32
# if (eax < 0) abort
3d/compare-eax-with 0/imm32
0f 8c/jump-if-< $_write:abort/disp32
@ -50,8 +47,7 @@ $_write:abort:
# can't write a message here for risk of an infinite loop, so we'll use a special exit code instead
# . syscall(exit, 255)
bb/copy-to-ebx 0xff/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
# . . vim:nowrap:textwidth=0

View File

@ -17,8 +17,7 @@ Entry: # manual test
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32 # add to esp
# syscall(exit, 0)
bb/copy-to-ebx 0/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# print msg to stderr if a != b, otherwise print "."
check-ints-equal: # a: int, b: int, msg: (addr array byte)

View File

@ -26,8 +26,7 @@ Entry: # run all tests
e8/call run-tests/disp32 # 'run-tests' is a function created automatically by SubX. It calls all functions that start with 'test-'.
# syscall(exit, Num-test-failures)
8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/ebx Num-test-failures/disp32 # copy *Num-test-failures to ebx
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
kernel-string-equal?: # s: (addr kernel-string), benchmark: (addr array byte) -> eax: boolean
# pseudocode:

View File

@ -35,8 +35,7 @@ Entry: # manual test
c7 0/subop/copy 0/mod/direct 0/rm32/eax . . . . . 0x34/imm32 # copy to *eax
# syscall(exit, eax)
89/copy 3/mod/direct 3/rm32/ebx . . . 0/r32/eax . . # copy eax to ebx
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
new-segment: # len: int, ad: (addr allocation-descriptor)
# . prologue
@ -50,8 +49,7 @@ new-segment: # len: int, ad: (addr allocation-descriptor)
89/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/eax $_mmap-new-segment:len/disp32 # copy eax to *$_mmap-new-segment:len
# mmap(_mmap-new-segment)
bb/copy-to-ebx _mmap-new-segment/imm32
b8/copy-to-eax 0x5a/imm32/mmap
cd/syscall 0x80/imm8
e8/call syscall_mmap/disp32
# copy {eax, eax+len} to *ad
# . ebx = ad
8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 3/r32/ebx 0xc/disp8 . # copy *(ebp+12) to ebx

View File

@ -10,8 +10,7 @@ Entry: # run all tests
e8/call run-tests/disp32 # 'run-tests' is a function created automatically by SubX. It calls all functions that start with 'test-'.
# syscall(exit, Num-test-failures)
8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/ebx Num-test-failures/disp32 # copy *Num-test-failures to ebx
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
string-equal?: # s: (addr array byte), benchmark: (addr array byte) -> eax: boolean
# pseudocode:

View File

@ -954,8 +954,7 @@ $_append-4:abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
== data

View File

@ -98,8 +98,7 @@ stop: # ed: (addr exit-descriptor), value: int
75/jump-if-!= $stop:fake/disp8
# . syscall(exit, value)
8b/copy 1/mod/*+disp8 4/rm32/sib 4/base/esp 4/index/none . 3/r32/ebx 8/disp8 . # copy *(esp+8) to ebx
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
$stop:fake:
# otherwise:
# ed->value = value+1

View File

@ -218,8 +218,7 @@ _read: # fd: int, s: (addr stream byte) -> num-bytes-read/eax: int
# . . size: edx = s->size - s->write
29/subtract 3/mod/direct 2/rm32/edx . . . 0/r32/eax . . # subtract eax from edx
# . . syscall
b8/copy-to-eax 3/imm32/read
cd/syscall 0x80/imm8
e8/call syscall_read/disp32
# add the result eax to s->write
01/add 0/mod/indirect 6/rm32/esi . . . 0/r32/eax . . # add eax to *esi
$_read:end:

View File

@ -12,8 +12,7 @@
#? e8/call write-stream/disp32
#? # syscall(exit, Num-test-failures)
#? 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/ebx Num-test-failures/disp32 # copy *Num-test-failures to ebx
#? b8/copy-to-eax 1/imm32/exit
#? cd/syscall 0x80/imm8
#? e8/call syscall_exit/disp32
write-stream: # f: fd or (addr stream byte), s: (addr stream byte)
# . prologue
@ -100,8 +99,7 @@ _write-stream: # fd: int, s: (addr stream byte)
# . . size: edx = s->write - s->read
29/subtract 3/mod/direct 2/rm32/edx . . . 7/r32/edi . . # subtract edi from edx
# . . syscall
b8/copy-to-eax 4/imm32/write
cd/syscall 0x80/imm8
e8/call syscall_write/disp32
# if (eax < 0) abort
3d/compare-eax-with 0/imm32
0f 8c/jump-if-< $_write-stream:abort/disp32
@ -130,8 +128,7 @@ $_write-stream:abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
test-write-stream-single:

View File

@ -247,8 +247,7 @@ $append-byte:abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
test-append-byte-single:

View File

@ -932,8 +932,7 @@ $from-hex-char:abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
# . . vim:nowrap:textwidth=0

View File

@ -20,8 +20,7 @@
#? e8/call error-byte/disp32
#? # . syscall(exit, Num-test-failures)
#? 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/ebx Num-test-failures/disp32 # copy *Num-test-failures to ebx
#? b8/copy-to-eax 1/imm32/exit
#? cd/syscall 0x80/imm8
#? e8/call syscall_exit/disp32
# write(out, "Error: "+msg+": "+byte) then stop(ed, 1)
error-byte: # ed: (addr exit-descriptor), out: (addr buffered-file), msg: (addr array byte), n: byte

View File

@ -59,8 +59,7 @@ Entry:
$array-equal-main:end:
# syscall(exit, Num-test-failures)
8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/ebx Num-test-failures/disp32 # copy *Num-test-failures to ebx
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# Allocate and clear 'n' bytes of memory from an allocation-descriptor 'ad'.
# Abort if there isn't enough memory in 'ad'.
@ -164,8 +163,7 @@ $allocate-raw:abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
test-allocate-raw-success:
@ -294,8 +292,7 @@ $lookup:abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32/exit-status
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
test-lookup-success:
# . prologue
@ -571,8 +568,7 @@ $allocate-region:abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
# Claim the next 'n+4' bytes of memory and initialize the first 4 to n.

View File

@ -68,8 +68,7 @@ $new-stream:abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
test-new-stream:

View File

@ -104,8 +104,7 @@ $read-line-buffered:abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
test-read-line-buffered:
@ -289,8 +288,7 @@ $read-line:abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
test-read-line:

View File

@ -858,8 +858,7 @@ $write-slice:abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
test-write-slice:
@ -1123,8 +1122,7 @@ $slice-to-string:abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
test-slice-to-string:

View File

@ -124,8 +124,7 @@ $print-int32-decimal:abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
test-print-int32-decimal:

View File

@ -124,8 +124,7 @@ $get:abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
test-get:
@ -316,8 +315,7 @@ $get-slice:abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
test-get-slice:
@ -534,8 +532,7 @@ $get-or-insert:abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
test-get-or-insert:
@ -821,8 +818,7 @@ $get-or-insert-handle:abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
test-get-or-insert-handle:
@ -1139,8 +1135,7 @@ $get-or-insert-slice:abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
test-get-or-insert-slice:
@ -1440,8 +1435,8 @@ $get-or-stop:terminus:
# . . discard args
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# syscall(exit, 1)
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
bb/copy-to-ebx 1/imm32
e8/call syscall_exit/disp32
test-get-or-stop:
# This test uses exit-descriptors. Use ebp for setting up local variables.
@ -1666,8 +1661,8 @@ $get-slice-or-stop:terminus:
# . . discard args
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# syscall(exit, 1)
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
bb/copy-to-ebx 1/imm32
e8/call syscall_exit/disp32
test-get-slice-or-stop:
# This test uses exit-descriptors. Use ebp for setting up local variables.

View File

@ -100,8 +100,7 @@ $slurp:abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
test-slurp:

View File

@ -47,8 +47,7 @@ $write-int:abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
test-write-int-single:

View File

@ -160,8 +160,7 @@ $push:abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
test-push:
@ -279,8 +278,7 @@ $pop:abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
test-pop:
@ -381,8 +379,7 @@ $top:abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
test-top:

Binary file not shown.

View File

@ -79,8 +79,7 @@ $subx-assort-main:interactive:
# syscall(exit, 0)
bb/copy-to-ebx 0/imm32
$subx-assort-main:end:
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# data structure:
# table: (addr stream {(handle array byte), (handle stream byte)}) (16 bytes/row)

Binary file not shown.

View File

@ -72,8 +72,7 @@ $subx-braces-main:interactive:
# syscall(exit, 0)
bb/copy-to-ebx 0/imm32
$subx-braces-main:end:
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
subx-braces: # in: (addr buffered-file), out: (addr buffered-file)
# pseudocode:

Binary file not shown.

View File

@ -72,8 +72,7 @@ $subx-calls-main:interactive:
# syscall(exit, 0)
bb/copy-to-ebx 0/imm32
$subx-calls-main:end:
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
subx-calls: # in: (addr buffered-file), out: (addr buffered-file)
# pseudocode:
@ -536,8 +535,7 @@ $emit-call:error1:
81 0/subop/add %esp 4/imm32
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
test-subx-calls-passes-most-lines-through:
@ -1020,8 +1018,7 @@ $next-word-string-or-expression-without-metadata:error0:
81 0/subop/add %esp 4/imm32
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
$next-word-string-or-expression-without-metadata:error1:
@ -1059,8 +1056,7 @@ $next-word-string-or-expression-without-metadata:error1:
81 0/subop/add %esp 4/imm32
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
$next-word-string-or-expression-without-metadata:error2:
@ -1098,8 +1094,7 @@ $next-word-string-or-expression-without-metadata:error2:
81 0/subop/add %esp 4/imm32
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
$next-word-string-or-expression-without-metadata:error3:
@ -1137,8 +1132,7 @@ $next-word-string-or-expression-without-metadata:error3:
81 0/subop/add %esp 4/imm32
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
$next-word-string-or-expression-without-metadata:error4:
@ -1176,8 +1170,7 @@ $next-word-string-or-expression-without-metadata:error4:
81 0/subop/add %esp 4/imm32
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
$next-word-string-or-expression-without-metadata:error5:
@ -1215,8 +1208,7 @@ $next-word-string-or-expression-without-metadata:error5:
81 0/subop/add %esp 4/imm32
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
test-next-word-string-or-expression-without-metadata:

Binary file not shown.

View File

@ -86,8 +86,7 @@ $run-main:
# syscall(exit, 0)
bb/copy-to-ebx 0/imm32
$main:end:
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# the main entry point
compile: # in: (addr buffered-file), out: fd or (addr stream byte), err: fd or (addr stream byte), ed: (addr exit-descriptor)

Binary file not shown.

View File

@ -86,8 +86,7 @@ $run-main:
# syscall(exit, 0)
bb/copy-to-ebx 0/imm32
$main:end:
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# the main entry point
compile: # in: (addr buffered-file), out: fd or (addr stream byte), err: fd or (addr stream byte), ed: (addr exit-descriptor)

Binary file not shown.

View File

@ -75,8 +75,7 @@ $subx-dquotes-main:interactive:
# syscall(exit, 0)
bb/copy-to-ebx 0/imm32
$subx-dquotes-main:end:
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# conceptual hierarchy within a line:
# line = words separated by ' ', maybe followed by comment starting with '#'

BIN
apps/ex5

Binary file not shown.

View File

@ -32,8 +32,7 @@ Entry:
# . size = 1 character
ba/copy-to-edx 1/imm32
# . syscall
b8/copy-to-eax 4/imm32/write
cd/syscall 0x80/imm8
e8/call syscall_write/disp32
# exit(ebx)
e8/call syscall_exit/disp32

Binary file not shown.

View File

@ -95,8 +95,7 @@ $run-main:
# syscall(exit, eax)
89/copy 3/mod/direct 3/rm32/ebx . . . 0/r32/eax . . # copy eax to ebx
$main:end:
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
factorial: # n: int -> int/eax
# . prologue

View File

@ -65,8 +65,7 @@ $run-main:
# syscall(exit, eax)
89/<- %ebx 0/r32/eax
$main:end:
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
factorial: # n: int -> int/eax
# . prologue

View File

@ -46,8 +46,7 @@ $run-main:
# syscall(exit, eax)
89/<- %ebx 0/r32/eax
$main:end:
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
factorial: # n: int -> int/eax
# . prologue

View File

@ -52,8 +52,7 @@ Entry: # run tests if necessary, compute `factorial(5)` if not
89/<- %ebx 0/r32/eax
}
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
factorial: # n: int -> int/eax
# . prologue

BIN
apps/hex

Binary file not shown.

View File

@ -73,8 +73,7 @@ $subx-hex-main:interactive:
# syscall(exit, 0)
bb/copy-to-ebx 0/imm32
$subx-hex-main:end:
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# the main entry point
subx-hex: # in: (addr buffered-file), out: (addr buffered-file), err: (addr buffered-file), ed: (addr exit-descriptor)

BIN
apps/mu

Binary file not shown.

View File

@ -473,8 +473,7 @@ Entry:
# syscall(exit, 0)
bb/copy-to-ebx 0/imm32
$mu-main:end:
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
convert-mu: # in: (addr buffered-file), out: (addr buffered-file)
# . prologue
@ -3986,8 +3985,7 @@ $parse-mu:error1:
(flush Stderr)
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
$parse-mu:error2:
@ -3999,8 +3997,7 @@ $parse-mu:error2:
(flush Stderr)
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
# scenarios considered:
@ -4169,8 +4166,7 @@ $populate-mu-function-header:error1:
(flush Stderr)
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
$populate-mu-function-header:error2:
@ -4181,8 +4177,7 @@ $populate-mu-function-header:error2:
(flush Stderr)
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
$populate-mu-function-header:error3:
@ -4199,8 +4194,7 @@ $populate-mu-function-header:error3:
(flush Stderr)
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
test-function-header-with-arg:
@ -4518,8 +4512,7 @@ $parse-var-with-type:abort:
(flush Stderr)
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
parse-type: # ad: (addr allocation-descriptor), in: (addr stream byte), out: (addr handle tree type-id)
@ -4637,8 +4630,7 @@ $parse-type:abort:
(flush Stderr)
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
parse-type-tree: # ad: (addr allocation-descriptor), in: (addr stream byte), out: (addr handle tree type-id)
@ -5698,8 +5690,7 @@ $parse-mu-block:abort:
(flush Stderr)
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
new-block-name: # fn: (addr function), out: (addr handle var)
@ -5807,8 +5798,7 @@ check-no-tokens-left: # line: (addr stream byte)
(flush Stderr)
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
$check-no-tokens-left:end:
# . reclaim locals
@ -5949,8 +5939,7 @@ $parse-mu-var-def:abort:
(flush Stderr)
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
test-parse-mu-var-def:
@ -6151,8 +6140,7 @@ $parse-mu-stmt:abort:
(flush Stderr)
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
add-operation-and-inputs-to-stmt: # stmt: (addr stmt), line: (addr stream byte), vars: (addr stack live-var)
@ -6269,8 +6257,7 @@ $add-operation-and-inputs-to-stmt:abort:
(flush Stderr)
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
stmt-has-outputs?: # line: (addr stream byte) -> result/eax: boolean
@ -6373,8 +6360,7 @@ $lookup-var-or-literal:abort:
(flush Stderr)
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
# return first 'name' from the top (back) of 'vars' and abort if not found
@ -6405,8 +6391,7 @@ $lookup-var:abort:
(flush Stderr)
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
# return first 'name' from the top (back) of 'vars', and 0/null if not found
@ -6489,8 +6474,7 @@ $lookup-var-helper:error1:
(flush Stderr)
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
# return first 'name' from the top (back) of 'vars' and create a new var for a fn output if not found
@ -6769,8 +6753,7 @@ $new-literal-integer:abort:
(flush Stderr)
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
new-literal: # ad: (addr allocation-descriptor), name: (addr slice), out: (addr handle var)
@ -7482,8 +7465,7 @@ $populate-mu-type:abort:
(flush Stderr)
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
type-name: # index: int -> result/eax: (addr array byte)
@ -7633,8 +7615,7 @@ $populate-mu-type-sizes-in-type:abort:
(flush Stderr)
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
# Analogous to size-of, except we need to compute what size-of can just read
@ -7831,8 +7812,7 @@ $locate-typeinfo-entry-with-index:abort:
(flush Stderr)
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
dump-typeinfos: # hdr: (addr array byte)
@ -8669,8 +8649,7 @@ $push-output-and-maybe-emit-spill:abort:
(flush Stderr)
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
emit-subx-cleanup-and-unconditional-nonlocal-branch: # out: (addr buffered-file), stmt: (addr stmt1), vars: (addr stack live-var)
@ -9762,8 +9741,7 @@ $translate-mu-index-stmt-with-array:error1:
(flush Stderr)
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
$translate-mu-index-stmt-with-array:error2:
@ -9771,8 +9749,7 @@ $translate-mu-index-stmt-with-array:error2:
(flush Stderr)
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
translate-mu-index-stmt-with-array-in-register: # out: (addr buffered-file), stmt: (addr stmt)
@ -10176,8 +10153,7 @@ $power-of-2?:abort:
(flush Stderr)
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
num-shift-rights: # n: int -> result/eax: int
@ -13217,8 +13193,7 @@ $get-stmt-operand-from-arg-location:abort:
(flush Stderr)
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
emit-subx-r32: # out: (addr buffered-file), l: arg-location, stmt: (addr stmt)

View File

@ -33,8 +33,7 @@ Entry: # run tests if necessary, a REPL if not
# syscall(exit, 0)
bb/copy-to-ebx 0/imm32
$main:end:
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# Data structures
#

BIN
apps/pack

Binary file not shown.

View File

@ -66,8 +66,7 @@ $subx-pack-main:interactive:
# syscall(exit, 0)
bb/copy-to-ebx 0/imm32
$subx-pack-main:end:
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# - big picture
# We'll operate on each line/instruction in isolation. That way we only need to

View File

@ -14,8 +14,7 @@ Entry:
bb/copy-to-ebx Filename/imm32
b9/copy-to-ecx 0/imm32/rdonly
ba/copy-to-edx 0x180/imm32/fixed-perms
b8/copy-to-eax 5/imm32/open
cd/syscall 0x80/imm8
e8/call syscall_open/disp32
# . stream = eax
89/copy 3/mod/direct 6/rm32/esi . . . 0/r32/eax . . # copy eax to esi
@ -25,8 +24,7 @@ $loop:
89/copy 3/mod/direct 3/rm32/ebx . . . 6/r32/esi . . # copy esi to ebx
b9/copy-to-ecx N/imm32
ba/copy-to-edx 4/imm32/size
b8/copy-to-eax 3/imm32/read
cd/syscall 0x80/imm8
e8/call syscall_read/disp32
# print-int32-buffered(Stdout, *N)
# . . push args
@ -48,8 +46,7 @@ $loop:
# syscall(exit, 0)
bb/copy-to-ebx 0/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
== data 0x0a000000

Binary file not shown.

View File

@ -99,8 +99,7 @@ $subx-sigils-main:interactive:
# syscall(exit, 0)
bb/copy-to-ebx 0/imm32
$subx-sigils-main:end:
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# error messages considered:
# *x + 34 -> error: base+disp addressing must be within '()'
@ -426,8 +425,7 @@ $subx-sigils:error1:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
test-subx-sigils-passes-most-words-through:
@ -1803,8 +1801,7 @@ $next-word-or-expression:error1:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
$next-word-or-expression:error2:
@ -1842,8 +1839,7 @@ $next-word-or-expression:error2:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
test-next-word-or-expression:
@ -2571,8 +2567,7 @@ $parse-effective-address:error1:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
$parse-effective-address:error2:
@ -2610,8 +2605,7 @@ $parse-effective-address:error2:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
$parse-effective-address:error3:
@ -2649,8 +2643,7 @@ $parse-effective-address:error3:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
$parse-effective-address:error4:
@ -2688,8 +2681,7 @@ $parse-effective-address:error4:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
# assumes 'in' starts with a register name, and returns pointer to its code
@ -4161,8 +4153,7 @@ $next-hex-int:abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
test-next-hex-int-single-digit:

Binary file not shown.

View File

@ -103,8 +103,7 @@ $subx-survey-main:interactive:
# syscall(exit, 0)
bb/copy-to-ebx 0/imm32
$subx-survey-main:end:
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# data structures:
# segment-info: {address, file-offset, size} (12 bytes)
@ -922,8 +921,7 @@ $compute-offsets:abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
test-compute-offsets:
@ -2361,8 +2359,7 @@ $emit-segments:global-variable-abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
$emit-segments:imm8-abort:
@ -2376,8 +2373,7 @@ $emit-segments:imm8-abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
$emit-segments:abort:
@ -2407,8 +2403,7 @@ $emit-segments:abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
test-emit-segments-global-variable:
@ -3414,8 +3409,7 @@ $stream-add4:abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
stream-add5: # in: (addr stream byte), key: handle, val1: addr, val2: addr, val3: addr
@ -3501,8 +3495,7 @@ $stream-add5:abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
stream-add6: # in: (addr stream byte), key: handle, val1: addr, val2: addr, val3: addr, val4: addr
@ -3597,8 +3590,7 @@ $stream-add6:abort:
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# . syscall(exit, 1)
bb/copy-to-ebx 1/imm32
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
# never gets here
# some variants of 'trace' that take multiple arguments in different combinations of types:

Binary file not shown.

View File

@ -64,8 +64,7 @@ $subx-tests-main:interactive:
# syscall(exit, 0)
bb/copy-to-ebx 0/imm32
$subx-tests-main:end:
b8/copy-to-eax 1/imm32/exit
cd/syscall 0x80/imm8
e8/call syscall_exit/disp32
subx-gen-run-tests: # in: (addr buffered-file), out: (addr buffered-file)
# pseudocode