flat assembler
Message board for the users of flat assembler.

Index > DOS > append '$' to dx... How To Do?

Author
Thread Post new topic Reply to topic
gumletis



Joined: 18 Dec 2004
Posts: 128
gumletis 22 Jan 2005, 22:22
...Hi, I have done alot of work with win32 APIs, and im tierd of that, so I try make some of my programs in dos, but I got a few problems, I don't know how I can append a string/a char to a register or a defined byte/other... Heres my SIMPLY code, I've gonna add more when i get this to work
Code:
org 100h
mov ah,1Ah
mov dx,find
int 21h
mov dx,type
mov cx,3fh
mov ah,0eh
int 21h
mov dx,word[find+30]
mov [dx+10],byte '$'
mov ah,09h
int 21h
xor ah,ah
int 16h
RET
type db 'c:\winnt\*.exe',0
find rb 128
    


HELP! Rolling Eyes

_________________
LOOOL
Post 22 Jan 2005, 22:22
View user's profile Send private message Reply with quote
gunblade



Joined: 19 Feb 2004
Posts: 209
gunblade 23 Jan 2005, 01:03
too lazy to look up the table of DOS interrupts to see what your code is doing.. but if your wanting to add a char to the end of a string, its easy (as long as that string is ended by a 0 (0x00)), or you know the length of it.

just calcutate the length of the string, then mov the char into the buffer+len..
basic example:

Code:
xor edx, edx
cmp byte [buffer+edx], 0
je @f
inc edx
jmp @b
@@:
;edx now contains length of string
mov byte [buffer+edx], '$'
mov byte [buffer+edx+1], '0' ;only if you need...
buffer rb 512
    


(im sure theres a better length-counting technique.. i'd like to know, if anyone else knows Smile
Post 23 Jan 2005, 01:03
View user's profile Send private message Reply with quote
cr4ck3r



Joined: 22 Sep 2004
Posts: 6
Location: Melbourne, Australia
cr4ck3r 23 Jan 2005, 06:59
Here you go you can use this Very Happy

Code:
mov ecx,labelend-labelbegin
mov byte [labelbegin+ecx],'$'
mov ah,9
mov dx,labelbegin
int 21h

xor ax,ax
int 16h

ret

labelbegin:
 db 'This is a string'
labelend:
    


Regards. Laughing
Post 23 Jan 2005, 06:59
View user's profile Send private message Reply with quote
gumletis



Joined: 18 Dec 2004
Posts: 128
gumletis 23 Jan 2005, 09:52
hmm, cr4ck3r thats is impossible to do with my code, becuase its one there allready are in a register - not a buffer, ´but i tryed what gumblade sayed... Just can't get it to work, here's my code

Code:
org 100h
mov ah,1Ah
mov dx,find
int 21h
mov dx,type
mov cx,3fh
mov ah,0eh
int 21h
mov dx,[find+30]
xor edx,edx
cmp byte[buffer+edx],0
je @f                              ; this i don't know whats means?
inc edx
jmp @b                           ; and this i also don't understand
@@:
mov byte[dx+edx],'$'
mov byte[dx+edx+1],0
mov dx,word[find+30]
mov [dx+10],byte '$'
mov ah,09h
int 21h
xor ah,ah
int 16h
RET
type db 'c:\winnt\*.exe',0
find rb 128         

_________________
LOOOL
Post 23 Jan 2005, 09:52
View user's profile Send private message Reply with quote
gumletis



Joined: 18 Dec 2004
Posts: 128
gumletis 23 Jan 2005, 11:40
i've tryed some there was't so hard to make, but still wont work, please help.
Code:
org 100h
mov ah,01h
star:
int 21h
cmp al,'s'
je endy
mov byte[path+len],al
jmp star
endy:
mov dx,endl
mov ah,9
int 21h
mov byte[path+len],'$'
mov dx,path
mov ah,9
int 21h
mov ah,0
int 16h
RET
path  rb 100
len   db $-path,0
endl  db 13,10,'$',0   
    

_________________
LOOOL
Post 23 Jan 2005, 11:40
View user's profile Send private message Reply with quote
gumletis



Joined: 18 Dec 2004
Posts: 128
gumletis 24 Jan 2005, 13:39
i found a way how to do that, just get the size of it, and so append it to it, some like this(not with my home computer, so just write this, donno if its works)
Code:
getsize equ call size
move eax,type
getsize
mov byte[type+eax],'$'
...
..
..
..
..
RET
size:
mov ebp,0
star333:
inc esi
cmp byte[eax+ebpi],0
jne star333
RET
    


donno if its works, i haven't got a compiler on this computer....

_________________
LOOOL
Post 24 Jan 2005, 13:39
View user's profile Send private message Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1166
Location: Overflow
Matrix 02 Feb 2005, 20:28
gunblade wrote:
too lazy to look up the table of DOS interrupts to see what your code is doing.. but if your wanting to add a char to the end of a string, its easy (as long as that string is ended by a 0 (0x00)), or you know the length of it.

just calcutate the length of the string, then mov the char into the buffer+len..
basic example:

Code:
xor edx, edx
cmp byte [buffer+edx], 0
je @f
inc edx
jmp @b
@@:
;edx now contains length of string
mov byte [buffer+edx], '$'
mov byte [buffer+edx+1], '0' ;only if you need...
buffer rb 512
    


(im sure theres a better length-counting technique.. i'd like to know, if anyone else knows Smile

hello,
i'd recommend you these algos to determine the null trerminated string len, then do mov byte [ebx],'$'
Post 02 Feb 2005, 20:28
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.