03 Instructions and Programming 1
03 Instructions and Programming 1
– ACCH 0
Syntax
;0≤n≤7
; 0 SHIFT2 7
• During the left shift, the lower order bits are 0 filled but
higher order bits are lost.
• ACC remains unaffected after the execution of SACL.
Instructions & Programming 1 – Manish Tiwari 7
SACL (Contd.)
• Ex. 1 SACL *+, 0, AR7
– Store ACCL indirectly without left shift in memory, after
the memory operation increment current AR by 1 and then
change the current AR to AR7.
Syntax
Syntax
Direct: SAR ARx, dir ; 0 ≤ dir ≤ 127
ARP 4 1
ARB 7 4
• Ex. 2 MAR *+, AR5
After
Before Instruction
Instruction
AR1 34H 35H
ARP 1 5
ARB 7 1
Instructions & Programming 1 – Manish Tiwari 30
Example Program 4
• Write a program to copy a data word from memory
location 020AH to 020BH using indirect addressing.
.entry LACL *+
LAR AR0, #020AH // AR0 Memory Location
020AH.
MAR *, AR0 // Set AR0 as current AR.
LACL * // Read from 020AH.
MAR *+ // Increment AR0 i.e. AR0 020BH.
SACL * // Store at 020BH.
.end
Instructions & Programming 1 – Manish Tiwari 31
Alternate Program 4
• Write a program to copy a data word from memory
location 020AH to 020BH using indirect addressing.
.entry
LAR AR0, #020AH // AR0 Memory Location
020AH
MAR *, AR0 // Set AR0 as current AR.
LACL *+ // Read from 020AH and Increment
AR0.
SACL * // Store at 020BH.
.end
Instructions & Programming 1 – Manish Tiwari 32
ADRK & SBRK
• ADRK #k ; 0≤ k ≤ 255
Add a small immediate or short constant to current
AR.
– Current AR Current AR + k
• SBRK #k ; 0≤ k ≤ 255
Subtract a small immediate or short constant from
current AR.
– Current AR Current AR - k
ARP 1 5
• Ex. 1
– LACC #2050H; ACCL 2050h
– BACC ; Jump to program location 2050H.
ARP 0 0
AR0 1 0
PC 2050H 191H
ARP 0 5
AR0 1 2
PC 2050H 191H
ARP 0 0
AR0 0 FFFFH
PC 2050H 2052H
0060H D0 0160H XX
0061H D1 0161H XX
0062H D2 0162H XX
0063H D3 0163H XX
• Ex. 1
– BCND 191H, LEQ, C
– Branch to program location 191H if ACC 0 and CY = 1.
ACC = 0 EQ CY = 0 NC
ACC 0 NEQ CY = 1 C
ACC 0 LEQ OV = 1 OV
ACC 0 GEQ TC = 1 TC