From 37d53a70958bfe5b1d7946229af9c12f0b865abc Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sun, 23 Sep 2018 22:38:16 -0700 Subject: 4512 --- html/subx/examples/ex8.subx.html | 70 ++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 38 deletions(-) (limited to 'html/subx/examples/ex8.subx.html') diff --git a/html/subx/examples/ex8.subx.html b/html/subx/examples/ex8.subx.html index e091fe9b..65f5e09c 100644 --- a/html/subx/examples/ex8.subx.html +++ b/html/subx/examples/ex8.subx.html @@ -77,44 +77,38 @@ if ('onhashchange' in window) { 21 # var s = argv[1] (EBX) 22 8b/copy 1/mod/*+disp8 4/rm32/sib 4/base/ESP 4/index/none 3/r32/EBX 8/disp8 . # copy *(ESP+8) to EBX 23 # call ascii_length(EBX) -24 # prepare call -25 55/push . . . . . . . . # push EBP -26 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP -27 # push args -28 53/push . . . . . . . . # push EBX -29 # call -30 e8/call ascii_length/disp32 -31 # discard args -32 5a/pop . . . . . . . . # pop into EDX -33 # clean up after call -34 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP -35 5d/pop . . . . . . . . # pop to EBP -36 -37 # exit(EAX) -38 89/copy 3/mod/direct 3/rm32/EBX . . . 0/r32/EAX . . # copy EAX to EBX -39 b8/copy . . . . . . . 1/imm32/exit # copy 1 to EAX -40 cd/syscall 0x80/imm8 -41 -42 ascii_length: # (s) -43 # initialize s (EDX) -44 8b/copy 1/mod/*+disp8 4/rm32/sib 4/base/ESP 4/index/none 2/r32/EDX 4/disp8 # copy *(ESP+4) to EDX -45 # var result = 0 (EAX) -46 b8/copy . . . . . . . 0/imm32 # copy 0 to EAX -47 $ascii_length_loop: -48 # var c = *s (ECX) -49 8a/copy 0/mod/* 2/rm32/EDX . . . 1/r32/ECX . . # copy byte at *EDX to lower byte of ECX -50 # if c == '\0' break -51 81 7/subop/compare 3/mod/direct 1/rm32/ECX . . . . . 0/imm32 # compare ECX with 0 -52 74/jump-if-equal $ascii_length_ret/disp8 -53 # ++s -54 81 0/subop/add 3/mod/direct 2/rm32/EDX . . . . . 1/imm32 # add 1 to EDX -55 # ++result -56 81 0/subop/add 3/mod/direct 0/rm32/EAX . . . . . 1/imm32 # add 1 to EAX -57 # loop -58 eb/jump $ascii_length_loop/disp8 -59 $ascii_length_ret: -60 # return (result in EAX) -61 c3/return +24 # push args +25 53/push-EBX +26 # call +27 e8/call ascii_length/disp32 +28 # discard args +29 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add 4 to ESP +30 +31 # exit(EAX) +32 89/copy 3/mod/direct 3/rm32/EBX . . . 0/r32/EAX . . # copy EAX to EBX +33 b8/copy . . . . . . . 1/imm32/exit # copy 1 to EAX +34 cd/syscall 0x80/imm8 +35 +36 ascii_length: # (s) +37 # initialize s (EDX) +38 8b/copy 1/mod/*+disp8 4/rm32/sib 4/base/ESP 4/index/none 2/r32/EDX 4/disp8 # copy *(ESP+4) to EDX +39 # var result = 0 (EAX) +40 b8/copy . . . . . . . 0/imm32 # copy 0 to EAX +41 $ascii_length_loop: +42 # var c = *s (ECX) +43 8a/copy 0/mod/* 2/rm32/EDX . . . 1/r32/ECX . . # copy byte at *EDX to lower byte of ECX +44 # if c == '\0' break +45 81 7/subop/compare 3/mod/direct 1/rm32/ECX . . . . . 0/imm32 # compare ECX with 0 +46 74/jump-if-equal $ascii_length_ret/disp8 +47 # ++s +48 81 0/subop/add 3/mod/direct 2/rm32/EDX . . . . . 1/imm32 # add 1 to EDX +49 # ++result +50 81 0/subop/add 3/mod/direct 0/rm32/EAX . . . . . 1/imm32 # add 1 to EAX +51 # loop +52 eb/jump $ascii_length_loop/disp8 +53 $ascii_length_ret: +54 # return (result in EAX) +55 c3/return -- cgit 1.4.1-2-gfad0