After the heights of APL, let's turn to the lowest level language possible: System/360 assembly language.
System/360 Assembly Language
MTS runs on the IBM System/360, designed from scratch by IBM in the early 1960s as a unified successor to a number of different architectures. System programmers, and application programmers looking for maximum performance used assembler to write code as close to the bare metal as possible.
As the System/360 was a new design, the architecture is clean and fairly simple. It's a 32 bit architecture with 24 bit addresses, 16 full word registers and 4 64 bit floating point registers. Binary Coded Decimal (BCD) arithmetic and I/O operations are also supported.
Assemblers on MTS
MTS ran originally on a System/360-67, and later on 370 and Amdahl CPUs which provided extensions to the basic instruction set that we will not consider here.
The main assembler available to us today is Assembler G (
*ASMG). This is a basic assembler, derived from Assembler F provided by IBM for OS/360 with extensions by the University of Waterloo for improved performance.
At the time of MTS D6, the most common assembler in use was Assembler H. This has a considerable number of improvements to the assembly language supported in Assembler G; however, this is not available in the MTS distribution due to copyright reasons.
ASSIST, Assembler System for Student Instruction & Systems Teaching, was an assembler and emulator used by students to learn assembly. As it emulates the underlying machine it can provide additional debug information and run time control, at the expense of performance. It is available on the MTS distribution as
*ASMT is a specialised assembler compatible with features on IBM's time sharing system TSS. We will not consider either of these further in these blog posts.
No special installation instructions to get this language running - just do the standard D6.0 setup as described in this guide and then sign on as a regular user such as
Running a program using
*ASMG will take a file of assembly language instructions from
scards and write output to
spunch. A program listing can be sent to
sprint and errors to
sercom if these are set on the command line. Extra parameters can be set with
par, for example
par=test will add debugging information to the object file.
Linking is done at run time by MTS, so if you are just using the system libraries the object file can be run directly with
Let's see how to run a simple program to print 'Hello, world!' five times using assembly language.
The source file (with line numbers) looks like this:
# list hello.asm 1 HELLO START 0 PROGRAM AT RELATIVE ADDRESS 0 2 USING HELLO,12 R12 WILL CONTAIN PROGRAM ADDR 3 LR 12,15 LOAD R12 WITH ABSOLUTE ADDR 4 L 3,RUNS R3 COUNTS DOWN NUMBER OF RUNS 5 LOOP SPRINT 'Hello, world!' PRINT THE MESSAGE 6 S 3,DECR DECREMENT R3 7 BP LOOP IF R3 POSITIVE, LOOP AGAIN 8 SYSTEM EXIT PROGRAM 9 RUNS DC F'5' NUMBER OF RUNS TO MAKE 10 DECR DC F'1' DECREMENT FOR LOOP 11 END HELLO END OF CODE
Here's how to run the assembler. We send errors to
*sink* so they are displayed immediately and a full program listing to
# $run *asmg scards=hello.asm spunch=-load sercom=*sink* sprint=-hello.l par=test . *** *ASMG has been changed to use *ASMGSYSMAC for the default macro . *** library instead of *SYSMAC. It will no longer work with *SYSMAC. # Execution begins 18:19:08 ASSEMBLER (G) DONE 18:19:08 30 SEP 17 NO STATEMENTS FLAGGED IN THIS ASSEMBLY # Execution terminated 18:19:08 T=0.091
We can ignore the
*ASMG has been changed... message;
NO STATEMENTS FLAGGED means that it worked OK.
Finally, let's run the assembled program.
# $run -load # Execution begins 18:19:17 Hello, world! Hello, world! Hello, world! Hello, world! Hello, world! # Execution terminated 18:19:17 T=0
A good place to start is A Programmer's Introduction to IBM System/360 Assembler Language, which gives an overview of the System/360 architecture and then teaches different aspects of assembly language programming using examples.
A full description of how the System/360 works and the opcodes available is in IBM System/360 Principles of Operation.
MTS Volume 14: 360/370 Assemblers in MTS details the differences between Assembler G and Assembler H, macro libraries, structured programming macros and the ASSIST assembler.
MTS Volume 3: System Subroutine Descriptions describes the 'standard library' of routines available to assembler programmers on MTS.