0% found this document useful (0 votes)
72 views11 pages

Mechatronics Midterm Papar PDF

The document contains a student's answers to multiple questions regarding assembly language programming. For question 1, the student provides commented assembly code to read temperature readings from two input ports and display the difference. For question 2, the student provides two methods of storing temperature readings in memory using LXI, MVI, and INX opcodes. For question 3, the student uses LDA, MOV, SUB, and OUT opcodes to subtract values from memory and display the result. For question 4, the student manually subtracts values in registers, determines the output port logic for a negative result, and provides mnemonics and codes to turn on spray paint using MVI, SUB, JNC, and CMP opcodes.

Uploaded by

Abdullah Aziz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views11 pages

Mechatronics Midterm Papar PDF

The document contains a student's answers to multiple questions regarding assembly language programming. For question 1, the student provides commented assembly code to read temperature readings from two input ports and display the difference. For question 2, the student provides two methods of storing temperature readings in memory using LXI, MVI, and INX opcodes. For question 3, the student uses LDA, MOV, SUB, and OUT opcodes to subtract values from memory and display the result. For question 4, the student manually subtracts values in registers, determines the output port logic for a negative result, and provides mnemonics and codes to turn on spray paint using MVI, SUB, JNC, and CMP opcodes.

Uploaded by

Abdullah Aziz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Name: Abdullah Reg No.

17JZMEC0176

Question No.01
Answer:
Given
The data is coming for MPU through 2 input ports F1H and F2H attached with the two furnaces
and an output port with the address F3H attached with the two spray paint nozzles & a display.
Required:
commented assembly language program in order to read the first temperature reading of the
furnace 1 from input port F1H and save the data to the register B as well as to read the first
temperature reading of the furnace 2 from input port F2H and save the data to the register C.
Then, subtract the content of register C from B and display the result at port.
Solution:

IN is a mnemonic that stands for INput the Byte


here we will use the opcode IN, OUT and MOV from input port's content to the accumulator.

OUT is a mnemonic that stands for OUTput


Accumulator contents to an output port”

MOV instruction is a copy


instruction.MOV copies the source operand to the
destination operand without affecting the source

Comments
Since its straight forward to write an assembly program
Read from input port F1H
IN F1H

Copy the data of accumulator A into register B


MOV B, A

IN F2H Read from input port F2H

MOV C, A Copy the data of accumulator A into register C

MOV A, B Copy the data of B to accumulator A

SUB C Subtract the data of C from accumulator A and store


the data in accumulator A

OUT F3H Display the data of the accumulator A on the output F3H

HLT
Name: Abdullah Reg No. 17JZMEC0176

Question No.02
Answer
Given:
sets of five temperature readings of the first and second furnaces are
recorded in hexadecimal as: Data (H):
First Set: 72, 79, 68, 7A, 7F
Second Set: 61, 68, 69, 72, 6F

Required
Write a program to load or store the first set of temperature values of the first furnace in the memory
location starting from 2500H and the second set of temperature values of the second furnace in the
memory location starting from 2300H.

MVI is a mnemonic, which actually means


Solution: “Move Immediate”
Since instructionVI copies the source operand to the
We have to use LXI, MVI and INX opcode destination operand without affecting the source

LXI. These instructions are used to load the 16-


LXI H,2500H bit address into the register pair.
MVI M,72H
INX H INX is a mnemonic that stands for INcrementeXtended register

MVI M,79H
INX H In the HL pair register INX H will increase the value of the
location by 1
MVI M,68H
i.e. if HL pair register have 2500H
INX H
and we Appling INX opcode on HL
MVI M,7AH
it valves become 2501H
INX H
MVI M,7FH
LXI H,3500H
MVI M,61H
INX H
MVI M,68H
INX H
MVI M,69H
INX H
Name: Abdullah Reg No. 17JZMEC0176

MVI M,72H
INX H
MVI M,6FH
HLT

Question No.02
On second method
Solution:
Here we will use only LXI and MVL opcode MVI is a mnemonic, which actually means
Since “Move Immediate”

LXI H,2500H Instruction MVI copies the source operand to the


destination operand without affecting the source
MVI M,72H
LXI H,2501H LXI. These instructions are used to load the 16-
bit address into the register pair.
MVI M,79H
LXI H,2502H
MVI M,68H
LXI H,2503H
MVI M,7AH
LXI H,2504H
MVI M,7FH
LXI H,3500H
MVI M,61H
LXI H,3501H
MVI M,68H
LXI H,3502H
MVI M,69H
LXI H,3503H
MVI M,72H
LXI H,3504H
MVI M,6FH
HLT
Name: Abdullah Reg No. 17JZMEC0176

Question No.02
On 3rd method
Solution: STA is a mnemonic that stands for STore
Accumulator contents in memory.
Here we will use only STA, INX and MVL opcode

Since
MVI is a mnemonic, which actually means
MVI A,72H “Move Immediate”
STA 2500H instruction.MOV copies the source operand to
the destination operand without affecting the
MVI A,79H
source
STA 2501H
MVI A,68H
STA 2502H
MVI A,7AH
STA 2503H
MVI A,7FH
STA 2504H
MVI A,61H
STA 3500H
MVI A,68H
STA 3501H
MVI A,69H
STA 3502H
MVI A,72H
STA 3503H
MVI A,6FH
STA 3504H
HLT
Name: Abdullah Reg No. 17JZMEC0176

