Assembler Language I
Assembler Language I
"Boot Camp"
Part 1 - Numbers and
Basic Arithmetic
SHARE in Minneapolis
July 22 - 27, 2001
Session 8181
1
Introduction
Who are we?
2
Introduction
Who are you?
An applications programmer who needs to write
something in S/390 assembler?
An applications programmer who wants to
understand S/390 architecture so as to better
understand how HLL programs work?
A manager who needs to have a general
understanding of assembler?
4
Introduction
The original ASSIST (Assembler System for
Student Instruction and Systems Teaching) was
written by John R Mashey at Penn State University
8
Today's Agenda
Decimal, Binary and Hexadecimal Numbers and
Conversions
9
Decimal, Binary and
Hexadecimal
Numbers and
Conversions
In Which We Learn to Count
All Over Again
10
Counting in Bases 10, 2, and 16
Dec Bin Hex Dec Bin Hex
0 0000 0 8 1000 8
1 0001 1 9 1001 9
2 0010 2 10 1010 A
3 0011 3 11 1011 B
4 0100 4 12 1100 C
5 0101 5 13 1101 D
6 0110 6 14 1110 E
7 0111 7 15 1111 F
16 10000 10 11
Numbers in Different Bases
Consider how we write numbers in base 10, using
the digits 0 - 9:
83210 = 80010 + 3010 + 210
= 8 x 102 + 3 x 101 + 2 x 100
1011 = ?10
10112 = 1110
101116 = 411310
2
A6116 = 10 x 16 = 10 x 256 = 2560
1
+ 6 x 16 = 6 x 16 = 96
0
+ 1 x 16 = 1 x 1 = 1
2657
15
Example: Convert 12310 to Base 16
123 / 16 = 7 with remainder 11, so the rightmost
digit is B
18
Arithmetic with Unsigned Numbers
Addition and subtraction of unsigned numbers is
performed in hexadecimal and binary just the
same as it is in decimal, with carries and borrows
19
Arithmetic with Unsigned Numbers
1101 <--- carries 11110 <--- carries
FCDE 10110
+ 9A05 + 1011
196E3 100001
20
Main Storage
Organization and
Signed Binary
Numbers
21
Main Storage Organization
In order to understand how signed numbers are
represented in a binary computer, we need first
to understand memory organization
So
One byte = eight bits
One word = four bytes = 32 bits
23
Main Storage Organization
Typically, each of these aggregates is aligned on an
address boundary which is evenly divisible by its
size in bytes
24
Representation of Signed Binary
Integers
Representing unsigned binary integers was fairly
simple, but how can we include a sign?
If we use one bit for the sign, then since 910 is 10012,
we would write +9 as 0 10012 and -9 as 1 01102
26
Representation of Signed Binary
Integers
The two's complement representation is formed
by taking the ones' complement and adding 1
28
Representation of Signed Binary
Integers: Examples
31
-2 is represented by 1000...000 but this number
is not the two's complement of any positive
integer
30
Arithmetic with Signed Numbers
Let's look at examples of addition and subtraction
using signed numbers in two's complement. These
examples use only 4 bits, one for sign, three for value.
+3 = 0 011
+2 = 0 010
+5 0 101
+3 = 0 011
-2 = 1 110 (Two's complement of 0 010)
+1 0 001 (Note that the carry out is ignored)
31
Arithmetic with Signed Numbers
Now, how about -3 plus +2:
-3 = 1 101
+2 = 0 010
-1 1 111
F89ABCDE F89ABCDE
-6D4AFBC0 = +92B50440 (Add 2's comp)
8B4FC11E
Note that carry bits are discarded (result is correct
anyway) 33
Overflow
What if two large numbers are added and the
31 31
result is greater than 2 -1 (or less than -2 )?
38
ASSIST/I Features
ASSIST/I is an integrated assembler and instruction
interpreter, plus a text editor and interactive
debugger
39
ASSIST/I Features
It is a useful tool for getting started and "tinkering"
on a PC without needing any host-system access
40
ASSIST/I Limitations
ASSIST/I supports only an older, less-rich
instruction set
42