943,871 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Unsolved
  • Views: 607
  • Assembly RSS
May 2nd, 2009
0

Conditional assambly doesn't work! :(

Expand Post »
Hello everyone.
I'm trying to do this in nasm under linux :
Assembly Syntax (Toggle Plain Text)
  1. cmp eax,ebx
  2. jng .loop
and also
Assembly Syntax (Toggle Plain Text)
  1. test eax,ebx
  2. jng .loop
and yet also
Assembly Syntax (Toggle Plain Text)
  1. %if eax < ebx
  2. jmp .loop
  3. %endif
I want to loop while eax is lesser than ebx and non of the 3 methods work!
First 2 execute once and then hit for the exit code
the last one gives error:
error: `<': operands differ by a non-scalar

Can someone help me? I've been banging my head against the wall for some hours now!
Reputation Points: 10
Solved Threads: 3
Junior Poster
Alex_ is offline Offline
175 posts
since Jun 2008
May 4th, 2009
0

Re: Conditional assambly doesn't work! :(

Sorry for the late response been really busy lately.
From the code you've posted I don't really see a problem.

Here's the best and most useful time to open up gdb.
And I'll attempt to explain an easy way to do so!

so in my linux asm code I usually have a main label. So I would do this.
Assembly Syntax (Toggle Plain Text)
  1. gdb myprog
  2. gdb> break main
  3. breakpoint set
  4. gdb> display /x $eax
  5. gdb> display /x $ebx
  6. gdb> display /x $eflags
  7. gdb> run
  8. breakpoint reached
Now here gdb is hanging out at the main label in myprog which happens for me to be the begging of my code!
So I do 'stepi' while watching my registers until I get to the instruction that I want to watch then I'll usually do a 'info all-reg'

If you're going to programming in assembly you're going to NEED to become familiar with a debugger. What do other languages do for you? By writing in assembly you're saying "I'm smart enough that I can get down into the hardware and interact with it directly". There's no type safety or any standard or a compiler to tell you that what you're doing is unsafe. Actually the only thing keeping your program in check from obliterating the machine is the O/S (assuming you're in a protected mode O/S such as linux).
Reputation Points: 57
Solved Threads: 5
Light Poster
sysop_fb is offline Offline
42 posts
since Apr 2009
May 4th, 2009
0

Re: Conditional assambly doesn't work! :(

Sorry i don't understand how to get it work...
I try running: gdb lab4a
it gives : (no debugging symbols found)
Then i try: - files lab4a
But it says:
exec No process In: Line: ?? PC: 0x0
Invalid window specified.
The window name specified must be valid and visible.

What am i doing wrong? Please bare with me. )
Reputation Points: 10
Solved Threads: 3
Junior Poster
Alex_ is offline Offline
175 posts
since Jun 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Assembly Forum Timeline: assembly language help
Next Thread in Assembly Forum Timeline: Assembly fatal ........





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC