diff options
author | Kartik Agaram <vc@akkartik.com> | 2018-12-04 00:29:06 -0800 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2018-12-04 00:29:06 -0800 |
commit | cf02c20bb02f5d2fbfee5557baf68c0e2ca5a042 (patch) | |
tree | 8f1d896a0134e8353ccf01add61fb6c732103861 /subx | |
parent | 7cb326df5bb9739d948dd4f8b32019f1bf6e4ef3 (diff) | |
download | mu-cf02c20bb02f5d2fbfee5557baf68c0e2ca5a042.tar.gz |
4832
Let's start adding ':end' labels in all functions, just because it helps us visualize where function calls end in traces, thanks to the '--map' commandline argument.
Diffstat (limited to 'subx')
-rw-r--r-- | subx/050_write.subx | 1 | ||||
-rw-r--r-- | subx/052kernel_string_equal.subx | 1 | ||||
-rw-r--r-- | subx/053new_segment.subx | 1 | ||||
-rw-r--r-- | subx/055trace.subx | 1 | ||||
-rw-r--r-- | subx/057stop.subx | 4 | ||||
-rw-r--r-- | subx/058read.subx | 1 | ||||
-rw-r--r-- | subx/061error.subx | 1 | ||||
-rw-r--r-- | subx/062write-byte.subx | 2 | ||||
-rw-r--r-- | subx/063print-byte.subx | 1 | ||||
-rw-r--r-- | subx/apps/crenshaw2-1.subx | 4 | ||||
-rw-r--r-- | subx/apps/crenshaw2-1b.subx | 2 |
11 files changed, 18 insertions, 1 deletions
diff --git a/subx/050_write.subx b/subx/050_write.subx index a82931db..5b8b4d4f 100644 --- a/subx/050_write.subx +++ b/subx/050_write.subx @@ -32,6 +32,7 @@ _write: # fd : int, s : (address array byte) -> <void> # . syscall b8/copy-to-EAX 4/imm32/write cd/syscall 0x80/imm8 +$_write:end: # . restore registers 5b/pop-to-EBX 5a/pop-to-EDX diff --git a/subx/052kernel_string_equal.subx b/subx/052kernel_string_equal.subx index 2834b047..7eb7c7af 100644 --- a/subx/052kernel_string_equal.subx +++ b/subx/052kernel_string_equal.subx @@ -96,7 +96,6 @@ $kernel-string-equal:true: # return false $kernel-string-equal:false: b8/copy-to-EAX 0/imm32 - $kernel-string-equal:end: # . restore registers 5f/pop-to-EDI diff --git a/subx/053new_segment.subx b/subx/053new_segment.subx index 27fd8ea1..8d6cdc5f 100644 --- a/subx/053new_segment.subx +++ b/subx/053new_segment.subx @@ -36,6 +36,7 @@ new-segment: # len : int -> address bb/copy-to-EBX _mmap-new-segment/imm32 b8/copy-to-EAX 0x5a/imm32/mmap cd/syscall 0x80/imm8 +$new-segment:end: # . epilog 5b/pop-to-EBX 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP diff --git a/subx/055trace.subx b/subx/055trace.subx index 37c91249..f502f18a 100644 --- a/subx/055trace.subx +++ b/subx/055trace.subx @@ -299,6 +299,7 @@ _append-3: # out : address, outend : address, s : (array byte) -> num_bytes_app e8/call _append-4/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x10/imm32 # add to ESP +$_append-3:end: # . restore registers 59/pop-to-ECX # . epilog diff --git a/subx/057stop.subx b/subx/057stop.subx index fd2afde2..5788cb72 100644 --- a/subx/057stop.subx +++ b/subx/057stop.subx @@ -87,6 +87,7 @@ tailor-exit-descriptor: # ed : (address exit-descriptor), nbytes : int -> <void 89/copy 0/mod/indirect 1/rm32/ECX . . . 0/r32/EAX . . # copy EAX to *ECX # initialize ed->value c7/copy 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 0/imm32 # copy to *(ECX+4) +$tailor-exit-descriptor:end: # . restore registers 59/pop-to-ECX 58/pop-to-EAX @@ -113,6 +114,7 @@ $stop:fake: 89/copy 1/mod/*+disp8 0/rm32/EAX . . . 1/r32/ECX 4/disp8 . # copy ECX to *(EAX+4) # non-local jump to ed->target 8b/copy 0/mod/indirect 0/rm32/EAX . . . 4/r32/ESP . . # copy *EAX to ESP +$stop:end: c3/return # doesn't return to caller test-stop-skips-returns-on-exit: @@ -174,6 +176,7 @@ _test-stop-1: # ed : (address exit-descriptor) # . . call e8/call _test-stop-2/disp32 # should never get past this point +$_test-stop-1:dead-end: # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP # signal test failed: check-ints-equal(1, 0, msg) @@ -201,6 +204,7 @@ _test-stop-2: # ed : (address exit-descriptor) # . . call e8/call stop/disp32 # should never get past this point +$_test-stop-2:dead-end: # . epilog 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP 5d/pop-to-EBP diff --git a/subx/058read.subx b/subx/058read.subx index 90425a74..5bf83aa6 100644 --- a/subx/058read.subx +++ b/subx/058read.subx @@ -145,6 +145,7 @@ _read: # fd : int, s : (address stream) -> num-bytes-read/EAX cd/syscall 0x80/imm8 # add the result EAX to s->write 01/add 0/mod/indirect 6/rm32/ESI . . . 0/r32/EAX . . # add EAX to *ESI +$_read:end: # . restore registers 5e/pop-to-ESI 5b/pop-to-EBX diff --git a/subx/061error.subx b/subx/061error.subx index b44d5473..a65c8a73 100644 --- a/subx/061error.subx +++ b/subx/061error.subx @@ -48,6 +48,7 @@ error: # ed : (address exit-descriptor), out : fd or (address stream), msg : (a # . . call e8/call stop/disp32 # should never get past this point +$error:dead-end: # . epilog 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP 5d/pop-to-EBP diff --git a/subx/062write-byte.subx b/subx/062write-byte.subx index fedde5d9..178b5004 100644 --- a/subx/062write-byte.subx +++ b/subx/062write-byte.subx @@ -73,6 +73,7 @@ $write-byte:to-stream: 88/copy-byte 1/mod/*+disp8 4/rm32/sib 6/base/ESI 1/index/ECX . 0/r32/AL 0x10/disp8 . # copy AL to *(ESI+ECX+16) # ++f->read ff 0/subop/increment 1/mod/*+disp8 6/rm32/ESI . . . . 4/disp8 . # increment *(ESI+4) +$write-byte:end: # . restore registers 5e/pop-to-ESI 59/pop-to-ECX @@ -99,6 +100,7 @@ flush: # f : (address buffered-file) -> <void> e8/call write-stream/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +$flush:end: # . restore registers 59/pop-to-ECX 58/pop-to-EAX diff --git a/subx/063print-byte.subx b/subx/063print-byte.subx index ed71a378..686695c4 100644 --- a/subx/063print-byte.subx +++ b/subx/063print-byte.subx @@ -54,6 +54,7 @@ print-byte: # f : (address buffered-file), n : num -> <void> e8/call write-byte/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +$print-byte:end: # . restore registers 59/pop-to-ECX 58/pop-to-EAX diff --git a/subx/apps/crenshaw2-1.subx b/subx/apps/crenshaw2-1.subx index 73e08d50..a9838b65 100644 --- a/subx/apps/crenshaw2-1.subx +++ b/subx/apps/crenshaw2-1.subx @@ -185,6 +185,7 @@ compile: # in : (address buffered-file), out : fd or (address stream), err : fd e8/call write/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +$compile:end: # . restore registers 59/pop-to-ECX 58/pop-to-EAX @@ -287,6 +288,7 @@ $get-num:stage2: $get-num:loop-end: # persist necessary variables from registers 89/copy 0/mod/indirect 7/rm32/EDI . . . 1/r32/ECX . . # copy ECX to *EDI +$get-num:end: # . restore registers 5f/pop-to-EDI 5e/pop-to-ESI @@ -521,6 +523,7 @@ expected: # ed : (address exit-descriptor), f : fd or (address stream), s : (ad # . . call e8/call stop/disp32 # should never get past this point +$expected:dead-end: # . epilog 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP 5d/pop-to-EBP @@ -542,6 +545,7 @@ get-char: # f : (address buffered-file) -> <void> 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP # save EAX to Look 89/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX Look/disp32 . # copy EAX to *Look +$get-char:end: # . restore registers 58/pop-to-EAX # . epilog diff --git a/subx/apps/crenshaw2-1b.subx b/subx/apps/crenshaw2-1b.subx index 77b262a7..14f93c5f 100644 --- a/subx/apps/crenshaw2-1b.subx +++ b/subx/apps/crenshaw2-1b.subx @@ -185,6 +185,7 @@ compile: # in : (address buffered-file), out : fd or (address stream), err : fd e8/call write/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +$compile:end: # . restore registers 59/pop-to-ECX 58/pop-to-EAX @@ -304,6 +305,7 @@ $get-num:loop-stage2: $get-num:loop-end: # persist necessary variables from registers 89/copy 0/mod/indirect 7/rm32/EDI . . . 1/r32/ECX . . # copy ECX to *EDI +$get-num:end: # . restore registers 5f/pop-to-EDI 5e/pop-to-ESI |