KS57C2308/P2308/C2316/P2316

SAM47 INSTRUCTION SET

 

 

XCHD — Exchange and Decrement

XCHD Operation:

dst,src

Operand

Operation Summary

Bytes

Cycles

 

 

 

 

A,@HL

Exchange A and data memory contents; decrement

1

2 + S

 

contents of register L and skip on borrow

 

 

 

 

 

 

Description: The instruction XCHD exchanges the contents of the accumulator with the RAM location addressed by register pair HL and then decrements the contents of register L. If the content of register L is 0FH, the next instruction is skipped. The value of the carry flag is not affected.

Operand

 

 

Binary Code

 

 

Operation Notation

 

 

 

 

 

 

 

 

 

 

A,@HL

0

1

1

1

1

0

1

1

A (HL), then L L–1;

 

 

 

 

 

 

 

 

 

skip if L = 0FH

 

 

 

 

 

 

 

 

 

 

Example: Register pair HL contains the address 20H and internal RAM location 20H contains the value 0FH:

 

LD

HL,#20H

 

 

LD

A,#0H

 

 

XCHD

A,@HL

; A 0FH and L L – 1, (HL) "0"

 

JPS

XXX

; Skipped since a borrow occurred

 

JPS

YYY

; H 2H, L 0FH

YYY

XCHD

A,@HL

; (2FH) 0FH, A (2FH), L L – 1 = 0EH

 

 

 

 

 

 

 

 

 

The “JPS YYY” instruction is executed since a skip occurs after the XCHD instruction.

5-91

Page 165
Image 165
Samsung KS57C2308 manual Xchd Exchange and Decrement, Xchd Operation, YYY Xchd @HL