| | |
Command-line arguments?
Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Oct 2009
Posts: 33
Reputation:
Solved Threads: 0
Would anyone know how to get command-line arguments in NASM16? I am on a Windows XP. I have tried a great deal of things and spent much time searching for an answer to this.
What I ment by command line arguments, something simple like this would be enough.
Filename: Hello1
Params: one two three
So when you type "hello1 one two three", it would see that you typed "one two three", and say something along the lines of
Param 1: One
Param 2: Two
Param 3: Three
I am really against using C libraries (I prefer to do everything purely in assembly).. So if it is possible to do it without C, I would really appreciate your time to answer.
Someone may ask "Why would you want to do this? Just use a higher level language.".. My short answer would be that I enjoy using assembly over a high level language, because of its complexity.
What I ment by command line arguments, something simple like this would be enough.
Filename: Hello1
Params: one two three
So when you type "hello1 one two three", it would see that you typed "one two three", and say something along the lines of
Param 1: One
Param 2: Two
Param 3: Three
I am really against using C libraries (I prefer to do everything purely in assembly).. So if it is possible to do it without C, I would really appreciate your time to answer.
Someone may ask "Why would you want to do this? Just use a higher level language.".. My short answer would be that I enjoy using assembly over a high level language, because of its complexity.
•
•
Join Date: Oct 2009
Posts: 33
Reputation:
Solved Threads: 0
0
#3 Oct 14th, 2009
I would assume so. It came with the book "Assembly language step-by-step". I have had it for a while and it works fine. (After looking around, MASM32 is 32 bit, so I think Nasm16 would be 16 bit).
And not sure if this means it's 16 bit, but I normally put [bits 16] at the top of my code.
Is it possible to get a command-line argument with C? I do not like the use C libraries because to me it does not feel like real assembly. To me, real assembly is 100% machine instructions.
And not sure if this means it's 16 bit, but I normally put [bits 16] at the top of my code.
Is it possible to get a command-line argument with C? I do not like the use C libraries because to me it does not feel like real assembly. To me, real assembly is 100% machine instructions.
It's passion that drives me.
0
#4 Oct 14th, 2009
I know how to do it in 64 bit assembly using Linux's as. You just take the offset of the rsp register.i.e
16(%rsp) will get the first command-line argument
In 32 bit Linux's as
8(%esp) to get the first command-line argument
...For 16 bit...I don't think Linux supports 16 bit exe's so I never had the opportunity to try but if it did it would probably be an offset of the ss:sp registers...Hope this helps
16(%rsp) will get the first command-line argument
In 32 bit Linux's as
8(%esp) to get the first command-line argument
...For 16 bit...I don't think Linux supports 16 bit exe's so I never had the opportunity to try but if it did it would probably be an offset of the ss:sp registers...Hope this helps
0
#6 Oct 14th, 2009
•
•
•
•
Thanks. I would not know how to test this on windows as I have never used Linux, but I appreciate your time to reply.
where ss is the segment register and sp is the stack pointer together they will give you the base of the stack
Last edited by gerard4143; Oct 14th, 2009 at 6:21 pm.
•
•
Join Date: Oct 2009
Posts: 33
Reputation:
Solved Threads: 0
0
#7 Oct 14th, 2009
How would I go about doing that? The most i've ever done with assembly was a "Press any key to view its hexidecimal\binary value". I think I may have heard of ss:sp before, but I have no clue how to do anything with them. I understand if you don't have the time to make a code to show me.
It's passion that drives me.
0
#8 Oct 14th, 2009
Try this link. It discusses 16 bit programming with nasm
http://developer.apple.com/mac/libra.../nasmdoc7.html
http://developer.apple.com/mac/libra.../nasmdoc7.html
•
•
Join Date: Oct 2009
Posts: 33
Reputation:
Solved Threads: 0
0
#9 Oct 14th, 2009
That did help a bit. But I still cannot get it to work.. I did, however, make a code as proof that I tried. It is supposed to check if the first argument is the "a" key, then display "It works" if it works.
Here is the code.
Here is the code.
Assembly Syntax (Toggle Plain Text)
[org 0100h] [section .text] start: call arg cmp bx,61h ;Check if first arg is "a" je works ;Say it worked if it did jne notwork ;Say it didnt work if it didnt arg: push bp mov bp,sp sub sp,0x40 mov bx,[bp+4] mov sp,bp pop bp ret 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
#10 Oct 14th, 2009
Did you try Googling "Windows XP 16 bit programs"
http://pcs.suite101.com/article.cfm/...atability_mode
http://pcs.suite101.com/article.cfm/...atability_mode
Last edited by gerard4143; Oct 14th, 2009 at 8:30 pm.
![]() |
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
| 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 nohau osdevelopment print program range read remainder shape string text theory tsr x86





