LAB-3 Assembling, Linking and Running
LAB-3 Assembling, Linking and Running
Assemble-Link-Execute Cycle
Listing File
Map File
Assemble-Link Execute Cycle
The following diagram describes the steps from creating a
source program through executing the compiled program.
If the source code is modified, Steps 2 through 4 must be
repeated.
Assemble in MASM
Executes ML.EXE (the Microsoft Assembler) to
assemble your programs
Linkxxx.exe(Microsoft Linker)
Command-Line syntax:
Ml progName.asm ENTER
(progName includes the .asm extension and is written in
notepad usually)
L1:
mov ax,5H
mov bx,10H
add ax,bx
mov bx,15H
add ax, bx
; Return to DOS
MOV AX , 4C00H
INT 21H
CODE ENDS
END ENTRY
Program 1(.Exe files)
Write a program in MASM to add three hex
numbers 5,10,15:
.MODEL SMALL
.STACK 64
.DATA
.CODE
MAIN PROC FAR
MOV AX,@DATA
MOV DS,AX
MOV AX,05H
MOV BX,10H
ADD AX,BX Program Code
MOV BX,15H
ADD AX,BX
MOV AH,4CH
INT 21H
MAIN ENDP
END MAIN
Program 1 (.com files)
Write a program in NASM to add two
numbers Num1 and Num2 and store the
result in Sum
[ORG 0x100]
mov ax,Num1
mov bx,Num2
add ax,bx Actual Coding
mov Sum,ax
mov ax, 0x4c00
int 0x21
Num1 DW 5
Num2 DW 15 Variables Declarations
Sum DW 0
Program 1 (.exe files)
Write a program in MASM to add three
numbers num1, num2, and num3 and store
the result in Sum
.MODEL SMALL
.STACK 32
.DATA
num1 DW 5
num2 DW 10
num3 DW 15
sum DW 0
.CODE
MAIN:
MOV AX, @DATA
MOV DS, AX
mov ax, num1 ; value at num1
mov bx, num2
add ax,bx
mov bx, num3
add ax,bx
mov sum,ax ;location num1
; RETURN TO DOS
MOV AX, 4C00H
INT 21H
END MAIN
Program 1 (.exe files)
Write a program in MASM to add three
numbers num1, num2, and num3 and store
the result in Sum—See if it works OK?
.MODEL SMALL
.STACK 32
.DATA
num1 DW 5
DW 10
DW 15
DW 0
.CODE
MAIN:
MOV AX, @DATA
MOV DS, AX
mov ax, num1 ; value at num1,
mov bx, [num1+2] ;
add ax,bx
mov bx, [num1+4]
add ax,bx
mov [num1+6],ax
; RETURN TO DOS
MOV AX, 4C00H
INT 21H
END MAIN