hb@pbhya.PacBell.COM (Henry Bitter) (04/20/88)
I am trying to get started doing some assembler programming and need some help. I need to know how you get the command line information using assembler. In particular, the program I'm writing needs the name of a file which will be opened and closed. Is there a ARGV[n] type arguement in assembler ? If so, how does it work ? Thanks for your help; Henry Bitter * Pacific Bell * (415) 823-2836 San Ramon, Calif. { }!pacbell!pbhya!hb If I had a disclaimer I wouldn't give it away !
steveb@cbmvax.UUCP (Steve Beats) (04/21/88)
In article <12542@pbhya.PacBell.COM> hb@pbhya.PacBell.COM (Henry Bitter) writes: > >I am trying to get started doing some assembler programming and need some >help. I need to know how you get the command line information using >assembler. In particular, the program I'm writing needs the name of a file >which will be opened and closed. Is there a ARGV[n] type arguement in >assembler ? If so, how does it work ? > When you start up an assembler program (that has not been linked with any special startup code) it is entered with a0 pointing to the command line arguments and d0 containing the number of characters in the command. Note, the name of the program is NOT included in the command line you are passed, only the arguments. D0 is the number of characters including the terminating newline character ($0a). The command line is not a null terminated string and you'll have to parse it yourself to break up the separate arguments. If you need to access the name of the program (equivalent to argv[0] in 'C') you will have to open DOS library, find your task with FindTask(0) and fish the pointer to the command name out of the CLI struct in your process header. It would go something like this in assembler (assuming the task pointer is already in a0). movea.l pr_CLI(a0),a0 adda.l a0,a0 BPTR to CLI struct adda.l a0,a0 movea.l cli_CommandName(a0),a0 adda.l a0,a0 BPTR to command name adda.l a0,a0 a0 now points to a BCPL string containing the name of the program. This is a string where the first byte (n) contains the length of the string followed by n characters. Hope this helps. VERY IMPORTANT: The above will only work for a program started from CLI (which can be tested for quite easily because pr_CLI is zero if the program was started from WorkBench). You need a completely different startup for WorkBench launched programs. Steve
mills-c@pike.cis.ohio-state.edu (Christopher Mills) (04/21/88)
In article <3664@cbmvax.UUCP> steveb@cbmvax.UUCP (Steve Beats) writes: >In article <12542@pbhya.PacBell.COM> hb@pbhya.PacBell.COM (Henry Bitter) writes: >>... I need to know how you get the command line information using >>assembler.... > > >If you need to access the name of the program (equivalent to argv[0] in 'C') >you will have to open DOS library, find your task with FindTask(0) and fish >the pointer to the command name out of the CLI struct in your process header. Or you could just link in c.o or astartup.obj and name the entry point to your program __main. Then it does all the workbench/CLI startup for you. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- _____________________ | Christopher Mills. (_)________________ \ | mills@baloo.eng.ohio-state.edu ________________|\ \ | mills-c@pike.cis.ohio-state.edu (_)______________\_\ \ | Current Thought: I really should be ______________________\ | doing my thesis now... (_)____________________| | DISCLAMER: I really wish I could blame | my thoughts on someone else... -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-