| | |
Command-line arguments?
Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
0
#12 Oct 14th, 2009
I would try experimenting with this line
Try values like
mov bx,[bp+8]
mov bx,[bp+12]
Just keep working your way up the stack...
Note the first value on the stack is the number of arguments
Also the command line argument isn't saved on the stack...a pointer to the command line argument is saved on the stack.
Assembly Syntax (Toggle Plain Text)
mov bx,[bp+4]
Try values like
mov bx,[bp+8]
mov bx,[bp+12]
Just keep working your way up the stack...
Note the first value on the stack is the number of arguments
Also the command line argument isn't saved on the stack...a pointer to the command line argument is saved on the stack.
Last edited by gerard4143; Oct 14th, 2009 at 9:20 pm.
0
#14 Oct 14th, 2009
cmp bx, 1 should work...at least its an easy way to see if your checking values on the stack...If you get a true for cmp bx, 1 try changing it to cmp bx, 3 and pass three arguments and see if it still works..If it does then try dereferencing the value ahead of it to see if its your string...Good luck
•
•
Join Date: Oct 2009
Posts: 33
Reputation:
Solved Threads: 0
0
#15 Oct 14th, 2009
Still does not work. I'll paste my newer code below. Would compiling it as a .com file have any effect? Because that's what I am using (.com).
Assembly Syntax (Toggle Plain Text)
[org 0100h] [section .text] start: call arg cmp bx,1 ;Check for first arg je works ;Say it worked if it found one jne notwork ;Say it didnt work if it didnt find one arg: push bp ;Save BP mov bp,sp ;Move SP into BP sub sp,0x40 mov bx,[bp+4] ;First argument mov sp,bp ;Move bp into SP pop bp ;Retore BP ret ;Return works: mov dx,msg ;Load "works" message into DX call disp call exit notwork: mov dx,msg1 call disp call exit disp: mov ah,9 ;Function 9, display string int 21h ;Call DOS ret exit: mov AH,4CH ; Terminate process DOS service mov AL,0 ; Pass this value back to ERRORLEVEL (0) int 21H ; Exit [section .data] msg db "It worked", 13, 10, "$" msg1 db "It did'nt work", 13, 10, "$"
It's passion that drives me.
0
#16 Oct 14th, 2009
16-bit OS dos I need help vortex reign....
Hello, to answer your question NASM16 is a 16-bit (80x86) assembler
for MS-DOS.
To access commandline parameters, they are passed by the
loader (your parent process) into offset 81h in your PSP.
You have your origin set to 100h so I assume you are assembling
a .COM
So try this:
Oh yeah, the command tail is but a string of bytes terminated
by a Carriage Return (0xd) and is usually preceded by a
space character (0x20) but not always.
Need more examples, no problem!
Hello, to answer your question NASM16 is a 16-bit (80x86) assembler
for MS-DOS.
To access commandline parameters, they are passed by the
loader (your parent process) into offset 81h in your PSP.
You have your origin set to 100h so I assume you are assembling
a .COM
So try this:
Assembly Syntax (Toggle Plain Text)
mov cl, [cs:0x80] ; Get Command Tail Length mov bx, 0x81 ; place offset of command tail in BX.
by a Carriage Return (0xd) and is usually preceded by a
space character (0x20) but not always.
Need more examples, no problem!
----------------------------------------------------------
To control a mind violates a man, and all it has been used for is
hurting and afflicting. Nowonder I progam in assembly...
--->Now available http://dotcoding.netai.net/
To control a mind violates a man, and all it has been used for is
hurting and afflicting. Nowonder I progam in assembly...
--->Now available http://dotcoding.netai.net/
•
•
Join Date: Oct 2009
Posts: 33
Reputation:
Solved Threads: 0
0
#17 Oct 14th, 2009
Hey, thanks.. but, it did not work.. I may have just set it up wrong though. Would you mind showing a working example of how to use it please?
Code:
Code:
Assembly Syntax (Toggle Plain Text)
[org 0100h] [section .text] start: call arg call disp call exit arg: mov cl, [cs:0x80] ; Get Command Tail Length mov bx, 0x81 ; place offset of command tail in BX. ret ;Return disp: mov ah,9 ;Function 9, display string int 21h ;Call DOS ret exit: mov AH,4CH ; Terminate process DOS service mov AL,0 ; Pass this value back to ERRORLEVEL (0) int 21H ; Exit [section .data]
It's passion that drives me.
1
#19 Oct 15th, 2009
To print out your commandline arguments with
function 9, simply add a '$' to the end of the actual command tail.
example:
But remember the command tail length does not include the
carriage return, so it will be overwritten.
Yes there is in fact a few other ways to print
a string, here's one using the BIOS:
function 9, simply add a '$' to the end of the actual command tail.
example:
Assembly Syntax (Toggle Plain Text)
xor bx, bx mov bl, [0x80] mov byte [bx+0x81],'$' mov bx, 0x81
carriage return, so it will be overwritten.
Yes there is in fact a few other ways to print
a string, here's one using the BIOS:
Assembly Syntax (Toggle Plain Text)
printstr: ; DS:SI - Null Terminated String cld printstr_l: lodsb cmp al, 0 jz printstr_e mov bh, 0 mov ah, 0xe int 0x10 jmp printstr_l printstr_e: ret
Last edited by NotNull; Oct 15th, 2009 at 11:19 pm.
----------------------------------------------------------
To control a mind violates a man, and all it has been used for is
hurting and afflicting. Nowonder I progam in assembly...
--->Now available http://dotcoding.netai.net/
To control a mind violates a man, and all it has been used for is
hurting and afflicting. Nowonder I progam in assembly...
--->Now available http://dotcoding.netai.net/
![]() |
Similar Threads
- Command Line Arguments (C#)
- command line arguments help (C)
- To fetch data through command line arguments (C++)
- HELP!!!need help with command line arguments and creating a package in java. HELP!!!! (Java)
- command line arguments (C++)
- Command-line Arguments. (C++)
Other Threads in the Assembly Forum
- Previous Thread: floating point syscall
- Next Thread: Big Issue with Assembly Startup
Views: 820 | Replies: 19
| Thread Tools | Search this Thread |
Tag cloud for Assembly
3d 68hc11 6811 80386 :( adress array asm assembler assembly boot bootloader buffer compression cursor debug directory division docs dos draw emulator endtask error exceptions file int10h integer intel interrupt interrupts language loop newbie nohau osdevelopment print program range read remainder shape string text theory tsr x86





