Hello, World!
Time to start reviving some macro-assembler skills :-)
Here are a couple of versions of the obligatory Hello, World!
The first, longer version uses normal AOS/VS file IO (?OPEN and ?WRITE) to the user’s console…
; Hello World!
;
; This version uses normal file IO to the default user console
;
.title hello
.ent hello
.nrel 4 ; Unshared code
hello: ?OPEN console
wbr badbye
?WRITE console
wbr badbye
close: ?CLOSE console
wbr badbye
wsub 2,2 ; set good return flags
wbr bye
bye: wsub 0,0
?RETURN
wbr badbye
badbye: wsub 1,1
wldai ?RFER+?RFCF+?RFEC,2 ; error code in AC0
wbr bye
.nrel 6 ; Shareable data
.enable word
console: .blk ?IBLT
.loc console+?ISTI
?ICRF+?RTDS+?OFIO
.loc console+?IMRS
-1 ; block size (def. 2048)
.loc console+?IBAD
.dword msg*2 ; double-word byte ptr to msg
.loc console+?IRCL
.word 120.
.loc console+?IFNP
.dword con*2 ; double-word byte ptr to filename
.loc console+?IDEL
.dword -1
.loc console+?IBLT
msg: .txt "Hello World"
con: .txt "@CONSOLE" ; generic name
.end hello
The second, shorter version uses an AOS/VS trick to avoid all the explicit file I/O; a message is simply returned to the calling process (CLI)…
; Hello World!
;
; This version uses a CLI return message
;
.title hello
.ent hello
.nrel 1 ; Shareable code
hello: llefb 1,msg*2 ; load byte addr into AC1
nldai len*2,2 ; byte length into AC2
bye: wsub 0,0
?RETURN
wbr badbye
badbye: wsub 1,1
wldai ?RFER+?RFCF+?RFEC,2 ; error code in AC0
wbr bye
; Be nice and put static data in shared data partition.
; N.B. Must then use llefb above to address it
.nrel 5
msg: .txt "Hello, World!"
len=.-msg
.end hello