Hello world written in IBM
System/370 assembler language using the SIOF (start I/O fast release)
instruction complete with associated channel program.
Output will appear on the
IBM 1403 line printer that you've (naturally) got connected to channel 0 at the usual address (i.e. 00E).
In order to avoid a bunch of extraneous details (that I don't remember anymore), we'll assume that the system is currently running in BC (Basic Control) mode.
EXAMPLE CSECT
*
* enter supervisor state
*
%%% left as an exercise for the reader %%%
*
* establish a base register
*
BALR 12,0
USING *,12
*
* disable I/O interrupts (save the old mask)
*
STNSM SYSMASK,0
*
* start the operation
*
LA 2,CPROGRAM Get the address of our first CCW
ST 2,72 set the CAW to point at it
* (EQU statements are for wimps!)
SIOF X'00E' bang!
BNZ OOPS Did it work?
*
* restore the system mask and continue
*
SSM SYSMASK
.
.
.
*
* Something went wrong. Just sit and stare at our navel.
* Someone will eventually notice that we need help!
*
OOPS B OOPS
*
* Our channel program
* (longer than it needs to be if memory serves)
*
* Sends "Hello World!" to a 1403 line printer
CPROGRAM DS 0D Force double-word alignment
* first CCW - skip to the top of the next page
* (does anyone remember if "Skip to channel 0" will take data as well?)
DC X'83' Skip to channel 0 (assumes 1403 line printer)
DC AL3(0) no data
DC X'60' Command Chaining and Suppress Length Indication
DC X'00' unused (always set to 0)
DC AL2(0) no length
* second CCW - send the message text
DC X'09' Write text and then advance to next line
DC AL3(HELLO) address of the data
DC X'20' Suppress Length Indication
DC X'00' unused (always set to 0)
DC AL2(LHELLO) length of message
*
* Our "Hello world!" message
*
HELLO DC C'Hello world!'
LHELLO EQU *-HELLO
*
* Somewhere to save the system mask
* (not re-entrant but you can't have everything)
*
SYSMASK DS X
*
* Done
*
END
Unfortunately, I wasn't able to convince anyone to lend me their mainframe so that I could test the program although I'm pretty sure that it would work.
Yes, I know - BC mode is also for wimps.