Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
35 views

Experiment-1: Basic Operations On 8-Bit Numbers.: Objective: Requirement: Theory

The document describes experiments to perform basic operations on 8-bit numbers using a Java simulator. It includes the theory, flowcharts and procedures for addition, subtraction, multiplication and division of two 8-bit numbers. The theory sections explain the logic for each operation. The procedures provide step-by-step instructions. Programs written in assembly language are given to perform each operation.

Uploaded by

Bidit Mangal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Experiment-1: Basic Operations On 8-Bit Numbers.: Objective: Requirement: Theory

The document describes experiments to perform basic operations on 8-bit numbers using a Java simulator. It includes the theory, flowcharts and procedures for addition, subtraction, multiplication and division of two 8-bit numbers. The theory sections explain the logic for each operation. The procedures provide step-by-step instructions. Programs written in assembly language are given to perform each operation.

Uploaded by

Bidit Mangal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

EXPERIMENT-1: Basic Operations on 8-bit numbers.

Objective: To perform basic operations on two 8-bit numbers


Requirement: Java Simulator
Theory:
Theory for Addition:
The first data is brought to Accumulator A and the second one in any one of the other registers, say B.
The addition is done using ADD.  The result is then stored at 4252. The ADD instruction affects flags
depending on result.

Theory for Subtraction:


In this experiment, the HL register pair is first initialized to the start address of  memory at which the
data is stored. Then data is brought to accumulator A and the other one is subtracted from memory
itself. The result from A is then stored into memory again using the HL register. The SUB instruction
sets and clears flags according to result.

Theory for Multiplication:


As far as the examples are concerned, they are very simple in the sense that 8085 offers
instructions to do those tasks. Since there is no such instruction to multiply or to divide, some
logic has to be applied to do these tasks. Multiplication can be done by done by repeated
addition while division by repeated subtraction.
Theory for Division:
The divisor is subtracted from the 8 most significant bits of the dividend. If there is no borrow, the bit
of the quotient is set to 1; otherwise 0. To line up the dividend and quotient properly the dividend is
sifted left by one bit before each trial of subtraction. The dividend quotient shares a 16-bit register.
Due to shift of dividend one bit of the registers falls vacant in each step. The quotient is stored in
vacant position.

Flowcharts:
Flowchart for Addition:
Flowchart for subtraction:

Flowchart for Multiplication:

Flowchart for Division:

2
Procedure:
Procedure for Addition:
EXPERIMENTAL PROCEDURE: STEP WISE –

i)  Key in the Opcodes from the address specified.

ii) Enter data at 4250 and 4251 as specified in the example.

iii)Execute the program and check for the result at 4252.

iv)Change data at 4250 and 4251 and execute each time and check for result.

Procedure for Subtractions


EXPERIMENTAL PROCEDURE: STEP WISE:

i) Key in the Opcodes from the address specified.

ii) Enter data that is needed for execution at 4250 and 4251.

Procedure for Multiplication:


EXPERIMENTAL PROCEDURE: STEP WISE –

i) Key in the Opcodes from the address specified.

ii)  Enter data at 4250 through 4253 for execution.

iii) Execute the program and check for results at 4254 and 4255.
3
iv) Try changing data and check results each time.

Procedure for Division:


EXPERIMENTAL PROCEDURE: STEP WISE      
       
i)  Key in the Opcodes from the address  specified.

ii) Enter data at 4250 and 4251 as specified in the example.

iii)Execute the program and check for the result at 4252.

iv)Change data at 4250 and 4251 and execute each time and check for result.

Programs:
Program for addition:

Addition of Two Number


A.

# ORG 7000H

LXI H,7501   // Get address of 1st no. in HL pair


MOV A,M     // Move no. into accumulator
INX H     // HL points the address 7502 H
ADD M     // Add the 2nd no.
INX H     // HL points 7503 H
MOV M,A   // Store result in 7503 H
RST 1     // Terminate

# ORG 7501H       // Store input at the address


# DB 12H, 13H    // Get two 8 bit no. in successive location

Program for Subtraction:

# ORG 7000H
LXI H, 7501     // Get address of ist no. in HL pair
MOV A, M     // Move no. into accumulator
INX H     // HL points 7502 H.
SBB M     // Substract 2nd no. from Ist no.
INX H     //HL points 7503 H.
MOV M, A     // Move contents of acc. to memory
RST 1     // Terminate

#ORG 7501H     // Store no. at address


#DB 20,10     // Get the two 8 bit no. at successive location

Program for Multiplication:

4
# ORG 7000H
LHLD 7501      // Get Multiplicand in H-L pair.
XCHG       // Exchange HL pair with DE pair
LDA 7503     // Get 2nd no. in acc.
LXI H,0000     // Initial product in HL=00
MVI C,08     // Count=08 in reg .C
up:DAD H     // Shift partial product left by 1 bit
RAL     // Rotate multi. by 1 bit. Is multiplier = 1?
JNC down     // No, go to ahead
DAD D     // Product=Product + Multiplicand
down:DCR C      // Decrement Count
JNZ up      // Jump until C=0
SHLD 7504     // Store result
RST 1      // Terminate

#ORG 7501H     // Store inputs at the address


# DB 25,00,05     // Get the numbers from successive locations

Program for Division:

# ORG 7000H

LDA 7501     // [7501]=>A (Divisor)


MOV B,A     // Take divisor in reg,B
LDA 7502     // Take dividend in reg,A
MVI C,00     // Quotient=00
CMP B     // Compare A to B
JC down     // Jump if carry
up:SUB B     // Dividend-divisor=>A
INR C     // C=C+1
CMP B     // Is dividend < divisor
JNC up     // If not,go back
down:STA 7503     // Store Remainder
MOV A,C     // C=>A
STA 7504     // Store Quotient
RST 1     // Terminate

5
# ORG 7501H     // Store the inputs at the address
# DB 06,26     // Get the numbers from successive loc.

You might also like