COAL Lab Practical 1+2
COAL Lab Practical 1+2
OBJECTIVE:
The objective of a lab manual on "Assembly language" likely involves teaching assembly
language to undergrads helps them understand how computers work at a deep level, write
efficient code, and debug effectively. It's key for careers in embedded systems and improves
understanding of compilers and interpreters. Plus, it offers insight into the history of computing
and sharpens critical thinking skills.
Theory Overview:
Assembly language, a low-level programming language, emerged in the late 1940s
and early 1950s alongside the development of electronic computers. Pioneers like
Kathleen Booth and John Backus contributed significantly to its development.
It is primarily used in situations where direct hardware manipulation or maximum
computational efficiency is required, such as embedded systems programming, device
driver development, and performance-critical applications.
Assembly language offers unparalleled control over hardware, making it
indispensable for tasks requiring direct hardware manipulation and optimization for
performance-critical applications.
Despite the predominance of high-level languages for general-purpose programming,
assembly language retains its significance in niche areas where efficiency and control
are paramount, such as embedded systems development and device driver
programming.
Its foundational role in understanding computer architecture and operating systems
ensures its continued relevance in educating software engineers and computer
scientists, providing essential knowledge for understanding the underlying principles
of computing systems.
9. View Output: If the program includes any output to the console (such as printing
characters), you should see the output displayed in the emulator's console window.
10. Terminate the Program: After the program has executed, you can terminate it by
closing the emulator window or clicking on "File" > "Exit".
Program Structure
Directives: Directives provide instructions to the assembler for tasks such as defining data
segments, reserving memory, or including external libraries. Directives often begin with a
period (.) or other special character.
model small: This directive tells the assembler to generate code for a small
memory model. In this memory model, the code, data, and stack segments are
limited to 64 KB each.
.stack 100h: This directive sets the size of the stack segment to 256 bytes (100h in
hexadecimal). This segment contains data values passed to functions and
procedures within the program.
.data: This directive starts the data segment, where variables and constants are
declared.
.code: This directive starts the code segment, where the program's instructions are
placed.
Comments
Comments are non-executable statements used to document code and provide explanations
for human readers. They are ignored by the assembler during program compilation.
Assembly language comment begins with a semicolon (;). It may contain any printable
character including blank.
It can appear on a line by itself, like:
; This program displays a message on screen
or, on the same line along with an instruction, like:
add ax ,bx ; adds bx to ax
Basic Syntax:
.model small
.data
; declare variables here
.code
Main PROC ; executable code begins here
; (write your code here)
Exit ; return control to Operating System
main ENDP
End main
MOV Instruction
The MOV instruction that is used for moving data from one storage space to another. The
MOV instruction takes two operands.
Syntax
The MOV instruction may have one of the following five forms −
TASK 1: Write the following program in assembly language and observe the output.
.model small
.stack 100h
.data
.code
main proc
mov bl,2
mov dl,2
mov ah,2
INT 21h
main endp
end main
CONCLUSION:
RUBRICS:
Ability to 5 5
Conduct Structure
practical
5 5
Data Analysis &
Efficiency
Interpretation
Instructors Signature:
CLO PLO LL
OBJECTIVE: 1 1 2
Overview:
Processor Registers
There are ten 32-bit and six 16-bit processor registers in IA-32 architecture. The registers are
grouped into three categories:
General registers
Control registers
Segment registers
The general registers are further divided into the following groups:
Data registers
Pointer registers
Index registers
Data Registers:
Four 32-bit data registers are used for arithmetic, logical and other operations. These 32-bit
registers can be used in three ways:
1. As complete 32-bit data registers: EAX, EBX, ECX, EDX.
2. Lower halves of the 32-bit registers can be used as four 16-bit data registers: AX, BX, CX
and DX.
3. Lower and higher halves of the above-mentioned four 16-bit registers can be used as eight
8-bit data registers: AH, AL, BH, BL, CH, CL, DH, and DL.
Index Registers:
The 32-bit index registers ESI and EDI and their 16-bit rightmost portions SI and DI
are used for indexed addressing and sometimes used in addition and subtraction.
Service Routines
1= Input a character with echo
2=Output/Print a single character ‘A’
8= Input a character without echo
9=Print collection of characters/String
4ch=Exit
Interrupts
Stop the current program and allow microprocessor to access hardware to take input
or give output.
The INT instruction executes a software interrupt.
The code that handles the interrupt is called an interrupt handler.
Syntax:
INT number
INT 21h = Interrupt for text handling
INT 20h = Interrupt for video/graphics handling
TASKS:
Task 1: Type and save the following programs in assembly language.
Run these programs and observe their values in registers.
Register Value
AX
BX
CS
IP
Register Value
AX
BX
CS
IP
CONCLUSION:
RUBRICS:
Instructors Signature: