Bismillahir Rahmanir Rahim
Hey guys, what's up?I'm coming back.Now I'm showing you How Can compile a assembly program.
Click here to collect some necessary files and software.
Click here to collect some necessary files and software.
At first open a text editor or notepad and write your code example:
data segment msg db "My first assembly program. $" data ENDs stack segment db 100 Dup(0) stack ENDs code segment Assume cs:code,ds:data,ss:stack start: mov ax,seg data mov ds,ax mov ax,seg stack mov ss,ax mov dx,offset msg mov ah,09h int 21h mov ax,4c00h int 21h code ENDs End start
In notepad like as
then file name: Your_program_name.ASM (example: hello.asm)
Save as file type: All files
hit SAVE button. One thing remember your file location will be where your asm file are stored. otherwise you have to face compiling errors.
my program link is in my pc: E:\asm
Code writing is done!
Now Compile the program.........
Here describe two way to compile....
Using cmd command:create a folder on D: drive. Name it ASM,
Debugging the program: stepwise execute each instructions and inspect the values in variables.
Save as file type: All files
hit SAVE button. One thing remember your file location will be where your asm file are stored. otherwise you have to face compiling errors.
my program link is in my pc: E:\asm
Code writing is done!
Now Compile the program.........
Here describe two way to compile....
Using cmd command:create a folder on D: drive. Name it ASM,
Place your assembly program
file, MASM.EXE, LINK.EXE, MYLIB1.LIB in this folder,
Assemble the program with
MASM.EXE, linker LINK.EXE
At DOS prompt( or cmd ) type the following !
·
Create the translated file first.obj with assembler:
·
>masm first.asm <enter><enter><enter><enter>
·
Create the executable file first.exe with linker
·
>link first.obj <enter><enter><enter><enter><enter>
·
run the executable file:
>first <enter>
The output will be 04 as expected.
using cmd command some tips:
for jump one drive to another drive type Drive_name: hit Enter (example: E:)
for jump one folder to another folder type cd folder_name hit enter (Example cd asm)
In the case of Windows 7 operating system we have to use the DOSBOX package to prepare and run the program.
for jump one drive to another drive type Drive_name: hit Enter (example: E:)
for jump one folder to another folder type cd folder_name hit enter (Example cd asm)
In the case of Windows 7 operating system we have to use the DOSBOX package to prepare and run the program.
a. Create a folder on D: drive.
Name it ASM,
b. Place your assembly program
file, MASM.EXE, LINK.EXE, MYLIB1.LIB in this folder,
c. Double click on DOSBOX.EXE,
d. Type-->: mount f d:/asm (d:/asm is your program link in your pc)
e. Type -->: f:
f. Run the commands in #b.
#
#
·
Create the translated file first.obj with assembler:
·
>masm first.asm <enter><enter><enter><enter>
·
Create the executable file first.exe with linker
·
>link first.obj <enter><enter><enter><enter><enter>
·
run the executable file:
>first <enter>
The output will be 04 as expected.
Debugging the program: stepwise execute each instructions and inspect the values in variables.
1. Type DEBUG nameOfExecutivefile.exe
2. Type -u to see the code and
instruction of program
3. Type -r to see the contents
of the registers and next instruction
4. Type -t to run an
instruction at a time ( single stepping ):
5. Type -p to run
procedure type INT XX
6. Type –g to complete the
program
7. Type -q to exit DEBUG
Reference:
Dr Ehteshamul Haque (lecture)
---------HAPPY CoDing---------