diff --git a/html/subx/056write.subx.html b/html/subx/056write.subx.html index 7ada1e78..727bda6b 100644 --- a/html/subx/056write.subx.html +++ b/html/subx/056write.subx.html @@ -92,55 +92,55 @@ if ('onhashchange' in window) { 27 b8/copy-to-EAX 1/imm32 28 cd/syscall 0x80/imm8 29 - 30 write: # f : fd or (address stream), s : (address array byte) -> bytes_written/EAX - 31 # (If we ever leave the Linux kernel behind, it may be better to return - 32 # the number of bytes *not* written. Success would then be signaled by - 33 # returning 0.) - 34 # . prolog - 35 55/push-EBP - 36 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP - 37 # if (f < 0x08000000) _write(f, s), return # f can't be a user-mode address, so treat it as a kernel file descriptor - 38 81 7/subop/compare 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 0x08000000/imm32 # compare *(EBP+8) - 39 7d/jump-if-greater-or-equal $write:fake/disp8 - 40 # . . push args - 41 ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) - 42 ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 . # push *(EBP+8) - 43 # . . call - 44 e8/call _write/disp32 - 45 # . . discard args - 46 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 47 eb/jump $write:end/disp8 - 48 $write:fake: - 49 # otherwise, treat 'f' as a stream to append to - 50 # . save registers - 51 51/push-ECX - 52 52/push-EDX - 53 53/push-EBX - 54 # ECX = f - 55 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 1/r32/ECX 8/disp8 . # copy *(EBP+8) to ECX - 56 # EDX = f->write - 57 8b/copy 0/mod/indirect 1/rm32/ECX . . . 2/r32/EDX . . # copy *ECX to EDX - 58 # EBX = f->length - 59 8b/copy 1/mod/*+disp8 1/rm32/ECX . . . 3/r32/EBX 8/disp8 . # copy *(ECX+8) to EBX - 60 # EAX = _append-3(&f->data[f->write], &f->data[f->length], s) - 61 # . . push s - 62 ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) - 63 # . . push &f->data[f->length] - 64 8d/copy-address 1/mod/*+disp8 4/rm32/sib 1/base/ECX 3/index/EBX . 3/r32/EBX 0xc/disp8 . # copy ECX+EBX+12 to EBX - 65 53/push-EBX - 66 # . . push &f->data[f->write] - 67 8d/copy-address 1/mod/*+disp8 4/rm32/sib 1/base/ECX 2/index/EDX . 3/r32/EBX 0xc/disp8 . # copy ECX+EDX+12 to EBX - 68 53/push-EBX - 69 # . . call - 70 e8/call _append-3/disp32 - 71 # . . discard args - 72 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - 73 # f->write += EAX - 74 01/add 0/mod/indirect 1/rm32/ECX . . . 0/r32/EAX . . # add EAX to *ECX - 75 # . restore registers - 76 5b/pop-to-EBX - 77 5a/pop-to-EDX - 78 59/pop-to-ECX + 30 # TODO: come up with a way to signal when a write to disk fails + 31 write: # f : fd or (address stream), s : (address array byte) -> <void> + 32 # . prolog + 33 55/push-EBP + 34 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP + 35 # if (f < 0x08000000) _write(f, s), return # f can't be a user-mode address, so treat it as a kernel file descriptor + 36 81 7/subop/compare 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 0x08000000/imm32 # compare *(EBP+8) + 37 7d/jump-if-greater-or-equal $write:fake/disp8 + 38 # . . push args + 39 ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + 40 ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 . # push *(EBP+8) + 41 # . . call + 42 e8/call _write/disp32 + 43 # . . discard args + 44 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 45 eb/jump $write:end/disp8 + 46 $write:fake: + 47 # otherwise, treat 'f' as a stream to append to + 48 # . save registers + 49 50/push-EAX + 50 51/push-ECX + 51 52/push-EDX + 52 53/push-EBX + 53 # ECX = f + 54 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 1/r32/ECX 8/disp8 . # copy *(EBP+8) to ECX + 55 # EDX = f->write + 56 8b/copy 0/mod/indirect 1/rm32/ECX . . . 2/r32/EDX . . # copy *ECX to EDX + 57 # EBX = f->length + 58 8b/copy 1/mod/*+disp8 1/rm32/ECX . . . 3/r32/EBX 8/disp8 . # copy *(ECX+8) to EBX + 59 # EAX = _append-3(&f->data[f->write], &f->data[f->length], s) + 60 # . . push s + 61 ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + 62 # . . push &f->data[f->length] + 63 8d/copy-address 1/mod/*+disp8 4/rm32/sib 1/base/ECX 3/index/EBX . 3/r32/EBX 0xc/disp8 . # copy ECX+EBX+12 to EBX + 64 53/push-EBX + 65 # . . push &f->data[f->write] + 66 8d/copy-address 1/mod/*+disp8 4/rm32/sib 1/base/ECX 2/index/EDX . 3/r32/EBX 0xc/disp8 . # copy ECX+EDX+12 to EBX + 67 53/push-EBX + 68 # . . call + 69 e8/call _append-3/disp32 + 70 # . . discard args + 71 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP + 72 # f->write += EAX + 73 01/add 0/mod/indirect 1/rm32/ECX . . . 0/r32/EAX . . # add EAX to *ECX + 74 # . restore registers + 75 5b/pop-to-EBX + 76 5a/pop-to-EDX + 77 59/pop-to-ECX + 78 58/pop-to-EAX 79 $write:end: 80 # . epilog 81 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP diff --git a/subx/056write.subx b/subx/056write.subx index 3496d980..c76d0737 100644 --- a/subx/056write.subx +++ b/subx/056write.subx @@ -27,10 +27,8 @@ b8/copy-to-EAX 1/imm32 cd/syscall 0x80/imm8 -write: # f : fd or (address stream), s : (address array byte) -> bytes_written/EAX - # (If we ever leave the Linux kernel behind, it may be better to return - # the number of bytes *not* written. Success would then be signaled by - # returning 0.) +# TODO: come up with a way to signal when a write to disk fails +write: # f : fd or (address stream), s : (address array byte) -> # . prolog 55/push-EBP 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP @@ -48,6 +46,7 @@ write: # f : fd or (address stream), s : (address array byte) -> bytes_written/ $write:fake: # otherwise, treat 'f' as a stream to append to # . save registers + 50/push-EAX 51/push-ECX 52/push-EDX 53/push-EBX @@ -76,6 +75,7 @@ $write:fake: 5b/pop-to-EBX 5a/pop-to-EDX 59/pop-to-ECX + 58/pop-to-EAX $write:end: # . epilog 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP diff --git a/subx/apps/crenshaw2-1 b/subx/apps/crenshaw2-1 index 47762af7..10003ae7 100755 Binary files a/subx/apps/crenshaw2-1 and b/subx/apps/crenshaw2-1 differ diff --git a/subx/apps/crenshaw2-1b b/subx/apps/crenshaw2-1b index 620c1bad..20eaafe0 100755 Binary files a/subx/apps/crenshaw2-1b and b/subx/apps/crenshaw2-1b differ diff --git a/subx/apps/factorial b/subx/apps/factorial index d3a50805..7d867940 100755 Binary files a/subx/apps/factorial and b/subx/apps/factorial differ