0% found this document useful (0 votes)
40 views15 pages

Lab Manual Coal

lab manual coal

Uploaded by

waseem04002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views15 pages

Lab Manual Coal

lab manual coal

Uploaded by

waseem04002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Lab Manual

Computer Organization and Assembly Language

Submitted to:
Mam Nashitah Alwaz
Submitted by:
Dua Fatima
Section:
A
Roll No:
2023-CS-33

Department of Computer Science

MNS Univerisity of Engineering and technology,Multan.


Introduction to Assembly language
Defination
Assembly language is a low-level programming language that uses symbolic codes (mnemonics) to
represent machine-specific instructions. It's translated directly into machine code that a computer's
processor understands.

Characteristics:

1. Low-level: Close to machine language, with a 1:1 correspondence.

2. Symbolic representation: Uses mnemonics (e.g., MOV, ADD) instead of binary.

3. Machine-specific: Tailored to a particular processor architecture.

4. Efficient: Provides direct access to hardware resources.

Key features:

1. Instructions: Represented by mnemonics (e.g., MOV, JUMP).


2. Registers: Access to processor registers (e.g., AX, BX).
3. Memory management: Direct access to memory locations.
4. Input/Output operations: Control over I/O devices.

Advantages:

1. Performance: Optimized for specific hardware.


2. Control: Direct access to hardware resources.
3. Size: Compact code.

Disadvantages:

1. Complexity: Steep learning curve.


2. Portability: Non-transferable between architectures.
3. Maintenance: Difficult to modify and debug.

Common assembly languages:

1. x86 Assembly (Intel/AMD)


2. ARM Assembly (Mobile devices)
3. MIPS Assembly (Embedded systems)
4. PowerPC Assembly (Game consoles, embedded)

Uses:

1. Operating systems
2. Embedded systems
3. Firmware
4. Device drivers
5. High-performance applications
6. Reverse engineering

Example code:

assembly

; x86 Assembly example

MOV AX, 5 ; load 5 into AX register

ADD AX, 3 ; add 3 to AX

JUMP LABEL ; jump to label

LABEL:

MOV BX, AX ; move AX to BX

To write assembly code, you'll need:

1. An assembler (e.g., NASM, MASM)\


2. A text editor or IDE
3. Knowledge of the target processor architecture

Installation Of DosBox and Emulator


There are two software used in this which are Dosbox and Emulator

DosBox

DOSBox is a free, open-source emulator that mimics MS-DOS, allowing users to run retro games and
applications on modern operating systems. It simulates the DOS environment, emulating hardware
components and translating input. Compatible with Windows, macOS, and Linux.
Installation of DosBox
The installation of dosbox has involving folowing steps.

Step 1: Download DOSBox


DOSBox is open source and free. Get it here: http://www.dosbox.com/download.php?
main=1 and use the installer.

Step 2: Creating the Game Folder


Go to the root of your main hard drive (Mine is C:\) and create a folder. I called mine "dos".

Step 3: Start DOSBox


Starting DOSBox isn't really that hard. All you need to do is click the icon. When DOSBox is started, a
window will pop up. Press Alt+Enter at any time to make it fullscreen or exit fullscreen.
Step 4: Mount the C:\dos Directory
Type this into DOSBox: mount c c:\dos

Then press Enter or Return. It will display the message "Drive C is mounted as local directory
c:\dos\." After that, type c: and hit Enter to enter the c:\dos directory.

Step 5: Enter the Directory Containing the Game


Step 6: Enter the Exe File Name and Play the Game!
Type dir, find the exe file name, type it in and you're away! Enjoy!

Step 7: (OPTIONAL STEP)


To get to your games faster, you can edit the options.bat file at (default) C:\Program Files
(x86)\DOSBox-0.74Anything added to the bottom row will automatically execute every time
DOSBox is started. Type the commands you would normally type here to access your games
faster. For example, if your game folder is C:\dos, then

mount c c:\dos
c:

dir

The above lines will automagically mount your dos folder as C:\ and take you directly into
the folder. Then it will show you your list of directories so you can just cd one and play your
game!

Emulator
An emulator is software or hardware that mimics a computer system, processor, or environment,
allowing programs to run on a host system as if on the original. Emulators ensure compatibility,
facilitate development, and preserve legacy systems. They translate instructions, simulate hardware,
and optimize performance.
Installation of Emulator

Step 1: Download
Click it and you will get a Website.

Introduction and Installation of Emu8086 in windows

Step 2: Downloading start

Click "Download for PC" button. This opens a new tab and the downloading starts.Observe that the

zip file of 3Mb in your folders .

