Author Topic: String  (Read 10602 times)

Offline shellc0de

  • Jr. Member
  • *
  • Posts: 12
String
« 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

Offline encryptor256

  • Full Member
  • **
  • Posts: 250
  • Country: lv
  • Win64 .
    • On Youtube: encryptor256
Re: String
« Reply #1 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!!!$"

Encryptor256's Investigation \ Research Department.

Offline shellc0de

  • Jr. Member
  • *
  • Posts: 12
Re: String
« Reply #2 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?

Offline encryptor256

  • Full Member
  • **
  • Posts: 250
  • Country: lv
  • Win64 .
    • On Youtube: encryptor256
Re: String
« Reply #3 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
Encryptor256's Investigation \ Research Department.

Offline shellc0de

  • Jr. Member
  • *
  • Posts: 12
Re: String
« Reply #4 on: March 13, 2014, 11:31:59 AM »
Thats it . I have used 0x0 for string termin. Thanks