Question No.03
Answer:
Here we will use LDA, MOV, SUB, OUT and HLT opcodes

Mnemonics Hex codes(H) Binary codes (2) Comments

LDA 2502H 3A 0011 1010


02 0000 0010 Load the content of memory 2502H into A
25 0010 0101

MOV B, A 47 0100 0111 Copy the A valve in Register B

LDA 3502H 3A 0011 1010


Load the content of memory 3502H into A
02 0000 0010
35 0011 0101

MOV C, A 4F 0100 1111 Copy the A valve in Register C

MOV A, B 78 O111 1OOO Copy the Register B into the accumulate A

Subtract the valve Register C from the value


SUB C 91 1001 0001
of accumulate A and store the answer in A

OUT F3H D3 1101 0011


Display the results on the output port F3H
F3 1111 0011

HLT 76 0111 0110 Terminate the program


Name: Abdullah Reg No. 17JZMEC0176

Question No.04
Answer
Given
Register C value is 68H
Accumulator A value is 69H
the R/W memory location begins at 0200H
Required
I. Perform subtraction manually the content of register-C from the content of accumulator.
II. If the answer is negative, then
determine the logic of the data bits (D7 to D0) combination at the output port in order to turn on
spray paint 1 and 2.
III. The appropriate mnemonic instructions along with Hex machine code for the microcomputer to
turn on spray paint 1 and 2

Solution:

manually subtraction Barrow carry 16


68H
-69H
FFH
Note:
We know that in hex carry is equal to 16 so according to this we do subtraction.
So,
Result =FFH
Logic:
D7 D6 D5 D4 D3 D2 D1 D0
1 1 1 1 1 1 1 1
Flag value

S Z X AC X P X CY
1 0 0 0 0 1 0 1
Name: Abdullah Reg No. 17JZMEC0176

To turn on spray paint 1 and 2


Mnemonic instructions along with Hex machine code
Here we use MVI,SUB,JNC, CMPand HLT opcode

JNC a16, which stands for “Jump if Not Carry” and “a16”stands
for any 16-bit address

CMP is a mnemonic that stands for “CoMPareAccumulator” and


hereR stands for any of the following registers, or memory location
M pointed by HL pair

Memory address mnemonic instructions Hex machine code(H) Comments

0200H STC 37 Set Cy flag bit. So Cy = 1

CMC 3F Complement Cy flag bit. So Cy = 0


0201H

0202H JNC D2 Jump Not Carry, i.e. Jump when Cy = 0

0203H MVI C,68H 0E ,68 This instruction will not get control now
as JNC will transfer the control to the
memory address 2000H
0204H MVI A,69H 3E,69
Subtract the valve Register C from the
value of accumulate A and store the
0205H SUB C 91
answer in A

compare contents of the Accumulator


0206H CMP B B8
with given register B

Display the results on the output port F3H


0206H OUT F3H D3,F3

0206H HLT 76 Terminate the program


Name: Abdullah Reg No. 17JZMEC0176

Question N0.05
Answer
We have to writer all 16-address line
A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
0 0 1 0 0 0 0 0 0 0 0 O 0 0 0 0

0 0 1 0 0 0 1 1 1 1 1 1 1 1 1 1

So, the memory map range


2000H

23FFH
Name: Abdullah Reg No. 17JZMEC0176

Question No. 06:


Answer:
Given data
Ending address= 2BFFH , of 1K memory
Required data:
Starting address of 1K memory
Solution:
We know that
Starting address = ending address – Offset (1)
Offset for 1K memory=1024*8
=210 *8
Compare with 2x=y
S0 address line =x=10
And data line =y=8
So,
The offset for 1k is equal to
Offset=03FFH
So,
Starting address=2BFFH-03FF
Starting address=2800H
Name: Abdullah Reg No. 17JZMEC0176

Question No.07
Answer
Given
2megabytes memory (2048K)
Required
Number of address line to address two megabytes
(2048 K) of memory
Solution:
Since
2x=y
Where,
X= number of the address line and y= number 0f passible combination
So, putting y=2048k in the above equation
 2x=2048k
=2048*1024
=211*210
 2x=221
Now taking log both side
 Log2x=log221
 X log2=21log2
 X log2=21log2 => log2 will be cancel both side
 X=21

So, 21 lines is required to address the two mega byes memory


Name: Abdullah Reg No. 17JZMEC0176

QuestionNo.08
Answer
8085/8080A microprocessor differentiate between the data and the instruction.
The 8085/8080A microprocessor differentiate between the data and the instruction in the following
manner.
As soon as microprocessor is turned on it begins execution opcode in the memory step wise. When
the first m/c code of an instruction is fetched and decoded in the instruction register the
microprocessor recognizes the number of bytes required to fetch the entire instruction the
8085/8080A microprocessor interprets the interprets the first byte it fetches as opcode and second
as data

For example
We tell the processer that our programs begin at 2000H the first code it fetches is 3EH When it
decodes it knows that it is a 2-byte instruction, hence the second code i.e. 32H is a data byte if we
enter 06H instead of 32H then it will load 06 in the accumulate instead of 32

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy