In DOS if you have to extract the command line arguments you will need your code to peep in the PSP(Program Segment Prefix)
As all know programs in DOS have 64k of memory,when you insert a code the code "org 0x100" at the beginning the assembler formats the code such as it begins at the offset 0x100.
Now everything between 0x0 to 0x100 contains the PSP.
PSP also contains the command line arguments passed it begins at the address 0x80,where 0x80 contains the length of the argument and 0x81 contains the space used to separate the program and the arguments.The argument(s) are finally terminated by a carriage return character.
Discussion will be incomplete without any code..so here it is:-
;Prints all command line arguments passed to it org 0x100 [section .text] mov bx,0x82 ;bx contains the address of the first char of argument print: cmp byte [bx],0x0D ;compare with CR character jz over ;if it's CR break mov ah,0x06 ;0x06 function number to output char mov dl,[bx] int 0x21 inc bx jmp print over: ret END
(If you have to extract each argument separately then you will have to recognize spaces and take the appropriate steps)
Warrior


Sign In
Create Account


Back to top









