Assignment 03-1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Assignment No.

03
Mechatronics

uestion No.01
Write logical steps & assembly language program to subtract the two Hex numbers 48H and
32H. Both the numbers should be saved for the future use. Save the result in the accumulator.
Answer.
Logical Steps
First we do the subtraction by 2’s complement method
Subtrahend 32H = 00110010
Step 01
1’s Complement 11001101
Step 02
Add 01 to obtain + 1

2’s Complement 11001111

To subtract 48H-32H
Add 48H to the 2’s Complement
11001111
+ 01001000
00010111

0 0 0 1 0 1 1 12=16H Answer

Now we have to write the assembly program for subtraction of two number

address HEX Codes Labels Mnemonics Comments


F000 0E MVI C,00H Clear C register
F001 00
F002 3E MVI A,48H load first number to accumulator
F003 48
F004 06 MVI B,32H load second number to B register
F005 32
F006 21 LXI H,8000H Load initial address to store number for future use
F007 00
F008 80
F009 77 MOV M, A Store the first number for future use
F00A 23 INX H Point to next location
F00B 70 MOV M, B Store the second number for future use
F00D 90 SUB B Subtract B from A
F00E D2 JNC STORE When CY = 0, go to STORE
F00F 12
F010 F0

Prepared by Abdullah
Reg No.17JZMEC0176
Assignment No.03
Mechatronics

F011 0C INR C Increase C by 1


F012 21 STORE LXI H,8050H Load the destination address
F013 50
F014 80
F015 77 MOV M, A Store the result
F016 23 INX H Point to next location
F017 71 MOV M, C Store the borrow
F018 76 HLT Terminate the program

Question N0.02
Write 8085 programs to perform the multiplication of two 8-bit
numbers and store the result in register C for future use.
Answer:
We have to write a program to perform the multiplication of two 8-bit numbers and store the
result in register C.
If the first number is store in the memory location 8000H and the second is store in 8001H

machine
Address label Mnemonics comments
code
F000 21 LXI H,8000H Load first operand address
F001 0
F002 80
F003 46 MOV B, M Store first operand to B
F004 23 INX H Increase HL pair
F005 AF XRA A Clear accumulator
F006 4F MOV C, A Store 00H at register C
F007 86 LOOP ADD M Add memory element with Acc
F008 D2 JNC SKIP When Carry flag is 0, skip next task
F009 0C
F00A F0
F00B 0C INR C Increase C when carry is 1
F00C 5 SKIP DCR B Decrease B register
F00D C2 JNZ LOOP Jump to loop when Z flag is not 1
F00E 7
F00F F0
F010 21 LXI H,8050H Load Destination address
F011 80
F012 50

Prepared by Abdullah
Reg No.17JZMEC0176
Assignment No.03
Mechatronics

Store C register content into


F013 71 MOV M, C
memory
F014 23 INX H Increase HL Pair
F015 77 MOV M, A Store Acc content to memory
F016 4F MOV C, A Store the result in register C
F017 76 HLT Terminate the program

Prepared by Abdullah
Reg No.17JZMEC0176

You might also like