flat assembler
Message board for the users of flat assembler.
Index
> DOS > How hard is doing command line arguments? |
Author |
|
Tomasz Grysztar 15 Oct 2006, 21:38
Code: org 100h label arguments_length byte at 80h label arguments_data byte at 81h mov ah,9 ; display string to stdout mov dx,_msg int 21h mov ah,40h ; write file mov bx,1 ; 1 - handle of stdout mov dx,arguments_data mov cl,[arguments_length] xor ch,ch ; number of bytes to write in CX int 21h ; writing to stdout displays the bytes int 20h ; exit program _msg db 'WAZZUP',24h |
|||
15 Oct 2006, 21:38 |
|
vid 15 Oct 2006, 22:09
means, you don't have argc and argv, you just have simple string at CS:81h, whose length is stored in byte at CS:80h
|
|||
15 Oct 2006, 22:09 |
|
Tomasz Grysztar 15 Oct 2006, 23:26
It's better to say PSP:80h - in case of MZ EXE it's also this way, though PSP is not necessarily CS.
|
|||
15 Oct 2006, 23:26 |
|
vid 15 Oct 2006, 23:38
well.. it is more general, but less understandable. depends on which of these two you (or reader) prefers
|
|||
15 Oct 2006, 23:38 |
|
2 16 Oct 2006, 05:43
Thanks! That helped me do this!
Code: org 256 mov ah,9 cmp byte[128],0 je p1 jmp p2 p1: mov dx,n int 33 jmp p3 p2: mov dx,y int 33 mov ah,64 mov bx,1 mov cl,[128] ;offset that says how many bytes the argument is xor ch,ch ;set ch to 0 so it won't interfere with the value of cx mov dx,129 ;space followed by arguments int 33 mov ah,9 mov dx,a int 33 p3: int 32 n db 'What is your name? You must tell me from the command line!',36 y db 'Hello',36 a db ', you are awesome!!!',36 |
|||
16 Oct 2006, 05:43 |
|
rhyno_dagreat 17 Oct 2006, 03:19
Is it the same with Windows apps as well, making a call from CS:81h for the command line, that is?
|
|||
17 Oct 2006, 03:19 |
|
Goplat 17 Oct 2006, 14:57
in Windows you use the GetCommandLine function to get a pointer to the command line. It has the program name in it as well as the arguments, though.
|
|||
17 Oct 2006, 14:57 |
|
Picnic 23 Sep 2007, 14:37
Hello all,
I want to take only one parameter, remove head-tail spaces, and store on a buffer as a null terminated string. Length on cl. I wrote few lines below, (running xp console), am i ok? Code: org 100h mov si,82h mov di,par xor ch,ch mov cl,[si-2] jcxz exit @@: lodsb cmp al,20h jz @b xor cl,cl dec si @@: lodsb stosb cmp al,0dh jz @f cmp al,20h jz @f inc cl jmp @b @@: mov byte [di],0 exit: int 20h par db 128 dup ? |
|||
23 Sep 2007, 14:37 |
|
rugxulo 07 Oct 2007, 02:58
You could use WDOSX as a DOS extender. If you use NASM's RDOFF (maybe other? formats), it sets up argc, **argv for you.
|
|||
07 Oct 2007, 02:58 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.