Labwork1 Memory-Access
Labwork1 Memory-Access
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
SAMPLE PROGRAM:
ORG 100h
RET
VAR1 DB 7
var2 DW 1234h
OUTPUT EMULATOR SCREEN:
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 AL,VAR1
K EQU 5
MOV AX, K
ret
VAR1 DB 22h
END
OUTPUT EMULATOR SCREEN:
ANSWERS:
Definition: A high-priority interrupt that cannot be disabled or ignored. It is typically used for critical
system events or hardware failures.
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.
Definition: External hardware devices, such as keyboards, mice, or network adapters, can generate
interrupts to notify the processor that they require attention.
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.
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.
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.
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.