MICROPROCESSOR SYSTEMS
NAME: __________________________________ SUBJECT CODE: _____
LABORATORY WORK NO. 1
MEMORY ACCESS
I. OBJECTIVE(S):
- to access memory we can use these four registers: BX, SI, DI, BP. combining these
registers inside [ ] symbols, we can get different memory locations.
II. THEORIES:
1. MOV instruction –
SAMPLE PROGRAM:
ORG 100h
MOV AX, 0B800h
MOV DS, AX ; copy value of AX to DS.
MOV CL, 'B'
MOV CH, 1101_1111b
MOV BX, 15Eh.
MOV [BX], CX
RET
OUTPUT EMULATOR SCREEN:
2. Variables, Arrays and Constant –
SAMPLE PROGRAM:
ORG 100h
MOV AL, var1
MOV BX, var2
RET
VAR1 DB 7
var2 DW 1234h
OUTPUT EMULATOR SCREEN:
3. Getting the Address of a Variable -
SAMPLE PROGRAM:
ORG 100h
DB 0A0h
DB 08h
DB 01h
DB 8Bh
DB 1Eh
DB 09h
DB 01h
DB 0C3h
DB 7
DB 34h
DB 12h
OUTPUT EMULATOR SCREEN:
4. Interrupts -
SAMPLE PROGRAM:
ORG 100h
MOV AL,VAR1
MOV BX,OFFSET VAR1
MOV BYTE PTR[BX], 44h
MOV AL,VAR1
K EQU 5
MOV AX, K
ret
VAR1 DB 22h
END
OUTPUT EMULATOR SCREEN:
5. Library of common functions - emu8086.inc
SAMPLE PROGRAM:
mov al, 1
mov bh, 0
mov bl, 0011b
mov cx, msg1end - offset msg1
mov dl, 10
mov dh, 7
push cs
pop es
mov bp, offset msg1
mov ah, 13h
int 10h
jmp msg1end
msg1 db "hello,world"
msg1end:
OUTPUT EMULATOR SCREEN:
III. QUESTIONS.
1. List of supported Interrupts and their definitions.
2. What are the two types of variables supported by the EMU 8086 compiler?
3. Differentiate a variable over a constant over an array.
4. What is an assembly language?
5. Enumerate how many ways Variable can be viewed in any numbering system.
ANSWERS:
1.Non-Maskable Interrupt (NMI):
Definition: A high-priority interrupt that cannot be disabled or ignored. It is typically used for critical
system events or hardware failures.
Machine Check Exception (MCE):
Definition: An interrupt triggered by hardware to indicate a severe hardware error or malfunction. It is
often used for detecting issues like memory corruption or CPU errors.
Page Fault Interrupt:
Definition: Occurs when a program tries to access a memory page that is not currently in physical RAM.
The operating system must handle this interrupt by loading the required page into memory.
External Interrupts (IRQ):
Definition: External hardware devices, such as keyboards, mice, or network adapters, can generate
interrupts to notify the processor that they require attention.
Software Interrupt (INT):
Definition: Generated by software to request a service from the operating system or to perform a system
call. It allows user programs to request privileged operations.
System Call Interrupt (SYSCALL):
Definition: Similar to a software interrupt, it is used by user programs to request services from the
operating system. It is a specific type of software interrupt dedicated to system calls.
Trap Interrupt:
Definition: Similar to a software interrupt but used for debugging and error-handling purposes. It allows
the execution of a specific routine or service.
Timer Interrupt:
Definition: Generated by a timer or clock device at regular intervals. It is often used for implementing
multitasking and time-related operations.
DMA (Direct Memory Access) Interrupt:
Definition: Generated by the DMA controller to signal the completion of a data transfer between devices
and memory without involving the CPU.
2. Register Variables:
Definition: Register variables are stored in CPU registers. In x86 assembly language, registers are fast,
low-level storage locations directly accessible by the processor.
Characteristics: Register variables have a limited size and are used for temporary storage during the
execution of a program. Common x86 registers include AX, BX, CX, DX, SI, DI, etc.
Usage: Register variables are suitable for small, short-lived data that doesn't need to persist beyond a
specific block of code.
Memory Variables:
Definition: Memory variables are stored in the computer's memory (RAM). They have a larger storage
capacity compared to registers but are generally slower to access.
Characteristics: Memory variables can persist across different parts of the program and are suitable for
storing larger amounts of data. Memory variables can be accessed through their memory addresses.
Usage: Memory variables are used for data that needs to retain its value across function calls, loops, or
other program blocks.
3. A variable is a mutable storage location used for changing data, a constant is an immutable named
value, and an array is a collection of elements of the same type, accessible by indices. The choice
between using a variable, constant, or array depends on the nature of the data and how it needs to be
managed in the program.
4. Mnemonic Codes: Assembly language uses mnemonics (short codes) that are more readable and
easier to remember than raw binary machine code. Each mnemonic corresponds to a specific machine
language instruction.
Registers and Memory Addresses: Assembly language instructions often involve the use of registers
(small, fast storage locations within the CPU) and memory addresses. Programmers can directly
manipulate data stored in registers and memory.
Low-Level Operations: Assembly language provides a direct representation of the low-level operations of
a computer's central processing unit (CPU). Instructions often map closely to the machine instructions
executed by the CPU.
Platform-Specific: Assembly language is closely tied to a specific computer architecture or processor.
Programs written in assembly language are generally not portable across different architectures without
modification.
Direct Control over Hardware: Programmers writing in assembly language have a high level of control
over the computer's hardware. They can fine-tune programs for performance and access specific
hardware features.