Assembly

Programming, for all ages and all languages.
Locked
RedDemon1970
Posts: 13
Joined: Sat Jan 24, 2009 11:25 am
Location: Belgium

Assembly

Post 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
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: Assembly

Post 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
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
blound
Member
Member
Posts: 70
Joined: Sat Dec 01, 2007 1:36 pm

Re: Assembly

Post 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
User avatar
i586coder
Member
Member
Posts: 143
Joined: Sat Sep 20, 2008 6:43 am

Re: Assembly

Post 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
Distance doesn't make you any smaller,
but it does make you part of a larger picture.
RedDemon1970
Posts: 13
Joined: Sat Jan 24, 2009 11:25 am
Location: Belgium

Re: Assembly

Post 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?
User avatar
i586coder
Member
Member
Posts: 143
Joined: Sat Sep 20, 2008 6:43 am

Re: Assembly

Post 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
Distance doesn't make you any smaller,
but it does make you part of a larger picture.
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: Assembly

Post by Troy Martin »

First IBX, then HL... you have your registers/processor architectures confuzzled, my friend...
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: Assembly

Post 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
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Assembly

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
RedDemon1970
Posts: 13
Joined: Sat Jan 24, 2009 11:25 am
Location: Belgium

Re: Assembly

Post 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
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Assembly

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Locked