ALP examples
ALP examples
Opcod
Operand Description
e
Rd,Rs
MOV M,Rs Copy from source to destination
Rd,M
Rd,Data
MVI Move immediate 8-bit
M,Data
Top
1) MOV instruction:
This instruction copies the contents of the source register into
the destination register. The contents of the source register are not
altered.If one of the operands is a memory location, its location is
specified by the contents of the HL registers.These instructions are
of one byte instruction and no flag is affected in these instructions.
where reg = A, B, C, D, E, H or L
This instruction is moves / copies the data in the given register to the
given register.
i.e
This instruction moves / copies the data in the given register to the
memory location addressed by H-L register pair.
i.e
M-
Operand Bytes Flags Affected T-States
Cycles
Rd,Rs 1 None 1 4
Rd,M 1 None 2 7
M,Rs 1 None 2 7
2) MVI instruction:
MVI M,2B
M-
Operand Bytes Flags Affected T-States
Cycles
Rd,data 2 None 2 7
M,data 2 None 3 10
3) LDA instruction:
LDA 2500H
4) LDAX instruction:
LDAX B
LDAX D
5) LXI instruction:
where rp = BC,DE,HL
LXI H,F850H
Reg. pair,16-bit
3 None 3 10
data
6) LHLD instruction:
LHLD 2100 H
after the execution of the instruction LHLD 2100 H , the L-register will
have 2A H and H-register will have 2B H.
STA 2100 H
8) STAX instruction:
STAX B
STAX D
STAX B
9) SHLD instruction:
SHLD 2200 H
[M2200H] < - 3A
[M2201H] < - 3B
XCHG
M-
Operand Bytes Flags Affected T-States
Cycles
None 1 None 1 4
SPHL
after the execution of the instruction SPHL will result SP = 2345 H.
[SP] < - > [HL] i.e. [SPH] < - > [H] and [SPL] < - > [L]
M-
Operand Bytes Flags Affected T-States
Cycles
None 1 None 1 6
This is mnemonic for Exchanges the top of the stack with H-L
register pair.The XTHL is one byte instruction and does not require any
operand. The top byte of the stack is exchanged with L-register and
next byte of the stack is exchanged with H-register.
M-
Operand Bytes Flags Affected T-States
Cycles
None 1 None 5 16
XTHL
as shown in figure
PCHL
[PC] < - > [HL] i.e. [PCH] < - > [H] and [PCL] < - > [L]
M-
Operand Bytes Flags Affected T-States
Cycles
None 1 None 1 6
where rp = BC,DE,HL,PSW
PUSH rp
T-
Operand Bytes Flags Affected M-Cycles
States
PUSH H
as shown in figure
where rp = BC,DE,HL,PSW
POP rp
T-
Operand Bytes Flags Affected M-Cycles
States
POP D
This is mnemonic for Outputs the data to the port.This two byte
output instruction is used to send the contents of accumulator to the
specified port.
OUT port
8-bit port
2 None 3 10
address
17) IN instruction:
IN port
8-bit port
2 None 3 10
address
2). Write assembly language program to find number of 1's and 0's in 8-
bit number stored at 2010 memory address.
Solution:
Solution:
Solution: