100% found this document useful (3 votes)
6K views

Sap 3 Architecture

DOWLOAD HERE: http://adf.ly/aJVg0 ====== CENG03, COMPUTER SYSTEM ARCHITECTURE, SAP3, programming model, arithmetic instructions, carry flag instructions. add instructions. adc instructions, add with carry, sub instructions, sbb instructions, subtract with borrow, increments, decrements, rotate, rotate all left, ral, rotate all right, rar, rotate left with carry, rlc, rotate right with carry, rac, multiply and divide by 2, carry flag, sign flag, zero flag, examples, esquivelazzej ----- credits to Engr. J. R.
Copyright
© Attribution Non-Commercial (BY-NC)
100% found this document useful (3 votes)
6K views

Sap 3 Architecture

DOWLOAD HERE: http://adf.ly/aJVg0 ====== CENG03, COMPUTER SYSTEM ARCHITECTURE, SAP3, programming model, arithmetic instructions, carry flag instructions. add instructions. adc instructions, add with carry, sub instructions, sbb instructions, subtract with borrow, increments, decrements, rotate, rotate all left, ral, rotate all right, rar, rotate left with carry, rlc, rotate right with carry, rac, multiply and divide by 2, carry flag, sign flag, zero flag, examples, esquivelazzej ----- credits to Engr. J. R.
Copyright
© Attribution Non-Commercial (BY-NC)
You are on page 1/ 5

SAP 3

SAP3 instruction set includes all the SAP 2 instructions plus new instructions. SAP 3 Programming Model
A FC SL B D H C E L F

CARRY FLAG INSTRUCTIONS Note: There are two instructions that can be used to control the carry flag. 1. STC - SET CARRY - will set the CY flag if it is not set e.g. if CY=0, STC produces CY=1 2. CMC - COMPLEMENT THE CARRY - complements the value of CY

Note: The additional CPU registers, D, E, H and L are used for more efficient data processing. The F register stores flag bits: S (sign flag), Z (zero flag) and others. ADVANTAGE OF MORE CPU REGISTERS 1. Programs can run faster 2. Simplifies program writing ARITHMETIC INSTRUCTIONS Example 1:

ADD INSTRUCTIONS

ADD REG

A = 1111 0001 E = 0000 1000


Solution:
1111 0001 + 0000 1000 1111 10001

Answer:
CY=0 A=1111 1001

Example 2: Note: CY = CARRY if operation is ADD CY = CARRY if operation is SUB Note: The 8-bit sum S7S0 is stored in the accumulator. The CY is stored in a special FF called CARRY FLAG. CY A7 A6 A5 A2 A1 A0

A = 1111 1111 L = 0000 0001


Solution:
1111 1111 + 0000 0001 1 0000 0000

Answer:
CY= 1 A=0000 0000

Note: The CY flag acts like the next higher bit of the accumulator, i.e. CY = AB

CENG03. COMPUTERSYSTEM ARCHITECTURE. SAP 3. esquivelazzej

ADC INSTRUCTIONS (ADC = Add with carry)

Example 2:

ADD REG
Example 1:

A = 0000 1100 C = 0001 0010


Solution:
0000 1100 - 0001 0010 1 1111 1010

A = 1000 0011 E = 0001 0010 CY = 1


Solution:
1000 0011 + 0001 0010 1 1001 0110

Answer:
CY=1 A=1111 1010

Answer:
CY=0 A=1001 0110 SBB INSTRUCTIONS (SBB = Subtract with borrow) Note: It subtracts the contents of a specified register and the CY flag from the accumulator contents. SUB INSTRUCTIONS Example 1:

SUB REG
Example 1:

A = 1111 1111 E = 0000 0010 CY = 1


Solution:
1111 1111 0000 0010 1 1111 1100

A = 0000 1111 C = 0000 0001


Solution:
0000 1111 - 0000 0001 0000 1110

Answer:
CY=0 A=1111 1100

Answer:
CY=0 A=0000 1110

CENG03. COMPUTERSYSTEM ARCHITECTURE. SAP 3. esquivelazzej

INCREMENTS

ROTATE ALL LEFT (RAL)

INR REG
Note: The INR instruction has no effect on the carry flag, but it does affect the sign flags and zero flags. Example 1:

CY

MSB

LSB

Note: The CY flag is included in the rotation of bits. Example 1:

B = 1111 1111, and The initial flags are S=1, Z=0, CY=0
Answer:
B = 0000 0000 S=0, Z=1, CY=0

CY = 1 A = 0111 0100
Answer:
CY=0 A = 1110 1001

DECREMENTS

DEC REG
Example 1:

ROTATE ALL RIGHT (RAR)

E = 0000 0000 S=0, Z=1, CY=0


Answer:
E = 1111 1111 S=1, Z=0, CY=0

CY

MSB

LSB

Note: The CY flag is included in the rotation of bits. Example 1:

CY = 1 A = 0111 0100
Answer:
CY=0 A = 1011 1010

CENG03. COMPUTERSYSTEM ARCHITECTURE. SAP 3. esquivelazzej

ROTATE LEFT WITH CARRY (RLC)

MULTIPLY AND DIVIDE BY 2 Uses of rotate instructions: 1. Parallel to serial and serial to parallel conversion of data. 2. Has the effect of multiplying or dividing the accumulator contents by a factor of 2. Note: With the carry flag reset, a RAL has the effect of multiplying by 2, while the RAR divides by 2.

CY

MSB

LSB

Note: This instruction will rotate the contents of the accumulator to the left and the MSB is saved in the CY flag. Example 1:

CY = 1 A = 0111 0100
Answer:
CY=0 A = 1110 1000

Example 1:

RAL
CY = 0 A = 0000 0111
Answer:
CY=0 A = 0000 1110 ROTATE RIGHT WITH CARRY (RRC)

Example 2:

CY

MSB

LSB

RAL
CY = 0 A = 0010 0001
Answer:
CY=0 A = 0100 0010

Note: The LSB is saved in the CY flag. Example 1:

CY = 1 A = 0111 0100
Answer:
CY=0 A = 0011 1010

CENG03. COMPUTERSYSTEM ARCHITECTURE. SAP 3. esquivelazzej

Example 3:

Example program:

RAR
CY = 0 A = 0001 1000
Answer:
CY=0 A = 0000 1100

Show a SAP 3 program that adds 700 and 400, with the final answer stored in the H ad L registers.

INSTRUCTION

Example 3:

RAR
CY = 0 A = 0000 1100
Answer:
CY=0 A = 0000 0110

MVI 00H MVI 02H MVI BCH MVI O3H MVI 84H ADD ADD MOV MVI 00H

A, B, C, D, E, C E L, A A,

ADC B ADD D MOV H, A HLT

CENG03. COMPUTERSYSTEM ARCHITECTURE. SAP 3. esquivelazzej

You might also like