Microprocessors and Microcontrollers -
Exam Answers
PART A - (60 Marks)
Question 1
(a) Discuss the performance metrics of a CPU in detail.
A CPU's performance is measured by several metrics, which collectively indicate its speed and
efficiency. The key metrics are:
● Clock Speed (GHz): This is the number of cycles the CPU performs per second. A higher
clock speed generally means faster processing. It is measured in gigahertz (GHz), with
one GHz equaling a billion cycles per second.
● Instructions Per Cycle (IPC): This metric measures how many instructions a CPU can
execute in a single clock cycle. A higher IPC indicates greater efficiency. It's influenced by
the CPU's architecture and pipeline design.
● Cores: A core is an individual processing unit within a CPU. Multi-core CPUs can execute
multiple instructions simultaneously, a process known as parallel processing. More
cores generally improve performance for tasks that can be broken down into smaller,
parallel subtasks.
● Cache Memory: This is a small, fast memory located on the CPU chip. It stores
frequently accessed data and instructions, reducing the time needed to fetch them from
slower main memory (RAM). The performance is affected by the cache's size (L1, L2, L3)
and latency.
● Thermal Design Power (TDP): TDP indicates the maximum amount of heat a CPU can
generate under a typical workload. A lower TDP means the CPU is more power-efficient
and requires less cooling.
(b) Discuss the components and specifications of a computer system.
A computer system consists of two main parts: hardware and software. The hardware
components are the physical parts, while software provides the instructions for the hardware.
Hardware Components:
● Central Processing Unit (CPU): The "brain" of the computer that executes instructions.
Specifications include clock speed, number of cores, and cache size.
● Motherboard: The main circuit board that connects all other components, including the
CPU, RAM, and storage drives.
● Random Access Memory (RAM): Volatile memory used to store data that the CPU is
actively using. Key specifications are capacity (e.g., 8 GB, 16 GB) and speed (e.g., DDR4,
DDR5).
● Storage Devices: These are used for long-term data storage.
○ Hard Disk Drive (HDD): Uses spinning platters for storage. Slower but cheaper and
with higher capacity.
○ Solid State Drive (SSD): Uses flash memory. Much faster but more expensive than
HDDs.
● Power Supply Unit (PSU): Converts AC power from the wall outlet into DC power
needed by the computer components.
● Graphics Processing Unit (GPU): Specializes in rendering images and video. Can be
integrated with the CPU or a separate dedicated card.
Software Components:
● Operating System (OS): The main software that manages all hardware and software
resources. Examples include Windows, macOS, and Linux.
● Application Software: Programs designed to perform specific tasks for the user, such as
web browsers, word processors, and video games.
Question 2
(a) A 16-bit microprocessor has 16 data lines. It is interfaced with a 2 KB of RAM.
(i) Find out the address lines required for this system.
● Memory size = 2 KB = 2 × 1024 bytes = 2048 bytes
● To address 2048 unique memory locations, we need 'n' address lines such that 2n=2048.
● Since 210=1024 and 211=2048, the number of address lines required is 11.
(ii) If a designer chooses 11 address lines instead with the first address location of the
memory to be 200H find out the last address.
● Number of addressable locations = 211=2048 bytes.
● Starting address = 200H.
● The total address space is 2048 bytes (0-2047). In hexadecimal, this is 000H to 7FFH.
● So, the address space ranges from 200H to (200H + 7FFH).
● 200H + 7FFH = 9FFH.
● Therefore, the last address is 9FFH.
(iii) Considering 11 address lines with the last address as 500H find out the first
address.
● Total number of memory locations = 211=2048 bytes.
● Last address = 500H.
● First address (in decimal) = Last address (decimal) - (total locations - 1).
● 500H = 1280 in decimal.
● First address = 1280 - (2048 - 1) = 1280 - 2047 = -767.
● This is not a valid physical address. The question contains a logical inconsistency.
(b) Discuss all the general purpose registers, segment registers, pointer and index
registers of 8086 microprocessor.
The Intel 8086 microprocessor has a segmented memory architecture and uses various
registers to manage data and addresses.
● General Purpose Registers (AX, BX, CX, DX): These 16-bit registers are used for
general data manipulation.
○ AX (Accumulator): Primarily used for arithmetic and data transfer.
○ BX (Base): Used as a base address for memory access.
○ CX (Counter): Used as a loop counter.
○ DX (Data): Used for I/O operations and as a secondary accumulator.
● Segment Registers (CS, DS, SS, ES): These 16-bit registers define the start of 64 KB
memory segments.
○ CS (Code Segment): Points to the start of the program's executable code.
○ DS (Data Segment): Points to the start of the program's data.
○ SS (Stack Segment): Points to the start of the program's stack.
○ ES (Extra Segment): An additional data segment register.
● Pointer and Index Registers (SP, BP, IP, SI, DI): These registers hold memory addresses
and pointers.
○ SP (Stack Pointer): Points to the top of the stack within the stack segment.
○ BP (Base Pointer): Used to access parameters passed from the stack.
○ IP (Instruction Pointer): Holds the offset of the next instruction to be executed
within the code segment.
○ SI (Source Index): Used as an index for source data in string operations.
○ DI (Destination Index): Used as an index for destination data in string operations.
Question 3
(a) Write an 8051 assembly language program to toggle all the bits of port 1 at
every 20 ms. Assume the crystal frequency is 11.0592 MHz, and that the system is
using the AT89C51 microcontroller. Write down the calculations performed by
mentioning the machine cycle across each instruction to get the desired time
delay using timer 0, mode 1.
Calculations:
● Crystal Frequency: F_xtal=11.0592 MHz
● Machine Cycle Frequency: F_mc=F_xtal/12=11.0592/12=0.9216 MHz
● Time for one machine cycle: T_mc=1/F_mc=1/0.9216×106=1.085μs
● Required Delay: 20 ms = 20000μs
● Number of machine cycles for delay: N=Required Delay/T_mc=20000/1.085=18433
cycles (approx)
● Initial Timer Value: 65536−18433=47103 (decimal)
● Converting to Hexadecimal: 47103_10=B73F_16.
● Timer Load Values:
○ TH0 (High byte): B7H
○ TL0 (Low byte): 3FH
Assembly Language Program:
ORG 0000H
JMP MAIN
ORG 0030H
MAIN:
MOV P1, #00H ; Initialize Port 1
SETB P2.0 ; Assume an LED is connected to P2.0 to indicate toggling
LOOP:
CPL P1 ; Toggle all bits of Port 1
; Configure Timer 0, Mode 1 (16-bit)
MOV TMOD, #01H ; TMOD = 01H for Timer 0, Mode 1
; Load Timer with calculated initial value for 20 ms delay
MOV TH0, #0B7H ; Load High byte
MOV TL0, #3FH ; Load Low byte
SETB TR0 ; Start Timer 0
WAIT_FOR_TIMER:
JNB TF0, WAIT_FOR_TIMER ; Wait until Timer 0 overflows (TF0 flag is set)
CLR TR0 ; Stop Timer 0
CLR TF0 ; Clear the Timer Overflow flag
JMP LOOP ; Repeat the process
END
(b) Write an assembly language program for 8051 microcontroller to keep
transferring word "VITB" serially at 9600 baud rate where, data is of 8-bit and 1
stop bit.
Calculations for Baud Rate:
● Timer 1 Reload Value (TH1): 256−3=253_10=FDH
Assembly Language Program:
ORG 0000H
JMP MAIN
ORG 0030H
MAIN:
MOV TMOD, #20H ; Timer 1, Mode 2 (8-bit auto-reload) for baud rate generation
MOV TH1, #0FDH ; Reload value for 9600 baud rate
MOV SCON, #50H ; Configure Serial Port: Mode 1: 8-bit UART
SETB TR1 ; Start Timer 1
LOOP:
MOV A, #'V' ; Load 'V' into accumulator
ACALL SERIAL_SEND ; Send 'V'
MOV A, #'I' ; Load 'I'
ACALL SERIAL_SEND ; Send 'I'
MOV A, #'T' ; Load 'T'
ACALL SERIAL_SEND ; Send 'T'
MOV A, #'B' ; Load 'B'
ACALL SERIAL_SEND ; Send 'B'
JMP LOOP ; Loop indefinitely
SERIAL_SEND:
MOV SBUF, A ; Load character to serial buffer
WAIT_FOR_TX:
JNB TI, WAIT_FOR_TX ; Wait for transmission to complete (TI flag to set)
CLR TI ; Clear transmit interrupt flag for next transmission
RET
END
PART B - (40 Marks)
Question 4
(a) Discuss the method to generate a sine wave from a Digital to Analog
Converter (DAC) unit of an 8051 microcontroller. Draw the Angle Vs Voltage
magnitude for the sine wave and write an assembly language program assuming
that the full scale output of the DAC unit is 5 volts.
Sine Wave Generation Method:
A sine wave can be generated using a DAC by providing a series of digital values that
correspond to the amplitude of a sine wave at different angular positions. This is typically
done by storing a lookup table in the microcontroller's program memory.
Angle vs. Voltage Magnitude:
Assembly Language Program:
ORG 0000H
JMP MAIN
ORG 0030H
MAIN:
MOV DPTR, #SINE_TABLE ; Load the starting address of the sine table
LOOP:
MOV A, #00H ; Initialize a counter for the table index
GET_DATA:
MOVC A, @A+DPTR ; Get data from sine table
MOV P1, A ; Send value to Port 1 (assuming DAC is connected to P1)
ACALL DELAY
INC A ; Increment the table index
CJNE A, #10H, GET_DATA ; Check if we've read all 16 values (10H = 16)
JMP LOOP ; Repeat for the next cycle
SINE_TABLE:
DB 80H, 0C0H, 0E0H, 0F0H, 0F8H, 0FFH, 0F8H, 0F0H, 0E0H, 0C0H, 80H, 40H, 20H, 10H,
08H, 00H
DELAY:
MOV R0, #10H
DLY1:
DJNZ R0, DLY1
RET
END
(b) Write and assemble a language program for an 8051 microcontroller to
interface with a 4×4 keyboard. Explain the interfacing with the help of a
connection diagram to the input port 2 and output port 1 of the microcontroller.
Interfacing a 4x4 Keyboard with 8051:
A 4x4 keypad has 4 rows and 4 columns, which are connected to a total of 8 I/O pins. The
8051 microcontroller will use Port 1 as an output port to scan the columns and Port 2 as an
input port to read the rows. This is known as a scanning method.
Connection Diagram:
Assembly Language Program:
ORG 0000H
JMP MAIN
ORG 0030H
MAIN:
MOV P1, #0FFH ; Set all column pins to high
LOOP_KEY:
MOV P1, #0FEH ; Drive column 0 low (0FEH = 1111 1110b)
JNB P2.0, KEY0 ; Check if row 0 is low
MOV P1, #0FDH ; Drive column 1 low
JNB P2.0, KEY1
MOV P1, #0FBH ; Drive column 2 low
JNB P2.0, KEY2
MOV P1, #0F7H ; Drive column 3 low
JNB P2.0, KEY3
JMP LOOP_KEY ; No key pressed, keep checking
KEY0: ; Key at (Row 0, Col 0) pressed
JMP LOOP_KEY
KEY1: ; Key at (Row 0, Col 1) pressed
JMP LOOP_KEY
KEY2: ; Key at (Row 0, Col 2) pressed
JMP LOOP_KEY
KEY3: ; Key at (Row 0, Col 3) pressed
JMP LOOP_KEY
END
Question 5
(a) What is an ARM processor? Discuss the advantages of ARM processors and
compare it with Intel processors.
An ARM processor (Advanced RISC Machine) is a type of CPU architecture based on the
RISC (Reduced Instruction Set Computing) design philosophy.
Advantages of ARM Processors:
● Low Power Consumption: ARM's simple architecture requires less power, making them
ideal for battery-powered devices.
● High Power Efficiency: This translates to excellent performance per watt.
● Cost-Effectiveness: The simple design and licensing model make ARM processors more
affordable to manufacture.
● Small Die Size: The compact design is crucial for mobile devices where space is limited.
Comparison with Intel Processors:
| Feature | ARM Processors | Intel Processors |
| --- | --- | --- |
| Architecture | RISC | CISC |
| Instruction Set | Fewer, simple instructions | More, complex instructions |
| Power Consumption| Very low | Higher |
| Primary Use | Mobile, IoT | Desktops, laptops, servers |
(b) Write a short note on:
(i) Operating modes of ARM:
ARM processors operate in several modes to manage different tasks, protect system
resources, and handle exceptions. These modes include User Mode, System Mode, Supervisor
(SVC) Mode, Abort Mode, Undefined Mode, IRQ Mode, and FIQ Mode.
(ii) ARM7TDMI pipelining:
Pipelining is a technique to improve instruction throughput. The ARM7TDMI uses a 3-stage
pipeline:
1. Fetch: The instruction is fetched from memory.
2. Decode: The fetched instruction is decoded.
3. Execute: The instruction is executed.
This overlapping of operations increases the overall speed of the processor.
Question 6
(a) Discuss the history and evolution of Intel 8-bit Microprocessors.
The history of Intel's 8-bit microprocessors marks a pivotal period in the development of
personal computers.
● Intel 8008 (1972): Intel's first 8-bit microprocessor, used in a computer terminal.
● Intel 8080 (1974): A major breakthrough that became a standard for 8-bit
microprocessors and was used in early personal computers like the Altair 8800.
● Intel 8085 (1976): An enhanced version of the 8080 that was more integrated and
required only a single power supply, making it ideal for embedded systems.
(b) Discuss addressing modes of 8086 microprocessor.
Addressing modes are the ways an 8086 microprocessor calculates the effective address of
an operand. The various modes include:
● Immediate Addressing: Operand is part of the instruction.
● Register Addressing: Operand is in a register.
● Direct Addressing: The effective address is specified in the instruction.
● Register Indirect Addressing: Address is in a base or index register.
● Based Addressing: Sum of a base register and a displacement.
● Indexed Addressing: Sum of an index register and a displacement.
● Based-Indexed Addressing: Sum of a base, an index, and a displacement.
● String Addressing: Used with string instructions.
(c) Discuss Special Function Registers of microcontroller 8051.
Special Function Registers (SFRs) are dedicated registers within the 8051 microcontroller's
internal RAM used to control and monitor its operation. Key SFRs include the Accumulator
(A), B Register, Program Status Word (PSW), Stack Pointer (SP), Data Pointer (DPTR),
Port Registers (P0-P3), Serial Data Buffer (SBUF), and various timer and control registers.
(d) Draw the connection diagram of a 7 segment display with an 8051
microcontroller through the interfacing chip 74LS240. Write an assembly
language program for the same system to display numbers from 0 to 9 in a 7
segment display using a BCD lookup table.
Connection Diagram:
Assembly Language Program:
ORG 0000H
JMP MAIN
ORG 0030H
MAIN:
MOV DPTR, #BCD_TABLE ; Load the starting address of the lookup table
MOV R0, #00H ; Initialize a counter for the numbers (0 to 9)
LOOP:
MOV A, R0 ; Move the counter value to the accumulator
MOVC A, @A+DPTR ; Get the corresponding BCD value from the lookup table
MOV P1, A ; Display the value on the 7-segment display (connected to P1)
ACALL DELAY_1S ; Call a delay subroutine to hold the number for 1 second
INC R0 ; Increment the counter to display the next number
CJNE R0, #0AH, LOOP ; Check if we have displayed all numbers from 0 to 9 (0AH = 10)
JMP MAIN ; Loop back to start from 0
BCD_TABLE:
DB 3FH, 06H, 5BH, 4FH, 66H, 6DH, 7DH, 07H, 7FH, 6FH
DELAY_1S:
MOV R2, #20 ; Outer loop for delay
DLY_OUT:
MOV R3, #250 ; Middle loop
DLY_MID:
MOV R4, #250 ; Inner loop
DLY_IN:
DJNZ R4, DLY_IN
DJNZ R3, DLY_MID
DJNZ R2, DLY_OUT
RET
END