ANSWERS 1 Microprocessor & Assembly Language Programming Year 3 Semester II
ANSWERS 1 Microprocessor & Assembly Language Programming Year 3 Semester II
INSTRUCTIONS
Answer Question ONE and any other TWO Questions
Section (30 Marks)
● ALIGN: The ALIGN instruction is used in assembly language to force the next
instruction to start at a specific memory address boundary. This can be useful for
aligning data structures or improving code execution efficiency on certain
microprocessor architectures.
● ASSUME: The ASSUME instruction allows the programmer to make assumptions about
the location of a register or memory address during assembly. This is often used for
temporary convenience during the assembly process. However, it's important to note
that ASSUME doesn't actually reserve memory or modify the program's behavior. The
assembler uses the assumed value during translation but may need adjustments later.
c) Differentiate between hardware interrupt and software interrupt giving examples in each
case 6 Marks
● One-pass Assembler: A one-pass assembler reads the source code once and
translates it directly into machine code in a single step. This is faster but may not be
able to handle complex dependencies between program sections.
● Two-pass Assembler: A two-pass assembler reads the source code twice. In the first
pass, it gathers information about labels (symbolic names for memory locations) and
references (uses of those labels). In the second pass, it translates the code with all
references resolved to actual memory addresses. This allows for more complex code
structures and error checking.
e) Describe why direct memory access (DMA) is considered an efficient mechanism for
performing I/O. 4 Marks
Direct Memory Access (DMA) is considered an efficient mechanism for performing I/O
operations because it offloads data transfer between memory and I/O devices from the
microprocessor. A dedicated DMA controller manages the transfer without involving the CPU.
This frees up the processor to continue executing instructions while the I/O operation is
happening in the background. This improves overall system performance by reducing
processor overhead during I/O tasks.
● Simple Instructions: RISC processors focus on a set of simple instructions that can be
executed in a single clock cycle. This simplifies the design and improves execution
speed.
● Few Addressing Modes: RISC architectures typically use fewer addressing modes for
instructions, reducing the complexity of decoding instructions during execution.
● Registers for Data: RISC processors rely more heavily on registers for data
manipulation, minimizing memory access and improving performance.
● Complex Control Unit: While instructions are simpler, the control unit in a RISC
processor may be more complex to handle instruction sequencing and pipeline
management efficiently.
Data movement in assembly language programming refers to instructions that transfer data
between various locations within the microprocessor system. These locations can include:
● Registers: Internal CPU registers used for temporary storage and manipulation of data.
● Memory: The main memory of the system where data and programs are stored.
● I/O Devices: Peripheral devices like keyboards, displays, or network cards that interact
with the processor.
These instructions, along with addressing modes that specify the source and destination of the
data, form the foundation for manipulating and processing data within assembly language
programs.
Assembly language condition codes are flags set by the microprocessor's ALU (Arithmetic
Logic Unit) after performing arithmetic and logical operations. These flags indicate the outcome
of the operation, allowing the program to make decisions based on the results. Common
condition codes include:
Conditional branch instructions in assembly language utilize these flags to control program
flow. For example, a JZ (Jump if Zero) instruction will only jump to a specific code section if the
Zero Flag (ZF) is set (meaning the previous operation resulted in zero).
The Universal Serial Bus (USB) is a serial bus standard commonly used for connecting
external peripherals like keyboards, mice, printers, and external storage devices to a computer.
Key characteristics of USB include:
Here's an assembly language program for the 8086 microprocessor that finds the largest
number from a series of 10 numbers stored in memory locations starting from DATA_START:
Code snippet
DATA_SEGMENT SEGMENT
DATA_SEGMENT ENDS
FIND_LARGEST:
IS_LARGER:
Explanation:
1. The program defines a data segment with space for 10 words (16-bit values) to store the
number series (replace ? with actual data).
2. The code segment starts with the START label where the program begins.
3. It loads the address of the first number
Microprocessors are the brains of modern computers and possess several key features:
1. Central Processing Unit (CPU): The microprocessor acts as the central processing
unit, fetching, decoding, and executing instructions. It performs arithmetic and logical
operations, manages data flow, and controls other components within the system.
2. Instruction Set Architecture (ISA): Each microprocessor has a defined ISA, a set of
instructions it understands and can execute. The ISA determines the types of operations
the processor can perform and how data is manipulated. Software developers write
programs specific to the target microprocessor's ISA.
3. Clock Speed: The microprocessor operates at a specific clock speed, measured in MHz
(MegaHertz) or GHz (Gigahertz). This clock speed determines the number of cycles the
processor can execute per second. A higher clock speed generally translates to faster
processing performance.
Interrupts are a crucial mechanism for handling asynchronous events within a computer
system. Here are some common areas where interrupts are used:
Here's an assembly language program for the 8086 microprocessor that multiplies two
constants and displays the result (replace CONSTANT1 and CONSTANT2 with your actual
values):
DATA_SEGMENT ENDS
CODE_SEGMENT ENDS
Explanation:
1. The program defines a data segment with memory locations for the constants and the
result.
2. In the code segment, it loads the constants into registers AX and BX.
3. The MUL BX instruction multiplies the values in AX and BX, storing the lower 16 bits of
the result in AX and the upper 16 bits (if any) in the DX register.
4. The lower 16 bits of the product (in AX) are then stored in the memory location pointed
to by RESULT.
The provided code also includes an optional section to display the result using a DOS interrupt
call. This functionality depends on the specific environment you're running the assembly
program in. You might need to adjust this section based on your system's requirements.
i) Transputer Microprocessor:
b) Explain different methods are used to decide which device to select when
more than one device raises an interrupt request signal. 6 Marks
When multiple devices request an interrupt simultaneously, the processor needs to determine
which interrupt gets serviced first. Here are some common interrupt priority methods:
● Fixed Priority: Each interrupt source is assigned a fixed priority level. Higher priority
interrupts preempt lower priority ones, ensuring critical events are handled first. This is
simple to manage but may not be suitable for situations where interrupt frequency varies
greatly.
● Nested Interrupt: The processor can temporarily disable lower-priority interrupts while
servicing a higher-priority interrupt. This prevents lower-priority events from interrupting
the handling of a critical event. Nested interrupts offer more flexibility but require careful
management to avoid situations where high-priority interrupts prevent lower-priority ones
from being serviced indefinitely.
● Software-Configurable Priority: The interrupt priority levels can be dynamically
configured by software based on the system's needs. This allows for more flexible
prioritization but may require additional software overhead for managing priorities.
● Daisy Chaining: Devices are connected in a daisy chain where each device can identify
the source of the interrupt and pass the request along to the processor. The device
closest to the source has higher priority. This approach can be useful for specific bus
architectures.
The choice of interrupt priority mechanism depends on the specific requirements of the system,
considering factors like real-time response needs, interrupt frequency variations, and desired
flexibility in priority management.
Here's an assembly language program for the 8086 microprocessor that finds the sum of odd
numbers in a series of 8-bit values stored in a continuous memory location (replace
DATA_START with the actual starting address and adjust the loop count if needed):
DATA_SEGMENT SEGMENT
START:
SUM_LOOP:
NOT_ODD:
CODE_SEGMENT ENDS
Explanation:
1. The program defines a data segment with space for 10 bytes (8-bit values) and a word
(16-bit) variable to store the sum.
2. In the code segment, it initializes a counter for the loop, an accumulator for the sum, and
a memory pointer to the data start.
3. The loop iterates
● Level-Triggered Interrupt:
○ Remains asserted (active) as long as the interrupting condition persists.
○ The processor will continue to receive the interrupt request until the condition is
cleared (goes back to inactive state).
○ Useful for situations where the processor needs to be notified of a condition that
exists for a certain duration (e.g., a device holding data ready for transfer).
● Edge-Triggered Interrupt:
○ Occurs only at the moment the interrupting condition transitions from inactive to
active (rising edge) or vice versa (falling edge).
○ The processor acknowledges the interrupt only at the specific point of transition.
○ Suitable for events that happen momentarily (e.g., a key being pressed or a timer
expiring).
● Doorbell Interrupt:
○ A simple interrupt signaling mechanism where a device asserts an interrupt line
to notify the processor of a condition.
○ Doesn't provide any additional information about the interrupt source or the
nature of the event.
○ The processor typically needs to poll devices to identify the source after receiving
the interrupt.
● Message-Signaled Interrupt:
○ Provides more information along with the interrupt request.
○ The interrupting device sends a message on a data bus along with the interrupt
signal, specifying the source and potentially additional details about the event.
○ This allows the processor to directly identify the source and handle the interrupt
more efficiently.
Here's an assembly language program for the 8086 microprocessor that finds the sum of even
numbers in a series (replace DATA_START with the actual starting address and adjust the loop
count if needed):
DATA_SEGMENT SEGMENT
DATA_START DB 10 DUP (?) ; Allocate space for 10 bytes
(8-bit values)
DATA_SEGMENT ENDS
SUM_LOOP:
MOV AL, [SI] ; Load current byte into
AL
NOT_EVEN:
INC SI ; Increment memory pointer
(SI)
CODE_SEGMENT ENDS
Explanation:
1. The program defines a data segment with space for 10 bytes (8-bit values) and a word
(16-bit) variable to store the sum.
2. In the code segment, it initializes a counter for the loop, an accumulator for the sum, and
a memory pointer to the data start.
3. The loop iterates 10 times, checking each byte in the data series.
4. The TEST instruction checks the least significant bit (LSB) of the current byte. If the LSB
is 0 (even number), the ADD instruction adds the value to the sum accumulator (AX).
DATA_SEGMENT ENDS
CHECK_ODD:
TEST AL, 1 ; Check if least significant bit is set (odd)
Prepared by: Joseph Mwaura Njenga | 0717065073 | Best Wishes in your Exam