From c9521a4aad0d42ccec124d84b04d9fa5b1ce621d Mon Sep 17 00:00:00 2001 From: ergz Date: Thu, 23 Jun 2022 23:32:45 -0700 Subject: [PATCH] finish 2_2 --- src/2_2.asm | 28 +++++++++++++++++++++++----- src/2_2.exe | Bin 567296 -> 567296 bytes 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/2_2.asm b/src/2_2.asm index fc11917..9cf1fcc 100644 --- a/src/2_2.asm +++ b/src/2_2.asm @@ -1,3 +1,7 @@ +; Notes --- +; RCX, RDX, R8, R9 are the registers specified in Windows ABI +; for use as the first, second, third and fourth argument respectively +; all of these are volatile option casemap:none @@ -12,6 +16,7 @@ right_op2 dword 12345678h title_str byte "Listing 2-2", 0 +sep_str byte "--------------", nl, 0 fmt_str1 byte "%lx AND %lx = %lx", nl, 0 fmt_str2 byte "%lx OR %lx = %lx", nl, 0 @@ -32,11 +37,11 @@ asm_main PROC sub rsp, 56 ; AND operator - lea rcx, fmt_str1 ; load fmt str address - mov edx, left_op - mov r8d, right_op1 - mov r9d, edx - and r9d, r8d + lea rcx, fmt_str1 ; load address for fmt_str1 into the rcx register + mov edx, left_op ; move the left_op value into the edx register + mov r8d, right_op1 ; move the right_op value into the r8d register + mov r9d, edx ; move the edx value into the r9d register, this one is a little confusing to me + and r9d, r8d ; r9d AND r8d, we also have all of our values into the correct register based on the ABI to call printf call printf lea rcx, fmt_str1 @@ -46,6 +51,19 @@ asm_main PROC and r9d, edx call printf + lea rcx, sep_str + call printf + +; OR operator + lea rcx, fmt_str2 ; load address of fmt_str2 in rcx for use in the printf call + mov edx, left_op + mov r8d, right_op1 + mov r9d, edx + or r8d, r9d + call printf + + add rsp, 56 + ret asm_main ENDP END diff --git a/src/2_2.exe b/src/2_2.exe index 4fe69608574d936c6e91c87b6220a41d3baf704c..9efc18f9b4aa0dd1e9861b03dc334203f540e6c1 100644 GIT binary patch delta 278 zcmZp;pww_dX@dYG^O2CPn}r$cnVE#9ZJxq%RE5d8aC5X~3>VAGH)#yh8MRr&H(xNG zr@y%%c?09*3&t_iFF3HUZ*ESNHLdsPWlf#Q&T!bH`Hh7~FK;Q3-7V@4Bwe~$UBJ{S zSLG8gEbIRN2TF&5r8OYZnn236`-F?~sTWcZX?38;3qAGdULd94A*ofZ5FZ37mOF^Z_Z8L z%;@3K%lh;jJHug*<~J4|y}TfHx9D*o>C(-51WcWBRX*`z=jQ+afzrpo(kmd+D}j`2 z_X!u}Q!i$1o}T!ERb=`F2Nw3t&8f1c)1`HoL?>S`zC1l4m4&6bXLftfY(^kv0%B$$ tW&vVWAZFX%Gn;*jFeBr3$Mx*j^QLRaarjJB7noj9&CasDLXM-O697*LQt$u(