Xref: utzoo comp.sys.amiga:17899 comp.sys.amiga.tech:432 Path: utzoo!mnetor!uunet!cbmvax!steveb From: steveb@cbmvax.UUCP (Steve Beats) Newsgroups: comp.sys.amiga,comp.sys.amiga.tech Subject: Re: Assembler Help Message-ID: <3664@cbmvax.UUCP> Date: 20 Apr 88 20:59:59 GMT References: <12542@pbhya.PacBell.COM> Reply-To: steveb@cbmvax.UUCP (Steve Beats) Organization: Commodore Technology, West Chester, PA Lines: 40 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