I am writing some assembler code to do 'Hello World', but I want to write to stdout in UNIX System Services and not a WTO or PUT to a DDName.
I am using 'as' and 'ld' without any special options to assemble and link, e.g.
as -mlist hw.asm >hw.lst
ld hw.o
and I expect I need to pull in the library code for BPX1WRT from somewhere, but I can't find it in the documentation. I end up with:
Assembler Done No Statements Flagged
IEW2457E 9208 SYMBOL BPX1WRT UNRESOLVED. NO CALL LIBRARY SPECIFIED.
IEW2665S 40FF MODULE *NULL* IS NON-EXECUTABLE AND WAS NOT SAVED BECAUSE
STORENX=NEVER.
IEW5033 The binder ended with return code 12.
I am coding this up as re-entrant code. Here's the code (I expect there are addressability bugs in here since I haven't got it linking yet)
PRINT ON,GEN,DATA
HELLO CSECT
*
* Prolog
*
SAVE (14,12)
BASR R12,0
USING *,R12
STORAGE OBTAIN,LENGTH=DYNSIZE,ADDR=(R11)
USING DYNAREA,R11
LA R2,SAVEA
ST R2,8(,R13)
ST R13,SAVEA+4
LR R13,R2
*
* Body
* Write Hello World to STDOUT
*
MVC RECORD,=C'Hello World'
MVC RECLEN,RECSIZE
LA R15,RECORD
ST R15,RECADDR
CALL BPX1WRT, +
(STDOUT, +
RECORD, +
BPXALET, +
RECLEN, +
RV, +
RC), +
VL,MF=(E,PLIST)
*
* Epilog
*
STORAGE RELEASE,LENGTH=DYNSIZE,ADDR=(R11)
RETURN (14,12),RC=0
LTORG
*
* Statics (constants)
*
STDOUT DC F'0'
STDIN DC F'1'
STDERR DC F'2'
BPXALET DC F'0'
*
* Dynamic (storage obtain'ed) area
*
DYNAREA DSECT
DYNSIZE EQU DYNEND-*
*
* Stack save area always first
*
SAVEA DS 18F
*
* Working storage
*
RECSIZE EQU RECEND-*
RECORD DS CL80
RECLEN DS F
RECEND EQU *
RECADDR DS A
RV DS F
RC DS F
PLIST DS 10A * Is this enough?
*
* End of working storage
*
DYNEND EQU *
*
* Equates
*
R0 EQU 0
R1 EQU 1
R2 EQU 2
R3 EQU 3
R4 EQU 4
R5 EQU 5
R6 EQU 6
R7 EQU 7
R8 EQU 8
R9 EQU 9
R10 EQU 10
R11 EQU 11
R12 EQU 12
R13 EQU 13
R14 EQU 14
R15 EQU 15
END
You are using the CALL macro instead of the LINK (or better LINKX) macro to invoke BPX1WRT. This will STATICALLY include the load module for BPX1WRT into your linked program. Use LINKX instead to dynamically load and execute BPX1WRT.
The link error is because you do not have the system library where BPX1WRT lives in the SYSLIB DD of the link step.