flat assembler
Message board for the users of flat assembler.

Index > Linux > appending \n using registers

Author
Thread Post new topic Reply to topic
Paul6253



Joined: 19 Oct 2003
Posts: 31
Location: NY
Paul6253
hello,
lets assume that we have defined tr:

tr db "96"

The stack method works fine.
The register method fails.

Thanks for help
Paul


_test:



;stack method
mov dx,[tr]
xchg dh,dl
mov edi,0x0a0d00
push edi
push dx
mov ecx,esp ;buffer
mov edx,5 ;length of buffer
mov eax,4 ;sys_write
mov ebx,1 ;file descriptor
int 0x80

;outputs '69' with a \n

;register method
mov dx,[tr]
mov ecx,edx ;buffer
mov edx,2 ;length of buffer
mov eax,4 ;sys_write
mov ebx,1 ;file descriptor
int 0x80

mov edi,0x0a0d00
mov ecx,edx ;buffer
mov edx,3 ;length of buffer
mov eax,4 ;sys_write
mov ebx,1 ;file descriptor
int 0x80


exit:

mov ebx,eax
mov eax,1
int 0x80

_________________
Plez xcuce mi spelng
Post 01 Nov 2003, 07:46
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7718
Location: Kraków, Poland
Tomasz Grysztar
You should do:
Code:
mov ecx,tr    

instead of:
Code:
mov dx,[tr]
mov ecx,edx    
Post 03 Nov 2003, 19:18
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.