From c5d9a32fe6add8c986942261dd22377f911d1ca0 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 24 Sep 2018 18:48:41 -0700 Subject: 4516 More calling convention tweaks. Use EBP to get consistently at parameters and locals. Always put the first function argument closest to EBP. --- subx/examples/ex10.subx | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'subx/examples/ex10.subx') diff --git a/subx/examples/ex10.subx b/subx/examples/ex10.subx index 81f4f2ae..92e9f1f4 100644 --- a/subx/examples/ex10.subx +++ b/subx/examples/ex10.subx @@ -18,14 +18,13 @@ # argv[0]: *(ESP+4) # argv[1]: *(ESP+8) # ... - # s1 = argv[1] (EAX) - 8b/copy 1/mod/*+disp8 4/rm32/sib 4/base/ESP 4/index/none . 0/r32/EAX 8/disp8 . # copy *(ESP+8) to EAX - # s2 = argv[2] (EBX) - 8b/copy 1/mod/*+disp8 4/rm32/sib 4/base/ESP 4/index/none . 3/r32/EBX 0xc/disp8 . # copy *(ESP+12) to EBX - # call argv_equal(s1, s2) - # push args - 50/push-EAX - 53/push-EBX + # prolog + 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP + # call argv_equal(argv[1], argv[2]) + # push argv[2] + ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + # push argv[1] + ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x8/disp8 . # push *(EBP+8) # call e8/call argv_equal/disp32 # exit(EAX) @@ -38,8 +37,8 @@ $exit: # reason for the name: the only place we should have null-terminated ascii strings is from commandline args argv_equal: # (s1, s2) : null-terminated ascii strings -> EAX : boolean # initialize s1 (ECX) and s2 (EDX) - 8b/copy 1/mod/*+disp8 4/rm32/sib 4/base/ESP 4/index/none . 1/r32/ECX 8/disp8 . # copy *(ESP+8) to ECX - 8b/copy 1/mod/*+disp8 4/rm32/sib 4/base/ESP 4/index/none . 2/r32/EDX 4/disp8 . # copy *(ESP+4) to EDX + 8b/copy 1/mod/*+disp8 4/rm32/sib 4/base/ESP 4/index/none . 1/r32/ECX 4/disp8 . # copy *(ESP+4) to ECX + 8b/copy 1/mod/*+disp8 4/rm32/sib 4/base/ESP 4/index/none . 2/r32/EDX 8/disp8 . # copy *(ESP+8) to EDX # while (true) $argv_loop: # c1/EAX, c2/EBX = *s1, *s2 -- cgit 1.4.1-2-gfad0 a href='/danisanti/profani-tty/plain/src/xmpp/stanza.h?id=d81dbdb23370374d972a97c046b76f81f2094f9f'>plain) (tree)
1
2
3
4