Nasm problem
Nasm problem
Hi,
i'm trying win32 nasm:
segment code
main:
mov dx,message
mov AH,9
int 0x21
;mov ax,0x4c00
int 0x21
ret
segment data
message db 'test','$'
on dos shell i digit:
nasm -o test.com -f bin test.asm
Now, when i execute this test.com, it print many "strange" characters and also "test" string. Which is error?
Thank you.
i'm trying win32 nasm:
segment code
main:
mov dx,message
mov AH,9
int 0x21
;mov ax,0x4c00
int 0x21
ret
segment data
message db 'test','$'
on dos shell i digit:
nasm -o test.com -f bin test.asm
Now, when i execute this test.com, it print many "strange" characters and also "test" string. Which is error?
Thank you.
- Combuster
- 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: Nasm problem
Code: Select all
ORG 100h
Re: Nasm problem
Ok,
now it's ok.
There's code:
org 100h
message db 'Hello',13,10,'$'
main:
mov dx, message
mov AH,09h
int 21h
I don't understand if i try to replace "Hello" with "test", it give me an error of "CS:...." during executing file.exe/com. Why?
now it's ok.
There's code:
org 100h
message db 'Hello',13,10,'$'
main:
mov dx, message
mov AH,09h
int 21h
I don't understand if i try to replace "Hello" with "test", it give me an error of "CS:...." during executing file.exe/com. Why?
Re: Nasm problem
I don't understand.
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Re: Nasm problem
Wait, never mind. I was thinking of the wrong int 21 function - been a while since I've delved into that sort of stuff.
You might want to put the "message db...." line after the code, otherwise it might possibly attempt to execute the string. There's no segments or whatnot in a COM file
You might want to put the "message db...." line after the code, otherwise it might possibly attempt to execute the string. There's no segments or whatnot in a COM file
Re: Nasm problem
I permit to extend this thread with another question:
org 100h
mov ax,num1
add ax,num2
aaa
mov dx,ax
mov ah,09h
int 21h
mov ah,4Ch ; ah = 4Ch
int 21h
num1 DW 10
num2 DW 15
I would sum num1 with num2 and print to screen. When executing this code it give me bad characters and not only 25.
org 100h
mov ax,num1
add ax,num2
aaa
mov dx,ax
mov ah,09h
int 21h
mov ah,4Ch ; ah = 4Ch
int 21h
num1 DW 10
num2 DW 15
I would sum num1 with num2 and print to screen. When executing this code it give me bad characters and not only 25.
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Re: Nasm problem
You need to convert the integer to a string first - at the moment it'll write the ASCII character 25, not 2 and 5.
- Combuster
- 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: Nasm problem
Do you know exactly what does?
Code: Select all
mov ax,num1
Re: Nasm problem
Insert num1 at ax register
- Combuster
- 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: Nasm problem
and what is "num1"?sbeng77 wrote:Insert num1 at ax register
Re: Nasm problem
Combuster wrote:and what is "num1"?sbeng77 wrote:Insert num1 at ax register
DW
- Combuster
- 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: Nasm problem
That answer would score you zero points on a test for being too obvious, try again.
Re: Nasm problem
org 100h
mov al,num1
add al,num2
mov dx,ax
mov ah,09h
int 21h
mov ah,4Ch ; ah = 4Ch
int 21h
num1 db 5
num2 db 3
Ok, now i've sum two number but when execute this code it prints me many bad characters!
mov al,num1
add al,num2
mov dx,ax
mov ah,09h
int 21h
mov ah,4Ch ; ah = 4Ch
int 21h
num1 db 5
num2 db 3
Ok, now i've sum two number but when execute this code it prints me many bad characters!
Re: Nasm problem
I think what Combuster was getting at is that you are actually loading ax and dx with pointers.
The second problem is that for DOS interrupts, a quick look in RBIL shows that Int 21h ah = 09h reveals that DS:DX should contain a pointer to a '$' terminated string. You need to convert your numeric answer to a string (once you have learned what [] does) and then add '$' termination, also ensuring that DS points where expected.
Cheers,
Adam
The second problem is that for DOS interrupts, a quick look in RBIL shows that Int 21h ah = 09h reveals that DS:DX should contain a pointer to a '$' terminated string. You need to convert your numeric answer to a string (once you have learned what [] does) and then add '$' termination, also ensuring that DS points where expected.
Cheers,
Adam