Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > alt.sys.pdp10 > #9967

Re: Command line parsing and MACRO-20

From jayjwa <jayjwa@atr2.ath.cx.invalid>
Newsgroups alt.sys.pdp10
Subject Re: Command line parsing and MACRO-20
Date 2026-08-29 12:19 -0400
Organization atr2net 2026
Message-ID <87h5kchpbs.fsf@atr2.ath.cx> (permalink)
References <87fqzyjexe.fsf@atr2.ath.cx> <aykkS.2694$aIQa.1285@fx18.iad>

Show all headers | View raw


scott@slp53.sl.home (Scott Lurndal) writes:

> Enter "how does an TOPS-20 MACRO-20 application retrieve the command
> line used to invoke the utility?" at the google search bar and the AI
> suggests the RSCAN% monitor call and COMND% jsys call.

I'm pretty leary of AI for a couple reasons: one, I often field (Linux)
questions on LQ, and many confused new user's questions begin thus:
"ChatGPT told me...but it's not working" and they are more lost as a
result. Two, is that it will often produce results that *seem* correct,
but are not. Case in point was someone I spoke with on IRC that got a
stopwatch program in MACRO-10. It (the LLM) made basic mistakes like
mixing up radix, not initializing the stack before use, and trying to
move too large of numbers in immediate mode. Then there's the ego thing,
but I digress...

In this case, it pointed me in the correct direction so that I didn't
have to offer a human sacrifice to get COMND% working. Thanks; here's
the finished program:

@compile /compile myecho.mac
MACRO:  myecho

EXIT
@load myecho
LINK:   Loading
@save myecho
 MYECHO.EXE.7 Saved
@myecho

No characters available to read.
@myecho hello world
The input text is: hello world


comment $
myecho.mac
Demo on how to get at the command line, such as in C's argv and argc. 
Normally the full command line is returned. If you don't want the 
program name itself, you'll have to step over it. 
$
        title	myecho				; There's an 'echo' in UNIX-SYS
        search	monsym, macsym
        STDAC.					; Label accums in std way

        maxchr==^D50				; Max chars to read, in decimal

buffer:	block	maxchr				; Input buffer for cmd line

	subttl	Main
start:	MOVX	t1, .RSINI			; First, make data in buf avail
	rscan%					; in Job Storage Block
	  erjmp	[hrroi t1, [asciz /Error on .RSINI. Exiting./]
		 psout%
		 haltf%]			; Halt on rscan/rsini error
	MOVX	t1, .RSCNT			; Get num chars remain to read
	rscan%					; Does not actually read them
	  erjmp [hrroi t1, [asciz /Error on .RSCNT. Exiting./]
		 psout%
		 haltf%]			; Halt no restart on rscnt err
	jumpe	t1, empty			; Nothing to read, then

; If we're here, there's chars to read. Read raw command string to our buffer
	move	t1, [.PRIIN]			; Read from term, ready SIN%
	hrroi	t2, buffer			; Send them to our buffer
	MOVX	t3, <5*maxchr>-1		; Max chr read limit
	MOVX	t4, .CHLFD			; Signal end on 12 oct, \n
	sin%					; String input
	  erjmp	[hrroi t1, [asciz /Error on SIN%. Exiting./]
		 psout%
		 haltf%]			; Exit no restart on SIN% err

; The buffer contains the program name as well. Step over it and the blank
; that comes after it (7 chars if prog name is "myecho" plus a space).
; TODO: Calculate, programmatically, the length of the program name	
	move	t1, [point 7, buffer]		; Load buffer location
	movei	t3, 7				; Skip those 7 chars
	adjbp	t3, t1				; in t1's pointer
	exch	t3, t1				; but we need it in t1...
	ldb	t2, t1				; Look for \r
	cain	t2, .CHLFD			; \r basically means no chars
	  jrst	empty
	move	t4, t1				; t1 will be clobbered by TMSG
        TMSG    (The input text is: )           ; Print heading
	move	t1, t4				; Put back t1, due to above
	psout%					
	jrst	done				; Skip 'no chars' message

; By "no chars" it means "other than the program's own name". Leave out
; the byte pointer dance above if you DO want to handle the program's own
; name.  
empty:	TMSG	(
No characters available to read.)		; If nothing to read...
done:	haltf%					; Exit to monitor
	jrst	start				; Restartable
	end	start				; Assembler is done

-- 
PGP Key ID: 781C A3E2 C6ED 70A6 B356  7AF5 B510 542E D460 5CAE
       "The Internet should always be the Wild West!"

Back to alt.sys.pdp10 | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Command line parsing and MACRO-20 jayjwa <jayjwa@atr2.ath.cx.invalid> - 2026-08-28 14:08 -0400
  Re: Command line parsing and MACRO-20 scott@slp53.sl.home (Scott Lurndal) - 2026-08-28 18:35 +0000
    Re: Command line parsing and MACRO-20 jayjwa <jayjwa@atr2.ath.cx.invalid> - 2026-08-29 12:19 -0400
      Re: Command line parsing and MACRO-20 Rich Alderson <news@alderson.users.panix.com> - 2026-08-29 17:51 -0400
  Re: Command line parsing and MACRO-20 Rich Alderson <news@alderson.users.panix.com> - 2026-08-28 20:59 -0400
    Re: Command line parsing and MACRO-20 jayjwa <jayjwa@atr2.ath.cx.invalid> - 2026-08-29 12:37 -0400
      Re: Command line parsing and MACRO-20 Rich Alderson <news@alderson.users.panix.com> - 2026-08-29 18:04 -0400
        Re: Command line parsing and MACRO-20 jayjwa <jayjwa@atr2.ath.cx.invalid> - 2026-08-30 11:38 -0400
          Re: Command line parsing and MACRO-20 Rich Alderson <news@alderson.users.panix.com> - 2026-08-30 22:18 -0400

csiph-web