- 2073 Bhadra · 4 marks
DAA, SPHL, XTHL, PCHL instructions
Short answer
DAA adjusts accumulator after BCD addition by conditionally adding 06H/60H if nibbles >9 or carry. SPHL copies HL to SP. XTHL exchanges HL with top of stack without changing SP. PCHL loads PC with HL for computed jumps.
Explain the following instructions with example program: (i) DAA (ii) SPHL (iii) XTHL (iv) PCHL
(i) DAA: Decimal Adjust Accumulator
After adding two packed BCD numbers with a binary ADD, DAA converts the result in A to a valid BCD result. It adds 06H if the low nibble is greater than 9 or AC = 1, and then adds 60H if the high nibble is greater than 9 or CY = 1. All flags are affected. (1 byte, 4T)
MVI A,38H ; BCD 38
ADI 45H ; BCD 45 -> A = 7DH (binary sum)
DAA ; low nibble D > 9, add 06H -> A = 83H (BCD 83)
HLT
(ii) SPHL
Copies the content of the HL pair into the stack pointer: SP <- HL. No flags are affected. (1 byte, 6T)
LXI H,27FFH ; HL = 27FFH
SPHL ; SP = 27FFH (stack initialised)
(iii) XTHL
Exchanges HL with the top of the stack: L <-> M[SP], H <-> M[SP+1]. SP does not change. No flags are affected. (1 byte, 16T)
LXI SP,3000H
LXI H,1234H ; H = 12H, L = 34H
XTHL ; if M[3000H]=78H, M[3001H]=56H:
; then HL = 5678H, M[3000H]=34H, M[3001H]=12H
(iv) PCHL
Loads PC with the contents of HL: PC <- HL, so the next instruction is fetched from the address in HL (a computed jump). No flags are affected. (1 byte, 6T)
LXI H,3000H ; HL = 3000H
PCHL ; PC = 3000H, execution continues at 3000H
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- PC and SP in CALL, RET, PUSH, POP · Microprocessor, chapter 2
- Interfacing 2732 EPROM and 6116 RAM · Microprocessor, chapter 4
- Addressing modes in given instructions · Computer Organization and Architecture, chapter 2
- RMR class IV support and excavation · Engineering Geology II, chapter 6 · asked 6×
- Valid lossless function; Foster II and Cauer II · Filter Design, chapter 4 · asked 2×
- ADC804 with 8255 control word and program · Instrumentation II, chapter 4