DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Assembly (http://www.daniweb.com/forums/forum125.html)
-   -   Conditional assambly doesn't work! :( (http://www.daniweb.com/forums/thread190040.html)

Alex_ May 2nd, 2009 4:10 pm
Conditional assambly doesn't work! :(
 
Hello everyone.
I'm trying to do this in nasm under linux :
 cmp eax,ebx
jng .loop
and also
 test eax,ebx
jng .loop
and yet also
 %if eax < ebx
jmp .loop
%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!

sysop_fb May 4th, 2009 12:23 am
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.
gdb myprog
gdb> break main
breakpoint set
gdb> display /x $eax
gdb> display /x $ebx
gdb> display /x $eflags
gdb> run
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).

Alex_ May 4th, 2009 7:50 am
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. )


All times are GMT -4. The time now is 7:15 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC