I am working on a project right now where I have to perform matrix multiplication. I have indicated in the comment in the code below that I can not change the variables given and their type. Therefore, I can not switch to section .resb macro and I have to use section .data. I am trying to test out the program by comparing rA
and cB
first before performing the operation.
I decided to print strings to check if the program is working as it is intended. Apparently, the program deems that the two variables I am comparing are not equal when it is supposed to be the other way around. Did I misuse EAX
and EBX
?
%include "io.inc"
section .data
;Below variables are to be used.
rA db 2
cA db 3
matrixA db 2,3,4
db 1,0,0
rB db 3
cB db 2
matrixB db 0,127
db 1,100
db 0,10
section .text
global CMAIN
CMAIN:
mov ebp, esp; for correct debugging
;write your code here
lea eax, [rA]
lea ebx, [cB]
mov ax, [eax]
mov bx, [ebx]
cmp ax, bx ;this line is supposed to compare if both digits are equal
JE bothEqual
JNE notEqual
bothEqual:
PRINT_STRING "Can be multiplied"
NEWLINE
PRINT_DEC 1, eax
NEWLINE
PRINT_DEC 1, ebx
jmp FINISH
notEqual:
PRINT_STRING "Can not be multiplied"
NEWLINE
PRINT_DEC 1, eax ; Check the value of eax. [In this case, the expected value of eax = 2 but program prints 770]
NEWLINE
PRINT_DEC 1, ebx ; Check the value of ebx. [In this case, the expected value of ebx = 2 but program prints 2]
jmp FINISH
FINISH:
nop
xor eax, eax
ret