i want to use masm write a dos program,and let it get cmdline arg list when it run.
such as
c:\test.com -help or c:\test.exe -help
then display:
c:\help
Posted on 2004-04-08 20:06:54 by bgcq
This code should process the command line and fill the array named paramlist with the addresses of the parameters.


mov si,129
mov di,128
xor cx,cx
mov bp,di
mov bx,offset paramlist
cmdlineloop:
lodsb
cmp al,34
jnz notquote
xor cl,1
jmp cmdlineloop
notquote:
cmp al,13
jz space
cmp al,44
jz space
cmp al,32
jnz notspace
space:
mov [bx],bp
mov bp,di
inc bx
inc bx
inc bp
mov al,0
notspace:
stosb
cmp byte [si-1],13
jnz cmdlineloop
Posted on 2004-04-08 21:38:32 by Sephiroth3
thanks.i just use code and data in one seg,it such as:
code segment
assume cs:code ,ds:code

strMsg db 'hello,world",0

mov si,offset strMsg
call ShowMessage

mov ax,4c00h
int 21h
ShowMessage proc
mov ah , 0eh
mov bh , 00
mov bl , 07
nextchar:
lodsb
or al , al
jz return
int 10h
jmp nextchar
return:
ret
ShowMessage endp
it dosnt work,but i add
mov ax,code
mov ds,ax
then it work,why?
Posted on 2004-04-09 20:58:39 by bgcq
Because when a DOS .exe program starts, DS does not equal CS. DS and ES are set up to allow access to the PSP which contains the tail of the command line.
Posted on 2004-04-10 01:37:26 by tenkey