NASM - The Netwide Assembler

NASM Forum => Programming with NASM => Topic started by: shellc0de on March 13, 2014, 09:57:29 AM

Title: String
Post by: shellc0de on March 13, 2014, 09:57:29 AM
Code: [Select]
section .text
org 0x100
start:
mov byte[var1],'A'
mov byte[var1+1],'B'
mov byte[var1+2],0x00
mov ah,0x9
mov dx,[var1]
int 0x21
exit:
;mov ah,0x8
;int 0x21
mov ax,0x4c00
int 0x21
section .bss
var1: resb 10
How can i print string? i get some random sh*t
Title: Re: String
Post by: encryptor256 on March 13, 2014, 10:35:48 AM
You need to store address into DX, not the value.

Try this, maybe works:
Code: [Select]
section .text
org 0x100
start:

; ...

mov ah,0x9
mov dx,sometext
int 0x21

; other code, like - exit


section .data

sometext: db "Hello world!!!$"

Title: Re: String
Post by: shellc0de on March 13, 2014, 11:18:38 AM
Code: [Select]
section .text
org 0x100
start:
mov byte[var1],'A'
mov byte[var1+1],'B'
mov byte[var1+2],'C'
mov ah,0x9
mov dx,var1
int 0x21
exit:
;mov ah,0x8
;int 0x21
mov ax,0x4c00
int 0x21
section .bss
var1: resb 10
something like this? I need to print ABC do i need null terminator?
Title: Re: String
Post by: encryptor256 on March 13, 2014, 11:29:52 AM
Yes, null terminator for dos string is this -> $.

Maybe this will work:
Code: [Select]
section .text
org 0x100
start:
mov byte[var1],'A'
mov byte[var1+1],'B'
mov byte[var1+2],'C'
mov byte[var1+3],'$'
mov ah,0x9
mov dx,var1
int 0x21
exit:
;mov ah,0x8
;int 0x21
mov ax,0x4c00
int 0x21
section .bss
var1: resb 10
Title: Re: String
Post by: shellc0de on March 13, 2014, 11:31:59 AM
Thats it . I have used 0x0 for string termin. Thanks