You are on page 1of 4

Lab No 3

USMAN INSTITUTE OF TECHNOLOGY


Department of Computer Science
Computer Organization & Assembly Language – CS223

3
Instructor: Muhammad Wasim
Semester: BS – IV

Objective:

1. Understanding of Assembler
2. Steps of Assembly Programs
3. Learning of Assembler Programs
4. Learning of Linker Program
5. Learning of Running a program
6. Learning of Directives

Name of Student: _____________________________________________

Roll No: ______________________________Sec. __________

Date of Experiment: ___________________________________________

Marks Obtained/Remarks: _____________________________

Signature: _____________________________

1
Lab No 3

Introduction:
Assembler & Debug
Assembler Debug
- Very versatile - Not so versatile
- Good on long program - Good on short program
- More program overload - Low program overloaded
- Not easy to run - Easy to run
- Isolated from the machine - Close to the machine

Steps for Assembly Programs


1. Write the program in any text editor, e.g DOS, Notepad etc, and save with extension .asm
2. Run masm.exe, input file name it will generate obj file which indicate error if any.
3. Run Link.exe, input file name.obj, it will generate exe file.

The assembler Program:


The assembler program converts a symbolic source module (file) into a hexadecimal object file.
Each source file should have an extension of ASM.
e.g: C:\assembler>masm myprog.asm
Microsoft (R) Macro Assembler Version 4.00
Copyright (C) Microsoft Corp 1981, 1983, 1984, 1985. All right reserved
Object filename [myprog.OBJ]:
Source listing [NUL.LST]:
Cross-reference [NUL.CRF]:
50962 Bytes symbol space free
0 Warning Errors
0 Severe Errors

The Linker Program:


The linker program reads the object file that is created by the assembler program and links them
together into a single execution file. An execution file is created with the file name extension
EXE.

e.g: C:\Assembler>link myprog


Microsoft (R) 8086 Object Linker Version 3.05
Copyright (C) Microsoft Corp 1983, 1984, 1985. All rights reserved.
Run File [MYPROG.EXE]:
List File [NUL.MAP]:
Libraries [.LIB]:
Warning: no stack segment

To Run a Program:
C:\Assembler>myprog

Turbo Debug (TD):

2
Lab No 3

The Turbo Debug mode is use for debug a program, this mode trace (F7) and run (F9) a program
after debugging.

Directives:
Directives are information for assembler or compiler that will not be executed.

Examples of Directives:
END (Not executed, message to assembler about end of program not to compiler).
ENDS (End of segment).
PROC (Start of procedure (subroutine))
ENDP (End of procedure (subroutine), same as in C {----------------})

DB (Define bytes) Not executed b/c these are for


DW (Define word) assembler, can execute only if it is
DD (Define double word) for microprocessor, which is not
DQ (Define quad bytes) possible.

Types of Procedures:

1. Far A program can store at any memory location. It store in other segments. It means the
procedure with exit other than the calling program.
2. Near The program will store in the same segment. It means the procedure with exit
only the calling program.

Main abc
Proc Far Proc Near
------------ -------------
------------ -------------
------------ -------------
call abc Return
It occupies more memory space It occupies less memory space (Large Program)
(Small Program)
NOTE: Data segment and extra segment are initialized at the beginning of program, but
code segment and stack segment registers are initialized by OS.
Instruction:
Instructions are information for microprocessor which will be executed (always executed).

Services:
01 Key board input with echo
08 Echo off
02 Display console/Monitor
05 Printer out put
09 String out put (DX register load offset of string to be printed)
Note: All services required AH register.
Trace the out put of the following program.
Program 1 Out Put
; To Print an ASCCII no. on computer screen
;***************************************

3
Lab No 3

***

DATA_SEG SEGMENT

DATA_SEG ENDS

CODE_SEG SEGMENT
ASSUME CS:CODE_SEG, DS:DATA_SEG

MAIN PROC FAR

MOV AH,02 ;AH=02, PRINT ON MONITOR.


MOV DL,041H ;ASSCII OF 'A'
INT 21H ;TO DISPLAY
MOV AH,04CH ;AH=4CH, EXIT TO DOS.
INT 21H

MAIN ENDP ;ENDP= END PROCEDURE

CODE_SEG ENDS
END MAIN

You might also like