SAP-2
- architectural differences with SAP-1
- bidirectional registers
- instruction set
- flags
Architectural Changes
- Jump Instructions: loadable PC
- 16-bit program counter
- 8-bit opcode, 42 instructions
- 2 input ports, 2 output ports
- 2K ROM, up to 62K RAM (16-bit addresses) with read and write
- memory data register (MDR) buffers reads and writes
- accumulator can write to bus
- tmp, B, and C registers
- 16 arithmetic and logic operations in ALU
- sign and zero flag
Bidirectional registers
- connect the inputs to the outputs
- load and enable never simultaneously active
- on load, outputs are 3-state, input is taken from the bus
- on enable, inputs are ignored, output goes to the bus
- 1/2 as many pins
- 1/2 as much bus capacitance
Instruction Set
- same fetch cycle (T1, T2, T3) as SAP-1
- memory reference instructions: LDA, STA (3 bytes, lower byte before
higher byte)
- immediate instructions: MVI reg, value (2 bytes)
- register instructions: MOV, ADD and SUB, INR and DCR,
ANA, ORA, XRA, CMA (1 byte), ANI, ORI, XRI (2 bytes)
- jump and call instructions: JMP, JM, JZ, JNZ, CALL (3 bytes),
RET (1 byte)
- CALL saves return address in memory FFFEH and FFFFH
- NOP, HLT, RAL, RAR (1 byte), IN, OUT (2 bytes)
In-Class Exercise 1
- hand-assemble the following program starting at address 2000H
- opcodes are: IN is DBH,
"MOV B,A" is 47H,
"DCR A" is 3DH,
"MOV C,A" is 4FH,
"ANA B" is A0H,
"MOV A,C" is 79H,
JNZ is 79H
- what does the program do?
START IN 01H
LOOP MOV B,A
DCR A
MOV C,A
ANA B
MOV A,C
JNZ LOOP
DONE
Flags
- 2 flip flops, sign flag and zero flag
- set during arithmetic and logic
operations to reflect final accumulator contents
- JM jumps only if the sign flag is set (minus result)
- JZ jumps only if the zero flag is set (zero result)
- JNZ jumps if the zero flag is clear (non-zero result)
- what is the value of the sign bit if the accumulator contents are zero?
In-Class Exercise 2
- work in groups of up to 3
- design a circuit to implement the flags
- inputs are: 8 bits from the accumulator, clock (use the
positive-going edge), 1 LF control line (active high)
- outputs are the flags: ZF, SF