Computer Architecture
Computer Architecture
Computer Architecture
Acumulator :It is a 8-bit register which is used to perform airthmetical and logical
operation. It stores the output of any operation. It also works as registers for i/o
accesses.
Temporary Register :It is a 8-bit register which is used to hold the data on which
the acumulator is computing operation. It is also called as operand register because
it provides operands to ALU.
Registers:These are general purposes registers. Microprocessor consists 6 general
purpose registers of 8-bit each named as B,C,D,E,H and L. Generally theses
registers are not used for storing the data permanently. It carries the 8-bits data.
These are used only during the execution of the instructions.
These registers can also be used to carry the 16 bits data by making the pair of 2
registers. The valid register pairs available are BC,DE HL. We can not use other pairs
except BC,DEand HL. These registers are programmed by user.
ALU:ALU performs the airthmetic operations and logical operation.
Flag Registers :It consists of 5 flip flop which changes its status according to the
result stored in an accumulator. It is also known as status registers. It is connected
to the ALU.
There are five flip-flops in the flag register are as follows:Sign(S), zero(z),Auxiliary
carry(AC),Parity(P),Carry(C)
The bit position of the flip flop in flag register is:
D7
D6
D5
D4
D3
AC
D2
P
All of the three flip flop set and reset according to the stored result in the
accumulator.
1.Sign-If D7 of the result is 1 then sign flag is set otherwise reset. As we know that a
number on the D7 always desides the sign of the number. if D7 is 1: the number is
negative. if D7 is 0: the number is positive.
2.Zeros(Z)-If the result stored in an accumulator is zero then this flip flop is set
otherwise it is reset.
3.Auxiliary carry(AC)-If any carry goes from D3 to D4 in the output then it is set
otherwise it is reset.
4.Parity(P)-If the no of 1's is even in the output stored in the accumulator then it is
set otherwise it is reset for the odd.
5.Carry(C)-If the result stored in an accumulator generates a carry in its final output
then it is set otherwise it is reset.
Instruction registers(IR): It is a 8-bit register. When an instruction is fetched from
memory then it is stored in this register.
Instruction Decoder: Instruction decoder identifies the instructions. It takes the
informations from instruction register and decodes the instruction to be performed.
Program Counter :It is a 16 bit register used as memory pointer. It stores the
memory address of the next instruction to be executed. So we can say that this
register is used to sequencing the program. Generally the memory have 16 bit
addresses so that it has 16 bit memory. The program counter is set to 0000H.
Stack Pointer: It is also a 16 bit register used as memory pointer. It points to the
memory location called stack. Generally stack is a reserved portion of memory
where information can be stores or taken back together.
Timing and Control Unit: It provides timing and control signal to the
microprocessor to perform the various operation.It has three control signal. It
controls all external and internal circuits. It operates with reference to clock signal.It
D1
8085 is a 40 pin IC, The signals from the pins can be grouped as follows
1.
2.
3.
4.
5.
6.
During the opcode fetch operation, in the first clock cycle, the lines deliver
the lower order address A0 - A7.
In the subsequent IO / memory, read / write clock cycle the lines are used as
data bus.
The CPU may read or write out data through these lines.
This indicates that the selected memory location or I/O device is to be read
and that the data bus is ready for accepting data from the memory or I/O
device
S1
S0
OPERATION
Opcode fetch
Memory read
Memory write
I/O read
I/O write
Interrupt acknowledge
Halt
Hold
Reset
The data is transferred from the address pointed by the data in a register to other
register.
Eg: MOV A, M (data is transferred from the memory location pointed by the regiser to
the accumulator).
It has 8 parallel lines of data bus. So it can access upto 2^8 = 256 data bus lines.
Control Bus
The control bus is used for sending control signals to the memory and I/O devices.
The CPU sends control signal on the control bus to enable the outputs of addressed
memory devices or I/O port devices.
Some of the control bus signals are as follows:
1. Memory read
2. Memory write
3. I/O read
4. I/O write
Interrupts In 8085
what is Interrupt?
Interrupt is a mechanism by which an I/O or an instruction can suspend the normal
execution of processor and get itself serviced. Generally, a particular task is
assigned to that interrupt signal. In the microprocessor based system the interrupts
are used for data transfer between the peripheral devices and the microprocessor.
Interrupt Service Routine(ISR)
A small program or a routine that when executed services the corresponding
interrupting source is called as an ISR.
Maskable/Non-Maskable Interrupt
An interrupt that can be disabled by writing some instruction is known as Maskable
Interrupt otherwise it is called Non-Maskable Interrupt.
There are 6 pins available in 8085 for interrupt:
1. TRAP
2. RST 7.5
3. RST6.5
4. RST5.5
5. INTR
6. INTA
Execution of Interrupts
When there is an interrupt requests to the Microprocessor then after accepting the
interrupts Microprocessor send the INTA (active low) signal to the peripheral. The
vector address=2*8
= 16
RST1:
vector address=1*8
= 08
RST3:
vector address=3*8
= 24
Vector Address
RST0
RST1
0000H
0008H
RST2
0010H
RST3
0018H
RST4
RST5
0020H
0028H
RST6
RST7
0030H
0038H
Hardware Interrupt
As i have already discussed that there are 6 interrupt pins in the microprocessor
used as Hardware Interrrupts given below:
1. TRAP
2. RST7.5
3. RST6.5
4. RST5.5
5. INTR
Note:
INTA is not an interrupt. INTA is used by the Microprocessor for sending the
acknowledgement.TRAP has highest priority and RST7.5 has second highest priority
and so on.
The Vector address of these interrupts are given below:
Interrupt
Vector Address
RST7.5
003CH
RST6.5
0034H
RST5.5
002CH
TRAP
0024H
TRAP
It is non maskable edge and level triggered interrupt. TRAP has the highest priority
and vectores interrupt. Edge and level triggered means that the TRAP must go high
and remain high until it is acknowledged. In case of sudden power failure, it
executes a ISR and send the data from main memory to backup memory.
As we know that TRAP can not be masked but it can be delayed using HOLD signal.
This interrupt transfers the microprocessor's control to location 0024H.
TRAP interrupts can only be masked by reseting the microprocessor. There is no
Operand
Explanation of
Instruction
Description
NOP
none
No operation
No
operation
is
performed.
The
instruction is fetched and decoded.
However
no
operation
is
executed.Example: NOP
HLT
none
Halt and enter wait The CPU finishes executing the current
state
instruction
and
halts
any
further
execution. An interrupt or reset is
necessary
to exit from the halt
state.Example: HLT
DI
none
EI
none
RIM
none
SIM
none
LOGICAL INSTRUCTIONS
Opco
de
CMP
CPI
ANA
Operand Explanation of
Instruction
Description
R
M
Compare
register or
memory with
accumulator
8-bit
data
Compare
The second byte (8-bit data) is compared
immediate with with the contents of the accumulator.
accumulator
The values being compared remain
unchanged. The result of the comparison
is shown by setting the flags of the PSW
as follows:
if (A) < data: carry flag is set
if (A) = data: zero flag is set
if (A) > data: carry and zero flags are
reset
Example: CPI 89H
R
M
Logical AND
register or
memory with
accumulator
8-bit
data
Logical AND
The contents of the accumulator are
immediate with logically
ANDed
with
the
accumulator
8-bit data (operand) and the result is
placed
in
the
accumulator. S, Z, P are modified to
reflect
the
result
of
the
operation. CY is reset. AC is set.
Example: ANI 86H
XRA
R
M
Exclusive OR
register or
memory with
accumulator
XRI
8-bit
data
Exclusive OR
The contents of the accumulator are
immediate with Exclusive ORed with the 8-bit data
accumulator
(operand) and the result is placed in the
accumulator. S, Z, P are modified to
reflect the result of the operation. CY and
AC are reset.Example: XRI 86H
ORA
R
M
Logical OR
register or
memory with
accumulator
ORI
8-bit
data
Logical OR
The contents of the accumulator are
immediate with logically ORed with the 8-bit data
accumulator
(operand) and the result is placed in the
accumulator. S, Z, P are modified to
reflect the result of the operation. CY and
AC are reset.Example: ORI 86H
RLC
none
Rotate
Each binary bit of the accumulator is
accumulator left rotated left by one position. Bit D7 is
none
RAL
RAR
none
Rotate
Each binary bit of the accumulator is
accumulator left rotated left by one position through the
through carry
Carry flag. Bit D7 is placed in the Carry
flag, and the Carry flag is placed in the
least significant position D0. CY is
modified according to bit D7. S, Z, P, AC
are not affected.Example: RAL
Rotate
accumulator
right through
carry
none
Complement
accumulator
CMC
none
Complement
carry
STC
none
Set Carry
Set Carry
CMA
none
Rotate
accumulator
right
Example: STC
BRANCHING INSTRUCTIONS
Opcode
Operand Explanation of
Instruction
JMP
16-bit
address
Jump
unconditionally
Description
The
program
sequence
is
transferred to the memory location
specified by the 16-bit address
given in the operand.Example: JMP
2034H or JMP XYZ
16-bit
Flag
Opcod Descriptio
Statu address
e
n
s
JC
Jump on
Carry
JNC
Jump on CY =
no Carry 0
JP
Jump on
positive
S=0
JM
Jump on
minus
S=1
JZ
Jump on
zero
Z=1
JNZ
Jump on
no zero
Z=0
JPE
Jump on
parity
even
P=1
JPO
Jump on
parity
odd
P=0
Jump
conditionally
The
program
sequence
is
transferred to the memory location
specified by the 16-bit address
given in the operand based on the
specified flag of the PSW as
described below.
Example: JZ 2034H or JZ XYZ
Unconditional
subroutine call
The
program
sequence
is
transferred to the memory location
specified by the 16-bit address
given in the operand. Before the
transfer, the address of the next
instruction after CALL (the contents
of the program counter) is pushed
onto the stack.
Example: CALL 2034H or CALL XYZ
CY =
1
16-bit
Flag
Opcod Descriptio
Statu address
e
n
s
CC
Call on
Carry
CY =
1
CNC
Call on
CY =
no Carry 0
CP
Call on
positive
S=0
CM
Call on
minus
S=1
CZ
Call on
zero
Z=1
CNZ
Call on
no zero
Z=0
CPE
Call on
parity
even
P=1
CPO
Call on
parity
odd
P=0
RET
none
Flag none
Opcod Descriptio
Statu
e
n
s
RC
Return
CY =
on Carry 1
RNC
Return o
CY =
n no
0
Carry
RP
Return o
S=0
n positive
RM
Return o
S=1
n minus
RZ
Return o
Z=1
n zero
RNZ
Return o
Z=0
n no zero
RPE
Return o
n parity P = 1
even
RPO
Return o
n parity P = 0
odd
PCHL
none
Return from
subroutine
unconditionally
The
program
sequence
is
transferred from the subroutine to
the calling program. The two bytes
from the top of the stack are copied
into the program counter,and
program execution begins at the
new address.
Example: RET
Return from
subroutine
conditionally
The
program
sequence
is
transferred from the subroutine to
the calling program based on the
specified flag of the PSW as
described below. The two bytes
from the top of the stack are copied
into the program counter, and
program execution begins at the
new address.
Example: RZ
Load program
The contents of registers H and L
counter with HL are copied into the program
contents
counter. The contents of H are
placed as the high-order byte and
the contents of L as the low-order
byte.
Example: PCHL
RST
0-7
Restart
0000H
RST1
0008H
RST 2
0010H
RST 3
0018H
RST 4
0020H
RST 5
0028H
RST 6
0030H
RST 7
0038H
The 8085 has four additional
interrupts and these interrupts
generate RST instructions internally
and thus do not require any
external
hardware.
These
instructions
and
their
Restart
addresses are:
Interrup Restart
t
Address
Arithmetic Instructions
TRAP
0024H
RST
5.5
002CH
RST
6.5
0034H
RST
7.5
003CH
Opco
de
ADD
Operand Explanation of
Instruction
Description
R
M
ADC
R
M
ADI
8-bit
data
ACI
8-bit data Add immediate The 8-bit data (operand) and the Carry flag are
to accumulator added to the contents of the accumulator and
with carry
the result is stored in the accumulator. All
flags are modified to reflect the result of the
addition.
Example: ACI 45H
LXI
DAD
SUB
Subtract
register or
memory from
accumulator
R
M
Subtract source
and borrow
from
accumulator
SUI
8-bit
data
Subtract
The 8-bit data (operand) is subtracted from
immediate from the contents of the accumulator and the result
accumulator
is stored in the accumulator. All flags are
modified to reflect the result of the
subtraction.Example: SUI 45H
8-bit
data
Subtract
The contents of register H are exchanged with
immediate from the contents of register D, and the contents of
accumulator
register L are exchanged with the contents of
with borrow
register E.
Example: XCHG
R
M
Increment
register or
memory by 1
SBI
INR
INX
DCR
DCX
R
M
Increment
The contents of the designated register pair
register pair by are incremented by 1 and the result is stored
1
in the same place.Example: INX H
Decrement
register or
memory by 1
Decrement
The contents of the designated register pair
register pair by are decremented by 1 and the result is stored
1
in the same place.
Example: DCX H
DAA
none
Opco
de
MOV
Operand Explanation of
Instruction
Rd, Rs
M, Rs
Rd, M
Description
MVI
Rd, data Move immediate 8-bit The 8-bit data is stored in the
M, data
destination register or memory. If the
operand is a memory location, its
location is specified by the contents
of the HL registers.
Example: MVI B, 57H or MVI M, 57H
LDA
16-bit
address
Load accumulator
LDAX
LXI
Reg.
pair, 16bit data
LHLD
16-bit
address
Load H and L
registers direct
STAX
SHLD
XCHG
SPHL
16-bit
address
16-bit address
16-bit
address
none
none
Store H and L
registers direct
Exchange H and L
with D and E
Copy H and L
The instruction loads the contents of
registers to the stack the
H
and
L
registers
into
pointer
the stack pointer register, the
contents of the H register provide
the high-order address and the
contents of the L register provide the
low-order address. The contents of
the
H
and L registers are not altered.
Example: SPHL
XTHL
none
Exchange H and L
with top of stack
PUSH
POP
OUT
8-bit
port
address
IN
8-bit
port
address
Input data to
accumulator from a
port with 8-bit
address
Programs Level 1
1. Store 8-bit data in memory
2. Exchange the contents of memory locations
3. Add two 8-bit numbers
4. Subtract two 8-bit numbers
5. Add two 16-bit numbers
6. Add contents of two memory locations
7. Subtract two 16-bit numbers
8. Finding ones complement of a number
9. Finding Twos complement of a number
10.Pack the unpacked BCD numbers
11.Unpack a BCD number
12.Execution format of instructions
13.Right shift, bit of data( 8 bit and 16 bit)
14.Left Shifting of a 16-bit data
15.Alter the contents of flag register in 8085
1.
2.
Program 1:
MVI A, 52H : "Store 32H in the accumulator"
3.
4.
HLT
1.
Program 2:
2.
3.
4.
HLT
Note: The result of both programs will be the same. In program 1 direct addressing
instruction is used, whereas in program 2 indirect addressing instruction is used.
Program 1:
LDA 2000H : "Get the contents of memory location 2000H into accumulator"
3.
MOV B, A
4.
5.
6.
MOV A, B
7.
1.
Program 2:
2.
3.
4.
MOV B, M
5.
LDAX D
6.
MOV M, A
7.
MOV A, B
8.
STAX D
9.
HLT
Statement: Add the contents of memory locations 4000H and 4001H and place the
result in memory location 4002H.
1.
2.
Sample problem
(4000H) = 14H
3.
(4001H) = 89H
4.
Result
5.
6.
Source program
7.
8.
MOV A, M
9.
INX H
10.
ADD M
11.
INX H
12.
MOV M, A
13.
HLT
Statement: Subtract the contents of memory location 4001H from the memory
location 2000H and place the result in memory location 4002H.
1.
2.
3.
(4000H) = 51H
4.
(4001H) = 19H
5.
Result
6.
7.
Source program:
8.
9.
MOV A, M
10.
INX H
11.
SUB M
12.
INX H
13.
MOV M, A
14.
HLT
Statement: Add the 16-bit number in memory locations 4000H and 4001H to the 16bit number in memory locations 4002H and 4003H. The most significant eight bits
of the two numbers to be added are in memory locations 4001H and 4003H. Store
the result in memory locations 4004H and 4005H with the most significant byte in
memory location 4005H.
1.
2.
Sample problem:
(4000H) = 15H
3.
(4001H) = 1CH
4.
(4002H) = B7H
5.
(4003H) = 5AH
6.
7.
(4004H) = CCH
8.
(4005H) = 76H
9.
10.
Source Program 1:
11.
12.
XCHG
13.
14.
MOV A, E
15.
ADD L
16.
MOV L, A
17.
MOV A, D
18.
ADC H
19.
MOV H, A
20.
SHLD 4004H : "Store I6-bit result in memory locations 4004H and 4005H"
21.
HLT
1.
Source program 2:
2.
3.
4.
5.
6.
SHLD 4004H : Store I6-bit result in memory locations 4004H and 4005H.
7.
Statement: Add the contents of memory locations 40001H and 4001H and place the
result in the memory locations 4002Hand 4003H.
1.
2.
Sample problem:
(4000H) = 7FH
3.
(400lH) = 89H
4.
Result
5.
(4002H) = 08H
6.
(4003H) = 0lH
7.
Source program:
8.
9.
MOV A, M
10.
INX H
11.
ADD M
12.
INX H
13.
MOV M, A
14.
MVIA, 00
15.
ADC A
16.
INX H
17.
MOV M, A
18.
HLT
Statement: Subtract the 16-bit number in memory locations 4002H and 4003H from
the 16-bit number in memory locations 4000H and 4001H. The most significant
eight bits of the two numbers are in memory locations 4001H and 4003H. Store the
result in memory locations 4004H and 4005H with the most significant byte in
memory location 4005H.
1.
2.
Sample problem:
(4000H) = 19H
3.
(400IH) = 6AH
4.
5.
Result
6.
(4004H) = 04H
7.
(4005H) = OEH
8.
Source program:
9.
10.
XCHG
11.
12.
MOV A, E
13.
SUB L
14.
MOV L, A
15.
MOV A, D
16.
SBB H
17.
MOV H, A
18.
SHLD 4004H : "Store l6-bit result in memory locations 4004H and 4005H"
19.
HLT
Sample problem:
(4400H) = 55H
3.
4.
Source program:
5.
6.
CMA
7.
8.
HLT
: "Complement number"
Sample problem:
(4200H) = 55H
3.
4.
Source program:
5.
6.
CMA
7.
8.
9.
HLT
Statement: Pack the two unpacked BCD numbers stored in memory locations 4200H
and 4201H and store result in memory location 4300H. Assume the least significant
digit is stored at 4200H.
1.
2.
Sample problem:
(4200H) = 04
3.
(4201H) = 09
4.
Result = (4300H) = 94
5.
Source program:
6.
7.
RLC
8.
RLC
9.
RLC
10.
RLC
11.
ANI FOH
12.
MOV C, A
13.
14.
ADD C
15.
16.
HLT
Statement: Two digit BCD number is stored in memory location 4200H. Unpack the
BCD number and store the two digits in memory locations 4300H and 4301H such
that memory location 4300H will have lower BCD digit.
1.
2.
Sample problem:
(4200H) = 58
3.
4.
(4301H) = 05
5.
Source program:
6.
7.
ANI FOH
8.
RRC
9.
RRC
10.
RRC
11.
RRC
12.
13.
14.
ANI OFH
15.
16.
HLT
Statement: Read the program given below and state the contents of all registers
after the execution of each instruction in sequence.
1.
2.
Main program:
4000H
LXI SP, 27FFH
3.
4003H
LXI H, 2000H
4.
4006H
LXI B, 1020H
5.
4009H
CALL SUB
6.
400CH
HLT
7.
Subroutine program:
8.
4100H
SUB: PUSH B
9.
4101H
PUSH H
10.
4102H
LXI B, 4080H
11.
4105H
LXI H, 4090H
12.
4108H
SHLD 2200H
13.
4109H
DAD B
14.
410CH
POP H
15.
410DH
POP B
16.
410EH
RET
Statement: Write a program to shift an eight bit data four bits right. Assume data is
in register C.
1.
2.
Sample problem:
(4200H) = 58
3.
4.
(4301H) = 05
5.
6.
Source program 1:
7.
MOV A, C
8.
RAR
9.
RAR
10.
RAR
11.
RAR
12.
MOV C, A
13.
HLT
Statement: Write a program to shift a 16 bit data, 1 bit right. Assume that data is in
BC register pair.
1.
2.
Source program 2
MOV A, B
3.
RAR
4.
MOV B, A
5.
MOV A, C
6.
RAR
7.
MOV C, A
8.
HLT
Statement: Program to shift a 16-bit data 1 bit left. Assume data is in the HL register
1.
2.
3.
4.
5.
----------------------------
6.
Statement: Write a set of instructions to alter the contents of flag register in 8085.
1.
2.
3.
4.
CMA
5.
6.
PUSH H
7.
8.
HLT
: "Complement accumulator"
: "Save on stack"
MVI B, 00H
MVI C, 08H
MOV A, D
BACK: RAR
JNC SKIP
INR B
SKIP: DCR C
JNZ BACK
HLT
Statement: Write a program to sort given 10 numbers from memory location 2200H
in the ascending order.
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
MVI B, 09
:"Initialize counter"
START
:"LXI H, 2200H: Initialize memory pointer"
MVI C, 09H
:"Initialize counter 2"
BACK: MOV A, M :"Get the number"
INX H
:"Increment memory pointer"
CMP M
:"Compare number with next number"
JC SKIP
:"If less, dont interchange"
JZ SKIP
:"If equal, dont interchange"
MOV D, M
MOV M, A
DCX H
MOV M, D
INX H
:"Interchange two numbers"
SKIP:DCR C
:"Decrement counter 2"
JNZ BACK
:"If not zero, repeat"
DCR B
:"Decrement counter 1"
JNZ START
HLT
:"Terminate program execution"
Statement: Calculate the sum of series of even numbers from the list of numbers.
The length of the list is in memory location 2200H and the series itself begins from
memory location 2201H. Assume the sum to be 8 bit number so you can ignore
carries and store the sum at memory location 2210H.
Sample problem
2200H= 4H
2201H= 20H
2202H= l5H
2203H= l3H
2204H= 22H
Result 22l0H= 20 + 22 = 42H
= 42H
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
LDA 2200H
MOV C, A
:"Initialize counter"
MVI B, 00H
:"sum = 0"
LXI H, 2201H :"Initialize pointer"
BACK: MOV A, M :"Get the number"
ANI 0lH
:"Mask Bit l to Bit7"
JNZ SKIP
:"Dont add if number is ODD"
MOV A, B
:"Get the sum"
ADD M
:"SUM = SUM + data"
MOV B, A
:"Store result in B register"
SKIP: INX H
:"increment pointer"
DCR C
:"Decrement counter"
JNZ BACK
:"if counter 0 repeat"
STA 2210H
:"store sum"
HLT
:"Terminate program execution"
Statement: Calculate the sum of series of odd numbers from the list of numbers.
The length of the list is in memory location 2200H and the series itself begins from
memory location 2201H. Assume the sum to be 16-bit. Store the sum at memory
locations 2300H and 2301H.
Sample problem
2200H = 4H
2201H= 9AH
2202H= 52H
2203H= 89H
2204H= 3FH
Result = 89H + 3FH = C8H
2300H= H Lower byte
Source program :
LDA 2200H
MOV C, A
:"Initialize counter"
LXI H, 2201H :"Initialize pointer"
MVI E, 00
:"Sum low = 0"
MOV D, E
:"Sum high = 0"
BACK: MOV A, M :"Get the number"
ANI 0lH
:"Mask Bit 1 to Bit7"
JZ SKIP
:"Dont add if number is even"
MOV A, E
:"Get the lower byte of sum"
ADD M
:"Sum = sum + data"
MOV E, A
:"Store result in E register"
JNC SKIP
INR D
:"Add carry to MSB of SUM"
SKIP: INX H
:"Increment pointer"
Statement: Find the square of the given numbers from memory location 6100H and
store the result from memory location 7000H.
Sample problem
2200H = 4H
2201H= 9AH
2202H= 52H
2203H= 89H
2204H= 3FH
Result = 89H + 3FH = C8H
2300H= H Lower byte
2301H = H Higher byte
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
Statement: Search the given byte in the list of 50 numbers stored in the consecutive
memory locations and store the address of memory location in the memory
locations 2200H and 2201H. Assume byte is in the C register and starting address of
the list is 2000H. If byte is not found store 00 at 2200H and 2201H.
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
LX I H, 2000H
MVI B, 52H
:"Initialize counter"
BACK: MOV A, M :"Get the number"
CMP C
:"Compare with the given byte"
JZ LAST
:"Go last if match occurs"
INX H
:"Increment memory pointer"
DCR B
:"Decrement counter"
JNZ B
:"If not zero, repeat"
LXI H, 0000H
SHLD 2200H
JMP END
:"Store 00 at 2200H and 2201H"
LAST: SHLD 2200H :"Store memory address"
END: HLT
:"Stop"
Statement: Two decimal numbers six digits each, are stored in BCD package form.
Each number occupies a sequence of byte in the memory. The starting address of
first number is 6000H Write an assembly language program that adds these two
numbers and stores the sum in the same format starting from memory location
6200H.
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
LXI H, 2200H
:"Initialize memory pointer l"
LXI D, 2300H
:"Initialize memory pointer2"
MVI C, 32H
:"Initialize counter"
BACK:MOV A, M :"Get the number"
ANI 0lH
:"Check for even number"
JNZ SKIP
:"If ODD, dont store"
MOV A, M
:"Get the number"
STAX D
:"Store the number in result list"
INX D
:"Increment pointer 2"
SKIP: INX H
:"Increment pointer l"
DCR C
:"Decrement counter"
JNZ BACK
:"If not zero, repeat"
HLT
:"Stop
Statement: Write assembly language program with proper comments for the
following:
A block of data consisting of 256 bytes is stored in memory starting at 3000H. This
block is to be shifted (relocated) in memory from 3050H onwards. Do not shift the
block or part of the block anywhere else in the memory.
Two blocks (3000 30FF and 3050 314F) are overlapping. Therefore it is necessary
to transfer last byte first and first byte last.
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
MVI C, FFH
:"Initialize counter"
LX I H, 30FFH :"Initialize source memory pointer 3l4FH"
LXI D, 314FH :"Initialize destination memory pointer"
BACK: MOV A, M :"Get byte from source memory block"
STAX D
:"Store byte in the destination memory block"
DCX H
:"Decrement source memory pointer"
DCX
:"Decrement destination memory pointer"
DCR C
:"Decrement counter"
JNZ BACK
:"If counter 0 repeat"
HLT
:"Stop execution"