Hi,
I've got an assignment where I have to turn C code into machine and assembly code, but I'm having a problem with understanding beq, bne, blt, and bnl commands. I have to do a simple while loop (while i >= 0), and I'm guessing I have to use bnl command but I have no idea how to use it. Anyone can provide me a link to learn about branching or can tell me about will be much appreciated. Also I have to use AT&T syntax, not Intel one.
Thanks in advance.
5 replies to this topic
#1
Posted 16 November 2011 - 07:00 PM
|
|
|
#2
Posted 16 November 2011 - 08:13 PM
For the following C code,
I would usually do something like this:
I don't know AT&T syntax, though; this is just my two cents.
while (variable1 < variable2){
variable2 += variable3;
}
I would usually do something like this:
lp1: mov eax, dword [variable1] cmp eax, dword [variable2] jnl lp1s mov eax, dword [variable3] add dword [variable2], eax jmp lp1 lp1s:
I don't know AT&T syntax, though; this is just my two cents.
#3
Posted 17 November 2011 - 12:24 PM
Are you using MIPS, x86, or what? I'm not sure whether beq, bne, blt, or bnl exists on x86, and that is why I ask.
Latinamne loqueris?
#4
Posted 17 November 2011 - 05:05 PM
I think the 'b' - in beq, bne, blt, and bnl - stands for "branch" (verb).
#5
Posted 19 November 2011 - 04:12 PM
Yeah, beq, bne, blt, and bnl are MIPS instructions. What did your assignment say?
sudo rm -rf /
#6
Posted 19 November 2011 - 04:32 PM
You would still use very similar instructions on MIPS, as you would on x86. Like instead of using the 'jz' instruction, you would use the 'beq' instruction, etc.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









