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
Assembly help
Re:Assembly help
1. You're using DOS calls. Are you aware of that?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
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
My book says 0x4c, with return code in al. So something like:
0x4c being the code for ah, and 0x00 the return value for al.
Happy assembling.
Code: Select all
mov ax, 0x4c00
int 0x21
Happy assembling.
Re:Assembly help
Yup... it's 0x4C. I recall something like 0x4D being for exiting without return value?QuiTeVexat wrote: My book says 0x4c, with return code in al. So something like:
0x4c being the code for ah, and 0x00 the return value for al.Code: Select all
mov ax, 0x4c00 int 0x21
Happy assembling.
Re:Assembly help
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.
I had trouble with a real BIOS that didn't save register values.
Re:Assembly help
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]
[url=http://www.cs.cmu.edu/~ralf/files.html]
## ---- ----- RBIL[/url]