9 Instruction Set Contd. With sample prog.
5). Stack,I/O and Machine control instructions:
- N port-address. (Input to accumulator from I/O port) [A] <-- [Port]
- OUT port-address (Output from accumulator to I/O port) [Port] <-- [A]
- PUSH rp (Push the content of register pair to stack)
- PUSH PSW (PUSH Processor Status Word)
- POP rp (Pop the content of register pair, which was saved, from the stack)
- POP PSW (Pop Processor Status Word)
- HLT (Halt)
- XTHL (Exchange stack-top with H-L)
- SPHL (Move the contents of H-L pair to stack pointer)
- EI (Enable Interrupts)
- DI (Disable Interrupts)
- SIM (Set Interrupt Masks)
- RIM (Read Interrupt Masks)
- NOP (No Operation).
Sample programs of instruction sets:
1).program for adding two 8 bit numbers.
// Load accumulator from memory address
// Move the content from accumulator to B
// Load accumulator from memory address 1001H
// Add the content of B to accumulator and store the result in accumulator
// Store the content of accumulator in memory location 1002H
Another assembly language instruction sequence to solve the same problem.
// Load lower order byte of address to register
// Load higher order byte of address to register
// Move the contents of memory location addressed by pair to
// Load the accumulator from memory location
// Add the content of to accumulator
// Store the content of accumulator to memory location
1).program for Multiplying two 8 bit numbers.
MVI A,00 // Load immediate data into accumulator.
MVI B,02// Load immediate data into register B.
MVI C,04// Load immediate data into register C.
LOOP: ADD B // Add the content of to accumulator.
DCR C // Decrement the content of register C by 1.
STA 1051H// Store the content of accumulator to memory location 1051H
HLT // Halt.