0% found this document useful (0 votes)
5 views10 pages

Tut 1

The document provides a tutorial on microprocessor programming and interfacing, covering topics such as determining the bit size of a microprocessor, the order of bus signals, and the differences between control and status flags. It explains the function of various flags in the 8086 microprocessor's flag register, detailing their purposes and how they reflect the results of arithmetic operations. Additionally, the document discusses binary subtraction methods and the potential for two's complement overflow during subtraction operations.

Uploaded by

agrawaldiveel
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)
5 views10 pages

Tut 1

The document provides a tutorial on microprocessor programming and interfacing, covering topics such as determining the bit size of a microprocessor, the order of bus signals, and the differences between control and status flags. It explains the function of various flags in the 8086 microprocessor's flag register, detailing their purposes and how they reflect the results of arithmetic operations. Additionally, the document discusses binary subtraction methods and the potential for two's complement overflow during subtraction operations.

Uploaded by

agrawaldiveel
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/ 10

Tutorial-1

EEE/CS/ECE/INST F241-Microprocessor Programming & Interfacing


Q.1 How do you determine whether if a microprocessor is 8 bits or 16-bits or
32-bits?
Sol: Size of ALU (i.e. Maximum size of data on with the arithmeticc or logical
operation can be performed)

Q.2 What is the order in which the microprocessors bus signals (Address, Data
and Control) are activated?
Sol: Address, Control, Data
Q.3 What is the difference between control flags and the status flags?

• A flag is a flip flop which indicates some conditions produced by the execution of an instruction or
controls certain operations of the EU.
• In 8086, the Execution Unit (EU) contains a 16 bit flag register.
• Out of the 16 bits 9 are active flags and remaining 7 are Unused (U).
• Out of the 9 active flags
• 6 Status Flags – Sign Flag(SF), Zero Flag(ZF), Auxiliary Carry Flag(AC), Parity Flag(PF), Carry
Flag(CF), Overflow Flag (OF)
• 3 Control Flags – Direction Flag(DF), Interrupt Flag (IF), Trap Flag (TF)

15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
U U U U OF DF IF TF SF ZF U AF U PF U CF
Status Flags Control Flags
Flag Purpose Flag Purpose

Carry (CF) Holds the carry after addition or the borrow after Enables the trapping through an on-chip debugging
subtraction. Trap (TF) feature.
Also indicates some error conditions, as dictated by Permits operation of the processor in single step mode.
some programs and procedures . Controls the operation of the INTR (interrupt request)
Parity (PF) PF=0;odd parity, PF=1;even parity. Interrupt (IF) I=0; INTR pin disabled. I=1; INTR pin enabled.
Indicates whether external interrupts are being processed or
Auxiliary Holds the carry (half – carry) after addition or borrow ignored
(AF) after subtraction between bit positions 3 and 4 of the It selects either the increment or decrement mode for DI
result (for example, in BCD addition or subtraction.) Direction (DF) and /or SI registers during the string instructions.
Zero (ZF) Shows the result of the arithmetic or logic operation. Indicates left or right for moving or comparing string data.
Z=1; result is zero. Z=0; The result is 0
Sign (SF) Holds the sign of the result after an arithmetic/logic
instruction execution. S=1; negative, S=0 positive.
Overflow Overflow occurs when signed numbers are added or
(OF) subtracted. An overflow indicates the result has
exceeded the capacity of the Machine.
• Status Flags reflect properties of the last executed arithmetic or logical instruction.
• For example, if register AL = 7Fh and the instruction ADD AL,1 is executed then the following happen
AL = 80h
CF = 0; there is no carry out of bit 7
PF = 0; 80h has an odd number of ones
AF = 1; there is a carry out of bit 3 into bit 4
ZF = 0; the result is not zero
SF = 1; bit seven is one
OF = 1; the sign bit has changed

After any operation, if D[6] generates any carry and passes to D[7] OR if D[6] does not generates carry but D[7]
generates, overflow flag becomes set, i.e., 1. If D[6] and D[7] both generate carry or both do not generate any
carry, then overflow flag becomes reset, i.e., 0.
**If the XOR of carry-in and carry-out at D[7] comes to be 0 ,OF is set to zero.
• 97 + 48 Decimal 33
0110 0001 Binary 0010 0001

0011 0000 1’s Complement 1101 1110

1001 0001 2’s Complement 1101 1111

Decimal 99
• 99 – 33 Binary 0110 0011
0110 0011 1’s Complement 1001 1100
1101 1111 2’s Complement 1001 1101
0100 0010

• 33 - 99
0010 0001 Binary 1011 1110 Sign bit 1 indicates that the result is
1001 1101 1’s Complement 0100 0001 negative. Take 2’s complement to
obtain the magnitude = 66.
1011 1110 2’s Complement 0100 0010
Binary 1100 0011 Decimal 29 Decimal 32
• -29 + -32 1’s Complement 0011 1100 Binary 0001 1101 Binary 0010 0000
2’s Complement 0011 1101 1’s Complement 1110 0010 1’s Complement 1101 1111
1110 0011
2’s Complement 1110 0011 2’s Complement 1110 0000
1110 0000
Sign bit 1 indicates that the
1100 0011
number is negative. Take 2’s
complement to obtain the
magnitude = 61.

• -41 - 95 Decimal 41 Decimal 95


Binary 0010 1001 Binary 0101 1111
1101 0111 1’s Complement 1101 0110 1’s Complement 1010 0000
1010 0001 2’s Complement 1101 0111 2’s Complement 1010 0001
0111 1000
Difference between pen-paper method and
binary subtraction used by microprocessor
• Binary subtraction • Now perform -41-95 using binary
10 subtraction method
-0 1 • -41 = 1 1 0 1 0 1 1 1
------------ • 95 = 0 1 0 1 1 1 1 1
01 • -------------------------
There is a borrow from 21 to 20 place • 01111000
• Thus in this method the CF=0 as
• Microprocessor performs this there is no borrow into the MSBit
binary subtraction method. Thus • However OF =1 as there is a
it will show CF=0 for the carryout from MSB to MSB-1, i.e.,
subtraction -41-95 bit 7 to bit6 (LSB is bit0)
Q5. Is there a possibility of two’s complement overflow during
subtraction?

• Yes.
Eg:
Two’s Complement overflow was observed in case of -41-95
1101 0111
1010 0001 Decimal 41 Decimal 95

0111 1000 Binary 0010 1001 Binary 0101 1111

1’s Complement 1101 0110 1’s Complement 1010 0000

2’s Complement 1101 0111 2’s Complement 1010 0001

You might also like