From 0eb0f69616bb928359aed5ec137c973b14b03788 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sun, 2 Dec 2018 20:43:39 -0800 Subject: 4821 --- html/subx/apps/crenshaw2-1b.subx.html | 173 +++++++++++++--------------------- 1 file changed, 66 insertions(+), 107 deletions(-) (limited to 'html/subx/apps/crenshaw2-1b.subx.html') diff --git a/html/subx/apps/crenshaw2-1b.subx.html b/html/subx/apps/crenshaw2-1b.subx.html index 19773a56..9c3a5cef 100644 --- a/html/subx/apps/crenshaw2-1b.subx.html +++ b/html/subx/apps/crenshaw2-1b.subx.html @@ -791,116 +791,75 @@ if ('onhashchange' in window) { 725 5d/pop-to-EBP 726 c3/return 727 -728 # write(f, "Error: "+s+"\n") then stop(ed, 1) -729 error: # ed : (address exit-descriptor), f : fd or (address stream), s : (address array byte) -> <void> +728 # read a byte from 'f', and save it in 'Look' +729 get-char: # f : (address buffered-file) -> <void> 730 # . prolog 731 55/push-EBP 732 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP -733 # write(f, "Error: ") -734 # . . push args -735 68/push "Error: "/imm32 -736 ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) -737 # . . call -738 e8/call write/disp32 -739 # . . discard args -740 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -741 # write(f, s) -742 # . . push args -743 ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x10/disp8 . # push *(EBP+16) -744 ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) -745 # . . call -746 e8/call write/disp32 -747 # . . discard args -748 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -749 # write(f, Newline) -750 # . . push args -751 68/push Newline/imm32 -752 ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) -753 # . . call -754 e8/call write/disp32 -755 # . . discard args -756 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -757 # stop(ed, 1) -758 # . . push args -759 68/push 1/imm32 -760 ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 . # push *(EBP+8) -761 # . . call -762 e8/call stop/disp32 -763 # should never get past this point -764 # . epilog -765 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP -766 5d/pop-to-EBP -767 c3/return -768 -769 # read a byte from 'f', and save it in 'Look' -770 get-char: # f : (address buffered-file) -> <void> -771 # . prolog -772 55/push-EBP -773 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP -774 # . save registers -775 50/push-EAX -776 # read-byte(f) -777 # . . push args -778 ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x8/disp8 . # push *(EBP+8) -779 # . . call -780 e8/call read-byte/disp32 -781 # . . discard args -782 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -783 # save EAX to Look -784 89/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX Look/disp32 . # copy EAX to *Look -785 # . restore registers -786 58/pop-to-EAX -787 # . epilog -788 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP -789 5d/pop-to-EBP -790 c3/return -791 -792 is-digit?: # c : int -> bool/EAX -793 # . prolog -794 55/push-EBP -795 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP -796 # EAX = false -797 b8/copy-to-EAX 0/imm32 -798 # if c < '0' return false -799 81 7/subop/compare 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x8/disp8 0x30/imm32 # compare *(EBP+8) -800 7c/jump-if-lesser $is-digit?:end/disp8 -801 # if c > '9' return false -802 81 7/subop/compare 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x8/disp8 0x39/imm32 # compare *(EBP+8) -803 7f/jump-if-greater $is-digit?:end/disp8 -804 # otherwise return true -805 b8/copy-to-EAX 1/imm32 -806 $is-digit?:end: -807 # . epilog -808 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP -809 5d/pop-to-EBP -810 c3/return -811 -812 == data -813 -814 Look: # (char) -815 00 00 00 00 # = 0 -816 -817 _test-output-stream: -818 # current write index -819 00 00 00 00 -820 # current read index -821 00 00 00 00 -822 # length (= 8) -823 08 00 00 00 -824 # data -825 00 00 00 00 00 00 00 00 # 8 bytes -826 -827 _test-error-stream: -828 # current write index -829 00 00 00 00 -830 # current read index -831 00 00 00 00 -832 # length (= 8) -833 08 00 00 00 -834 # data -835 00 00 00 00 00 00 00 00 # 8 bytes -836 -837 # . . vim:nowrap:textwidth=0 +733 # . save registers +734 50/push-EAX +735 # read-byte(f) +736 # . . push args +737 ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x8/disp8 . # push *(EBP+8) +738 # . . call +739 e8/call read-byte/disp32 +740 # . . discard args +741 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +742 # save EAX to Look +743 89/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX Look/disp32 . # copy EAX to *Look +744 # . restore registers +745 58/pop-to-EAX +746 # . epilog +747 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP +748 5d/pop-to-EBP +749 c3/return +750 +751 is-digit?: # c : int -> bool/EAX +752 # . prolog +753 55/push-EBP +754 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP +755 # EAX = false +756 b8/copy-to-EAX 0/imm32 +757 # if c < '0' return false +758 81 7/subop/compare 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x8/disp8 0x30/imm32 # compare *(EBP+8) +759 7c/jump-if-lesser $is-digit?:end/disp8 +760 # if c > '9' return false +761 81 7/subop/compare 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x8/disp8 0x39/imm32 # compare *(EBP+8) +762 7f/jump-if-greater $is-digit?:end/disp8 +763 # otherwise return true +764 b8/copy-to-EAX 1/imm32 +765 $is-digit?:end: +766 # . epilog +767 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP +768 5d/pop-to-EBP +769 c3/return +770 +771 == data +772 +773 Look: # (char) +774 00 00 00 00 # = 0 +775 +776 _test-output-stream: +777 # current write index +778 00 00 00 00 +779 # current read index +780 00 00 00 00 +781 # length (= 8) +782 08 00 00 00 +783 # data +784 00 00 00 00 00 00 00 00 # 8 bytes +785 +786 _test-error-stream: +787 # current write index +788 00 00 00 00 +789 # current read index +790 00 00 00 00 +791 # length (= 8) +792 08 00 00 00 +793 # data +794 00 00 00 00 00 00 00 00 # 8 bytes +795 +796 # . . vim:nowrap:textwidth=0 -- cgit 1.4.1-2-gfad0