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 4fe6960..9efc18f 100644 Binary files a/src/2_2.exe and b/src/2_2.exe differ