Click here to Skip to main content
15,867,963 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Im new to this and i need help with this asembler code
What does hoing to happen?

org 100h 
mov ax, 5; 
mov bx, 6; 
sub ax, bx; 
jz equal 
mov ax, 7; 
jmp stop
equal : 
mov ax, 10; 
stop: 
ret


What I have tried:

Im going to sub 5-6 = -1
If its qual im going to jump, but its not

And in the end in ax contains 10
Am i right?
Posted
Updated 24-Jan-22 23:53pm
Comments
CPallini 25-Jan-22 5:53am    
Yes, I suppose you are right.

1 solution

jz means "jump if zero"
Your result is not zero so it will not jump to the label "equal" but will execute the next instruction
ASM
mov ax, 7;
then jump to the label "stop"

So no, ax will not contain 10
 
Share this answer
 
Comments
ArchiKanarchi 25-Jan-22 6:18am    
So then ax is still 7
CHill60 25-Jan-22 6:51am    
Yes.
You said in your question "If its qual im going to jump, but its not" - jz equal does NOT mean "jump if it's equal", it means "if the result (of the previous calculation) is zero jump to the label "equal"
In your comment you said "So then ax is still 7" - strictly speaking it is not "still" 7, the value 7 has been moved into ax so it is now 7
When I was debugging my assembler programs back in the day, I used to use graph paper and a pencil to keep track of register contents and "current" instructions, because I didn't have a debugging program. At least now there is http://web.cecs.pdx.edu/~apt/cs510comp/gdb.pdf[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900