Step 3:Steup
Click on the small arrow, open the folder. A folder will be pop up.Double click at "Setup". It will ask
for the permission. Allow it by clicking "yes".

The Window will appear that will start the setup process.
Click "Next" to continue the process.

Step 4:Continue to next


A new will be appear like this:

Close All the Application running applications and click "Next".

Step 5:Choose the installation folder

Now, You have to give the path for the folder .By default the path is given for the C directory but you

can change it by clicking Browse.


Read all the tabs appeared after it and then Click "Next".

Step 6: Finish the installation


In the last window, it will ask does we want to launch the Emu8086 or Does we wish to read the
instruction.
Choose the action you want to be launched or mere remove the tick mark and the setup is finished.

The Emu8086 icon will appear on your desktop. You can use it whenever you want.

Register
When we learn about register a big question arises in our mind that what are register.so here we will
discuss about short intro.

These are small, high-speed memory locations within the Central Processing Unit (CPU) that store
data temporarily while it is being processed.

Characteristics:

1. Small size (typically 8-64 bits)


2. Fast access times (faster than main memory)
3. Limited number (varies by CPU architecture)
4. Used for temporary storage of data and instructions

Types of Registers:
1. General-Purpose Registers (GPRs): Used for arithmetic, logical, and data transfer operations.
2. Index Registers: Used for array indexing and addressing.
3. Stack Registers: Used for stack operations (push, pop).
4. Pointer Registers: Used for memory addressing.
5. Flag Registers: Store status flags (e.g., carry, overflow).
6. Instruction Registers: Hold the current instruction.
7. Program Counter (PC): Stores the address of the next instruction.

Examples:
x86 Architecture:

1. EAX (Accumulator)
2. EBX (Base Index)
3. ECX (Counter)
4. EDX (Data)
5. ESI (Source Index)
6. EDI (Destination Index)
7. ESP (Stack Pointer)
8. EBP (Base Pointer)

ARM Architecture:

1. R0-R12 (General-Purpose Registers)


2. SP (Stack Pointer)
3. LR (Link Register)
4. PC (Program Counter)

Assembly Language Usage:


Registers are used extensively in assembly language programming to:

1. Store and manipulate data


2. Perform arithmetic and logical operations
3. Control program flow
4. Access memory locations

Example Assembly Code (x86):


1. assembly
2. MOV EAX, 5 ; Load 5 into EAX register
3. ADD EAX, 3 ; Add 3 to EAX
4. MOV EBX, EAX ; Copy EAX to EBX

In summary, registers are essential components of CPU architecture, providing fast and efficient data
storage and manipulation for assembly language programming.

Lab Session 01

Print a chracter
.model small

.stack 100h

.data

.code

main proc

mov dl,'w'

mov ah,2

INT 21h

mov dl,'a'

mov ah,2

INT 21h

mov dl,'s'

mov ah,2

INT 21h

mov dl,'e'

mov ah,2

INT 21h

mov dl,'e'

mov ah,2

INT 21h

mov dl,'m'

mov ah,2
INT 21h

main endp

end main

Lab Session 02

Arithematic Operation in Assembly language

These are some arithematic operation in assembly language.

1. Register Addressing Mode


2. Intermediate Addressing Mode
3. Increament(INC)
4. Decreament(DEC)
5. Multliplication
6. Divission

Register Addressing Mode

.model small

.stack 100h

.data

.code

main proc

mov Ax, 2h

mov Bx, 3h

ADD Ax , Bx

mov Dx,Ax

mov Ah,0Eh

INT 0x10

main endp

end main

Immediate Addressing mode


.model small
.stack 100h

.data

.code

main proc

Mov AX, 2h

ADD Ax, 3h

Mov ah, 3h

MOV DL, AL

MOV AH, 0EH

INT 0x10

main endp

end main

Increament(INC)
.model small

.stack 100h

.data

.code

main proc

mov ax, 3h

ADD Ax, 5h

INC Ax

mov dl,al

mov AH, 0EH

INT 0x10

main endp

end main

Decreament(DEC)
.model small

.stack 100h
.data

.code

main proc

mov AX,3h

DEC Ax

mov dl,al

mov AH, 0EH

INT 0x10

main endp

end main

Multiplication
.model small

.stack 100h

.data

.code

main proc

Mov Ax, 4h

Mov Bx,2h

MUL Bx

mov dl,al

mov AH, 0EH

INT 0x10

main endp

end main

Division
.model small

.stack 100h

.data
.code

main proc

Mov Ax, 4h

Mov Bx,2h

DIV Bx

mov dl,al

mov AH, 0EH

INT 0x10

main endp

end main

You might also like