You are on page 1of 5

Teaching Assembly Language:

A Comparison of IBM S/360 and Intel 80x86 Courses

Richard C. Detmer
Computer Science/Information Systems
Northwest Missouri State University
Maryville, MO 64468

Abstract paper, but IBM System/370 machines and


other architectural descendents of the
Computer science programs often use IBM System/360 have also been used.
a course with a title such as “assembly In fact, when IBM mainframes are not
language” to meet the objectives of the available, IBM S/360 emulators are
Curriculum ‘78 CS3 course. The com- sometimes used on other computer
puter system used for this course has systems. The author has taught this
frequently been an IBM System/360 or a traditional course many times, using
descendent of this architecture. Micro- both IBM mainframes and emulators on
computers are now widely available for other systems.
instructional use. This paper explores
the similarities and differences between Now microcomputers are widely
teaching assembly language for the available for computer science instruc-
System/360 architecture and for the tion. Many of these are IBM PC-
Intel 80x86 architecture. compatible systems, using the Intel 8088
microprocessor or a more powerful
Introduction member of the Intel 80x86 family. At
one point the computer science faculty
Curriculum ‘78 [ 11 lists the objec- at Northwest Missouri State University
tives of the CS3 course as: used ASSIST-PC, an S/360 emulator, to
teach assembly language on Intel 8088
(a) to provide basic concepts of systems. However, in the fall of 1987
computer systems; the author switched to 8088 assembly
language and has taught Northwest
(b) to introduce computer architec- Missouri’s “cs3” course using 8088
ture; and assembly language on IBM PC-compatible
systems four times. This paper is
(c) to teach an assembly language. based on those experiences, It
discusses the similarities and differ-
Although the title of CS3 is ences between teaching assembly
“Introduction to Computer Systems” language in the IBM S/360 environment
many computer science programs have and in the Intel 80x86 environment.
chosen to fulfill these objectives using
a course called “assembly language” or System Architectures
“assembler language.” In the past, a
typical course has been taught on IBM Each of the IBM S/360 and Intel
mainframes. Such systems are collec- 80x86 architectures use eight-bit bytes
tively called S/360 computers in this and byte-addressable memory. The
S/360 has 3%bit registers and a 3%bit
word length, while the 8086, 8088, and
Permission to copy without fee all or part of this material is granted provided
that the copies are not made or distributed for direct commercial advantage,
80286 have 16-bit registers and a 16-bit
the ACM copyright notice and the title of the publication and its date appear, word length. (The 80386 has 32-bit
and notice is given that copying is by permission of the Association for registers, but a “word” is still 16 bits
Computing Machinery. To copy otherwise, or to republish, requires a fee
and/or specific permission. long.) Each system uses base-displace-
0 1990 ACM 089791-346-9/90/0002/0116 $1SO ment addressing. An S/360 memory

116
address is calculated as the sum of the The S/360 registers are all “general
value in a base register and a displace- purpose,” although many have tradi-
ment coded in the instruction; some tional uses and a few instructions affect
instructions also add the value stored specific registers. The 80x86 architec-
in an index register. The 80x86 micro- ture assigns specific uses to most
processors use a similar formula, but registers. Even the nominally general
instead of the programmer’s choice of purpose registers AX, BX, GX and DX
registers for a base register, three have special assignments which must be
fixed “segment registers” named CS, DS, learned in an 80x86 course.
and SS hold segment numbers of
memory segments for code, data, and One of the most significant differ-
stack, respectively. A segment number ences between the S/360 and 80x86
is multiplied by 16 to get the starting architectures is that the latter uses a
byte address of the corresponding stack segment register and a stack
segment; the segment’s starting address pointer register to maintain a hardware
is added to a displacement from the stack. This has a major impact on the
instruction to get a memory address. way that procedures are implemented, as
Some 80x86 instructions add values from discussed below.
a base register and/or an index register
in addition to the segment register, Data Types
providing a richer collection of memory
addressing modes than the S/360 has. IBM S/360 systems support a much
larger collection of data types than do
It is just as easy to teach base- Intel 80x86 systems. Both have
displacement addressing for the Intel instructions for arithmetic on signed
80x86 and the IBM S/360. Students (2’s complement) and unsigned binary
seem to find the use of three segment integers. There are S/360 instructions
registers more intuitive than the use of for either 16-bit or 32-bit integers,
a single base register -- the three while there are 80x86 instructions for
segments naturally partition memory. either 8-bit or 16-bit integers. (The
Some students must be reminded, Intel 80386 also has instructions for 32-
however, that there is really only one bit integers.) Teaching integer opera-
memory for all code, for data, and for tions is very similar for the two archi-
the stack. The greater number of tectures.
addressing mode choices with the 80x86
could cause confusion, but it is easy to The two systems have somewhat
avoid this by postponing discussion of similar instructions for manipulating
more elaborate memory addressing modes strings. One difference is that 80x86
until halfway through a course. instructions handle strings of either
bytes or 16-bit words; the author
Displacements are stored as 12 bits typically concentrates on byte strings.
in S/360 instructions and as 16 bits in Teaching string operations is comparable
8086/8088/80286 instructions. One prac- in S/360 and Intel 80x86 courses.
tical consequence of this is that S/360
programs require multiple base registers While S/360 systems have extensive
for a program (code and data) over 4K instruction sets for dealing with packed
bytes long, whereas each segment of an decimal and floating point numbers,
8088 program can be 64K bytes long, 80x86 systems have minimal instruction
This has little impact on teaching an sets for packed decimal numbers and no
assembly language course; in both instructions for floating point numbers.
cases, one needs to talk about tech- This has had little affect on the
niques of writing longer programs. author’s assembly language courses; he
has always emphasized binary arith-
metic, treating packed decimal topics

117
late in a course and barely mentioning convert directly between character and
floating point operations. Packed deci- binary formats.
mal operations with an 80x86 system
must be accomplished with a collection Input/output can be a problem in an
of procedures to carry out the various 80x86 environment. Using PC-DOS or
operations, providing a good opportu- MS-DOS operating systems, the INT 33
nity to build a large software package instruction can be used to request a
if there is time in a course, but giving variety of operating system services,
the course a very different flavor than including character and string input
teaching the powerful S/360 packed and output. However, this is even more
decimal instructions. Floating point difficult than using the IBM macros, and
operations can be handled via proce- conversion from character to binary
dures in a “straight” 80x86 environment; format requires far more than two
80x87 instructions can be discussed if instructions. An alternative is to run
math coprocessors are available. Using programs under the control of a debug-
80x87 instructions is similar to teaching ging tool such as the DEBUG utility
S/360 floating point instructions. provided with DOS operating systems or
the CodeView debugger that Microsoft
The IBM S/360 and Intel 80x86 distributes with its Macro Assembler and
architectures have similar instructions with high-level language products. With
to do Boolean operations, although the a debugger, contents of registers or
80x86 instruction set includes a NOT memory can be easily examined and/or
instruction as well as AND, OR and XOR altered. This approach has the disad-
instructions, Both architectures include vantage of having to teach an additional
shift and rotate instructions. layer of software, and it obscures the
fact that a program must often do type
Input/Output conversions.

There are at least two ways that In his 8088 classes, the author has
input and output are handled in S/360 adopted an approach similar to that
assembly language courses. One is to provided by ASSIST, providing a set of
, use the I/O macros which are provided macros to read and write character
with the chosen operating system to strings, and to convert between char-
read or write fixed-length records. acter and binary formats. These macros
These macros expand into code expand to instruction sequences which
sequences including SVC instructions to call external procedures to do their
request operating system services. jobs. A student can easily use the
(The macro expansions are ignored in a macros at the beginning of a course,
typical S/360 course.) If a program is and later they and the associated
to do binary arithmetic, an S/360 CVD procedures provide a generous source
instruction is used to convert a char- of examples for macros, for procedures,
acter string to packed decimal and a and for use of many instructions.
CVB instruction is used convert the
packed decimal number to binary, This Procedures
is confusing for beginning assembly
language students, and it forces some There are many differences in the
discussion of packed decimal numbers way procedures are implemented in the
much sooner than the author prefers. S/360 and Intel 80x86 environments.
Another alternative with S/360 assembly The Intel 80x86 is stack-oriented, so the
language is to use a package like stack rather than a register is used to
ASSIST which provides an extended save the return address. This is
instruction set, including instructions to accomplished by a CALL instruction
read or write a record of a specified which students find much more natural
length, and other instructions to

118
than the S/360 BAL or BALR, To return different data types or different
to the calling procedure, 80x86 RET addressing modes.
instructions are somewhat more natural
than S/360 BR instructions. Intel designed 80x86 assembly
language so that one mnemonic may
In the Intel 80x86 environment PUSH correspond to several instruction
and POP instructions use the stack to formats and/or opcodes. The assembler
save and restore register values needed examines the operands as well as the
by the calling procedure. This is much mnemonic to determine which instruction
simpler to teach than the conventional is intended. For example, the ADD
S/360 technique which requires the mnemonic corresponds to three basic
calling procedure to reserve a register instruction formats and nine opcodes in
save area and to put the address of 8088 machine language. This makes it
this area in register 13, while a STM easier to learn Intel 80x86 mnemonics
instruction in the called procedure than to learn S/360 mnemonics, but it
actually saves the registers. makes hand assembly very difficult.
Although the author talks about opcodes
A standard scheme for parameter and other elements of machine code
passing is normally used in the S/360 early in his 8088 assembly language
environment. The calling program es- course, he postpones description of
tablishes a block of parameter addresses machine code formats until late in the
and puts the address of this block in course, and even then does little hand
register 1. The called procedure must assembly.
then go through a two-step sequence to
first get a parameter address and then Macros and conditional assembly are
retrieve the corresponding parameter often topics in an assembly language
value. There is no single scheme for course. The IBM assembler includes
parameter passing in the Intel 80x86 incredibly large, complex facilities to
environment. One must teach several implement macros and conditional assem-
representative techniques: using the bly. The Microsoft Macro Assembler
stack to pass values or addresses of (MASM) has been a de facto standard
values, using registers for values or for 80x86 assemblers; its facilities for
addresses, etc. The S/360 technique is macros and conditional assembly are not
rigid and complicated, while the Intel as elaborate as IBM’s, but are adequate
80x86 schemes are simpler but confusing for most uses. MASM’s macro facilities
because of the variety of possibilities. are much easier to teach and learn than
the IBM assembler’s macro facilities.
Language Syntax and Machine Code
Reference Materials and Textbooks
“Hand assembly” is often covered in
an S/360 assembly language course. There is a standard set of reference
That is, students are taught how to materials for an S/360 assembly
convert assembly language statements language course. Principles of Opera-
into object code. This is fairly simple tion [2] tells exactly how instructions
since there are only five commonly-used work. The Assembler Language manual
object code formats, and each instruc- [3] describes the syntax of the language
tion mnemonic corresponds to exactly and the operation of the assembler.
one format starting with a fixed opcode Finally, the System/370 Reference
for that mnemonic. For example, the Summary [4] is a pocket-sized reference
addition instruction AR 2,3 has RR with all the information needed to write
format and hex opcode 1A; it can easily most assembly language programs.
be translated by hand to the object Beginning assembly language students
code IA23. IBM S/360 assembly receive valuable help from the Reference
language uses distinct mnemonics for

119
Summary, and they find Principles of system. In addition, the student has
Operation and the Assembler Language the satisfaction of having total control
manual useful as they advance. over a personal computer, a situation
which is rarely possible with a main-
Reference materials for Intel 80x86 frame system.
systems and assembly language are not
as definitive as the IBM S/360 materials. References
The Intel iAPX 88 Book [5] describes
how the 8088 instructions work. The [l] ACM Curriculum Committee
Microsoft Macro Assembler 5.1 Program- Computer Science, “Curriculum ‘k:
mer’s Guide [ 61 describes the syntax of Recommendations for the Undergraduate
the Microsoft dialect of 80x86 assembly Program in Computer Science,” Communi-
language and the operation of the cations of the ACM, volume 22, number
Microsoft assembler. These are useful 3, March 1979, pp 147-166.
in an assembly language course.
Although Intel makes available a [ZJ IBM System/370 Principles of Opera-
Programmer’s Pocket Reference Guide tion, IBM order number GA22-7000.
[71, students find it confusing. The
small reference book [8] which comes [3] IBM OS/VS - DOS/VSE - VM/370 As-
with the Microsoft Macro Assembler is sembler Language, IBM order number
more useful. GC33-4010.

Because S/360 assembly language [4] IBM System/370 Reference Summary,


has been taught so often in “CS3” and IBM order number GX20-1850.
because S/360 assembly language has
changed so little through the years, [5] The Intel iAPX 88 Book, published
there are many mature, high-quality for Intel by Reston Publishing Company,
textbooks available to teach an S/360 Inc., 1983.
assembly language course. For a period
after the IBM PC was introduced, the [ 63 MicrosoftGuy;zro Assembler 5.1 Pro-
only assembly language books other grammer’s ’ , Microsoft Part No.
, than the manuals listed above were 01506.
trade books written for hobbyists
rather than for classroom use, This [7] 8086/8088/8087/80186/80188 Program-
situation has improved, and there are mer’s Pocket Reference Guide, Intel
now several acceptable textbooks from Order Number 231017-001.
which to choose,
[8 3 Microsoft Macro Assembler 5.1 Refer-
Conclusions ence, Microsoft Part No. 04696.

Assuming that the objectives in an


assembly language course are to provide
basic concepts of computer systems, to
introduce computer architecture, and to
teach an assembly language, a course
teaching Intel 80x86 assembly language
is just as effective as a course teaching
IBM S/360 assembly language. There
are more similarities than differences in
the two courses. Some concepts are
more easily taught in an S/360 environ-
ment, but the author believes that it is
simpler overall to teach and learn
assembly language using an 80x86

You might also like