Download presentation
Presentation is loading. Please wait.
Published byLoren Miles Modified over 9 years ago
1
CIS 020 Assembly Programming Chapter 11 - Binary Operations Using RX-Format Instructions © John Urrutia 2012, All Rights Reserved.5/27/20121
2
Objectives Familiarization with the General Purpose Registers Syntax & Use of some RX-Format instructions Conversion to Binary format from Decimal format Conversion to Decimal format from Binary format Boundary Alignment © John Urrutia 2012, All Rights Reserved.25/27/2012
3
General Purpose Registers As we will see there are multiple instructions that do the similar things Register instructions are the most efficient because they are part of the CPU In the 390 architecture there are: 16 General Purpose Register 16 Control Registers 16 Floating Point Registers Most programs only use the General Purpose Registers © John Urrutia 2012, All Rights Reserved.35/27/2012
4
General Purpose Registers Each Register is internally designated by 1 hexadecimal digit. ( 0 – F ) The Assembler recognizes registers in context by numeric values. ( 0 – 15 ) To help prevent confusion with numeric values we generally identify registers with R0 – R15. This is done with the assembly Macro EQUREGS that uses the equate assembler directive. © John Urrutia 2012, All Rights Reserved.45/27/2012
5
General Purpose Registers Each register is 4 bytes long, however we will see later that we can pair registers together to form 8 bytes. Instructions that use Registers directly, come in 3 basic formats. RR – Register to Register RX – Register to Indexed Storage RS – Register to Storage In this chapter we concentrate on the RX format © John Urrutia 2012, All Rights Reserved.55/27/2012
6
Review of Data Representation We have already explored Character & Decimal format. Character format is used for displayable text and includes A – Z, a – z, 0 – 9 (Standard letters & numerals) '-!"#$%&()*,./:;?@[\]^_`{|}~+ (Special Characters) Control characters Decimal format is used for arithmetic operations and is stored in the Packed Decimal format Character = Hexadecimal = Packed Decimal C’012345’ X’F0F1F2F3F4F5’ X’012345F’ © John Urrutia 2012, All Rights Reserved.65/27/2012
7
Review of Data Representation Packed Decimal format, negative numbers are represented by the last character byte Character = Hexadecimal = Packed Decimal C’01234N’ X’F0F1F2F3F4D5’ X’012345D Binary format is used primarily for addressing and calculations. Each byte has 8 bits and each bit has an ordinal value. The above numeric value is 64+4+2 = 70 Hex = X’46’, Packed = X’070F’, Character = C’70’ © John Urrutia 2012, All Rights Reserved.75/27/2012 1286432168421 01000110
8
Review of Data Representation Binary format is always a series of ones & zeros So to convey a 4 byte value like “BULL” in binary Convert each character to it’s binary equivalent Combine in sequence the 4 conversions and Spew forth the answer: 11000010111001001101001111010011 There’s got to be a better way, Which is to use hexadecimal to convey the binary equivalent C2E4D3D3 © John Urrutia 2012, All Rights Reserved.85/27/2012
9
Review of Data Representation Binary numbers are a bit strange Rule 1 : If the high-order bit is on the number is negative If the high-order bit is off the number is positive Rule 2 : Negative numbers are stored as 2 ’s complement of the positive number Take the positive binary number Complement the bits Add 1 © John Urrutia 2012, All Rights Reserved.95/27/2012
10
Review of Data Representation Examples © John Urrutia 2012, All Rights Reserved.105/27/2012
11
Review of Data Representation Binary data will generally be aligned to specific addresses. All of which are even numbers. D – Doubleword – 8 Bytes long, address is a multiple of 8 F – Fullword – 4 Bytes long, address is a multiple of 4 H – Halfword – 2 Bytes long, address is a multiple of 2 The Assembler will automatically align to these addresses by padding with slack bytes When defining constants the binary equivalent of the decimal number will be stored. © John Urrutia 2012, All Rights Reserved.115/27/2012
12
Register to Indexed Storage There are 47 RX instructions All RX instructions are 4 bytes long with the following syntax © John Urrutia 2012, All Rights Reserved.125/27/2012 RXOp CodeR1X2B2 0-78-1112-1516-19 20-31 D2 First HalfwordSecond Halfword
13
Register to Indexed Storage The Load instruction Loads 4 consecutive bytes into the specified register. Parameter should be on a fullword boundary. Failure to do this will slow down the instruction © John Urrutia 2012, All Rights Reserved.135/27/2012
14
Register to Indexed Storage The Store instruction Stores the specified register into 4 consecutive bytes. Parameter should be on a fullword boundary. Failure to do this will slow down the instruction © John Urrutia 2012, All Rights Reserved.145/27/2012
15
Register to Indexed Storage The Add instruction Adds 4 consecutive bytes to the specified register. Parameter should be on a fullword boundary. Failure to do this will slow down the instruction © John Urrutia 2012, All Rights Reserved.155/27/2012
16
Register to Indexed Storage The Add instruction When Adding, no Overflow or Underflow will occur. Condition Code 3 is set if there is a carry out of the high- order bit. If the program mask has been set to recognize a fixed- point exception. The Fixed-point overflow exception occurs. © John Urrutia 2012, All Rights Reserved.165/27/2012
17
Register to Indexed Storage The Subtract Instruction Subtract behaves the same as the Add instruction except Operand 2 is subtracted from the general purpose register in operand 1. © John Urrutia 2012, All Rights Reserved.175/27/2012
18
Register to Indexed Storage The index value in an RX instruction X2 – is the general purpose register temporarily added to the base register along with the displacement to resolve the Operand 2 address. Any value from 1 through 15 can be used By default X2 is set to zero which is treated as a NOP. © John Urrutia 2012, All Rights Reserved.185/27/2012
19
Convert to Binary All data must be in a binary format when using registers. CVB – Convert To Binary, takes packed decimal values and stores them in a register in binary format Op. 2 must be PL8 and on a Doubleword Boundary © John Urrutia 2012, All Rights Reserved.195/27/2012
20
Convert to Decimal CVD – Convert To Decimal, takes a register in binary format and stores it in packed decimal format. Op. 2 must be PL8 and on a Doubleword Boundary © John Urrutia 2012, All Rights Reserved.205/27/2012
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.