Page 1 of 1

Assembly help

Posted: Wed Dec 21, 2005 12:02 pm
by fatalz
Hi everyone ! i've been programming in c++ for years now and i always read how fast and memory efficient an assembly code is. So i've decided to give it a try and write a hello world code. here is part of it



MOV AH , 02h

MOV DL , 48h
INT 21h ; //PRINT H

MOV DL , 45h
INT 21h ;//PRINT E

MOV DL , 4ch
INT 21h ;//PRINT L

MOV DL , 4ch
INT 21h ;//PRINT L

MOV DL , 4fh
INT 21h ; //PRINT O



for some reason after it prints o, the programme enter in an infinite loop and keeps printing the "o" caractere. Does anyone know what the problem is ? and also is it worth learning assembly ? is it portable ?
Thanks in advance

PS: English is not my first language, so please excuse my syntax

Re:Assembly help

Posted: Wed Dec 21, 2005 12:13 pm
by Candy
fatalz wrote: Hi everyone ! i've been programming in c++ for years now and i always read how fast and memory efficient an assembly code is. So i've decided to give it a try and write a hello world code. here is part of it



MOV AH , 02h

MOV DL , 48h
INT 21h ; //PRINT H

MOV DL , 45h
INT 21h ;//PRINT E

MOV DL , 4ch
INT 21h ;//PRINT L

MOV DL , 4ch
INT 21h ;//PRINT L

MOV DL , 4fh
INT 21h ; //PRINT O



for some reason after it prints o, the programme enter in an infinite loop and keeps printing the "o" caractere. Does anyone know what the problem is ? and also is it worth learning assembly ? is it portable ?
Thanks in advance

PS: English is not my first language, so please excuse my syntax
1. You're using DOS calls. Are you aware of that?

2. You don't terminate the program with DOS calls. Due to some coincidence, it ends up back at the o or somewhere near that. Terminate your program when you're done. Hint: int21/ah=4f iirc.

Re:Assembly help

Posted: Wed Dec 21, 2005 2:13 pm
by QuiTeVexat
My book says 0x4c, with return code in al. So something like:

Code: Select all

mov ax, 0x4c00
int 0x21
0x4c being the code for ah, and 0x00 the return value for al.

Happy assembling.

Re:Assembly help

Posted: Wed Dec 21, 2005 3:02 pm
by Candy
QuiTeVexat wrote: My book says 0x4c, with return code in al. So something like:

Code: Select all

mov ax, 0x4c00
int 0x21
0x4c being the code for ah, and 0x00 the return value for al.

Happy assembling.
Yup... it's 0x4C. I recall something like 0x4D being for exiting without return value?

Re:Assembly help

Posted: Wed Dec 21, 2005 3:18 pm
by fatalz
i see the problem now ! thanks a lot

Re:Assembly help

Posted: Thu Dec 29, 2005 4:55 pm
by Cjmovie
Is it always safe to assume DOS or BIOS won't mess up your registers during the call? Are they saved for you?

I had trouble with a real BIOS that didn't save register values.

Re:Assembly help

Posted: Fri Dec 30, 2005 11:41 am
by JAAman
most of the time, any registers not marked as return values, will not be contaminated, but check the RBIL for more accurate, and machine specific details (there are a couple of exceptions)


[url=http://www.cs.cmu.edu/~ralf/files.html]
## ---- ----- RBIL[/url]