comp r3, r6 //
beq L1 //if cc == 0 goto L1
set 00, r5 //else if cc != 0, set r5 to 0
//problem:keeps going to L1 from here
L1: set 01, r5 //set r5 to 1
Whats wrong with my 'if statement' in assembly?
Hi, i'm doing some assembly and I'm trying to do an if statement,
if cc == 0 set reg5 to 1 else set reg5 to 0
The problem is 'if cc !=0' it sets 'r5' to 0 fine, but continues to 'L1', and sets it to 1 aswell.
What am I doing wrong?
thx!
Maybe you should handle a '!=' (or "if (r3 != r6)") and send it to L2, if it reaches that point. I'm no expert in Assembly, but that's my guess. =)
you need an unconditional jump after you set r5 to 0.
I forget the syntax but something like
I forget the syntax but something like
comp r3, r6beq L1set 00, r5jmp L2L1: set 01, r5L2: whatever you want to dowhat you have now is equivalent toif (r3 == r6) r5 = 0;r5 = 1;
Ah right I see,
With the
L2:
I want it to goto that position, but I don't want to put any code next to it, but I can't compile it unless I do.
What should I do?
With the
L2:
I want it to goto that position, but I don't want to put any code next to it, but I can't compile it unless I do.
What should I do?
Quote:Original post by johnnyBravo
hmmmm, nothing, i just want the L2: so I can skip calling L1:
Yes, but what happens _after_ that? Something must.
Quote:I can't compile it unless I do
What error message do you get?
Quote:Dude: CMOV
Except this does not look like x86 assembly.
Which architecture is it, BTW?
I'm not really sure which dialect it is, I'm using 'Yet Another Assembly Simulator' written by someone at Macquarie Uni, our lecturer said its x86.
the error is some numbers 'opcode not recognized', over and over.
I ended up just storing it:
L2: store r5, 01
Which wasn't part of the question guidelines.
the error is some numbers 'opcode not recognized', over and over.
I ended up just storing it:
L2: store r5, 01
Which wasn't part of the question guidelines.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement