Page 1 of 1

Assembly

Posted: Mon May 11, 2009 8:10 am
by RedDemon1970
Maybe this has been asked several times, but i can't find it any site so..here's my question

how can i halt and vieuw the result if i load some values into EAX, EBX and IBX and then substrac them and do more with them. Is there a way that i can vieuw the result or can execute my code step by step?

thx in advance

Re: Assembly

Posted: Mon May 11, 2009 8:47 am
by Troy Martin
Well, if I remember correctly, there is a breakpoint flag or something that calls an exception every instruction if it's set, but I'm not sure how it works...

If you have calls that can print a byte in, let's say AL, as hexadecimal, you can use that to print AX, and then use that to print EAX. Using that, you could even get IP and print out the next four or so bytes (and, if you're really good at assembly, have a listing of all the base x86 instructions and disassemble them.)
RedDemon1970 wrote:and IBX
I'm assuming you mean EBP or ECX or something.

Cheers,
Troy

Re: Assembly

Posted: Mon May 11, 2009 10:54 am
by blound
RedDemon1970 wrote:Maybe this has been asked several times, but i can't find it any site so..here's my question

how can i halt and vieuw the result if i load some values into EAX, EBX and IBX and then substrac them and do more with them. Is there a way that i can vieuw the result or can execute my code step by step?

thx in advance
do you mean in your own os? just boot your OS in bochs and set a breakpoint at wherever you want to start, then start single step each instruction

if you want to do this for a normal binary under linux/windows just use any debugger. if you specially have an asm file under linux, then ald is a really good single stepping debugger

Re: Assembly

Posted: Mon May 11, 2009 12:24 pm
by i586coder
HI there,

if i understood your question, there's several ways to do that:

1. for me i use BORLAND TC 3.1 IDE to write kernel code,this environment has break-point
add watch,view registers,and more
2. the above useful in development session,but if you want view some debugging info
in compiled code, i suggest:
a. use #define debug , in possible errors section in your code,and write your own panic()
b. on hardware level, set ( bit 8 )TRAP flag in FLAGS registers using popf instruction

CheerS,
a.T.d

Re: Assembly

Posted: Mon May 11, 2009 12:28 pm
by RedDemon1970
well I didn't meant it for my own os i meant if I put for example this

mov al, 5
mov hl, 5
add al, hl

well when I would compile this it would run but I don't see any result so wich code do I have to add to make the program halt and show the result?

Re: Assembly

Posted: Mon May 11, 2009 12:38 pm
by i586coder
OK, please take look at
http://forum.osdev.org/viewtopic.php?f= ... 8&start=15
RedDemon1970 wrote:to make the program halt and show the result?
you can:
1. call the print_AX procedure itself
2. convert print_AX into interrupt, e.g. int 99h when invoke will print the result

CheerS,
a.T.d

Re: Assembly

Posted: Mon May 11, 2009 4:01 pm
by Troy Martin
First IBX, then HL... you have your registers/processor architectures confuzzled, my friend...

Re: Assembly

Posted: Mon May 11, 2009 4:18 pm
by Dex
You could try
xor ax,ax
int 16h
before you exit code.
Also some thing like this may help you
http://www.lrr.in.tum.de/~jasmin/index.html
http://www.btinternet.com/~btketman/tutpage.html

Re: Assembly

Posted: Mon May 11, 2009 4:56 pm
by Combuster
RedDemon1970 wrote:I put for example this

mov al, 5
mov hl, 5
add al, hl

(...) it would run
Seriously, get your facts straight.
wich code do I have to add to make the program halt and show the result?
Do you consider yourself a programmer? The forum rules say that you need a good deal of experience with programming prior to attempting an OS, and if you're unable to find a way to print something that's been discussed and demonstrated a dozen times before you should be able to figure this one on your own.

Re: Assembly

Posted: Tue May 12, 2009 10:36 am
by RedDemon1970
I have never said that, and if my question doesn't belong here, well then tell me where to find a comunity where they know also a lot about assembly

Re: Assembly

Posted: Tue May 12, 2009 11:02 am
by Combuster
I have never said that
Of course not, you typed that. :roll:
well then tell me where to find a comunity where they know also a lot about assembly
On google. And -1 for ignoring that forum rule.
if my question doesn't belong here
Your questions fail the etiquette. You should not be asking them anywhere.

Now, whatever code you should need to is already here on the forums. But I leave you some time to think about the other things you need. Thread locked.