Docsity

Assembly Language Lab: Assembler, MASM, NASM, TASM, Emulator, Linker - Prof. Anwar, Lab Reports of Mathematics

Partial preview of the text

Download Assembly Language Lab: Assembler, MASM, NASM, TASM, Emulator, Linker - Prof. Anwar and more Lab Reports Mathematics in PDF only on Docsity!

Computer Organization and Assembly

Language

Lab Manual (Lab 01)

Topic: To study assembler, MASM, NASM, TASM, Emulator, Linker, Turbo

Assembler

Course Instructor:

Lab Instructor:

Session: Spring 2021

School of Systems and Technology

UMT Lahore Pakistan

Objectives: Introduction of assembler. Some concepts and assembler setting snapshot:

Assembly Language

An assembly language is a low-level programming language for computers, microprocessors, Microcontrollers, and other integrated circuits. It implements a symbolic representation of the binary machine codes and other constants needed to program a given CPU architecture. This representation is usually defined by the hardware manufacturer, and is based on mnemonics that symbolize processing steps (instructions), processor registers, memory locations, and other language features. An assembly language is thus specific to certain physical (or virtual) computer architecture.

Machine Language

Machine language is a pattern of bits that represent the OPCODE and operands, directly executable by the CPU. The following is a short machine language program or the IBM PC. Assembly Language Machine Language Operations MOV AX,A 10100001 00000000 00000000 Fetch the contents of memory word 0 and put it in register AX. ADD AX,4 00000101 0000100 00000000 Add 4 to AX MOV A,AX 10100011 0000000 00000000 Store the contents of AX in memory word 0.

Introduction to Assembler, Linker and Debugger

Assembler

It is a system program which converts the assembly language program instructions into machine executable instructions. For example: Microsoft Macro Assembler (MASM), Borland Turbo Assembler (TASM), Open Source Netwide Assembler (NASM) etc.

MASM

The Microsoft Macro Assembler (MASM) is an x86 assembler for MS-DOS and Microsoft Windows. It supports a wide variety of macro facilities and structured programming idioms, Including high-level functions for looping and procedures. Later versions added the capability of producing programs for Windows.

TASM

Turbo Assembler (TASM) is an x86 assembler package developed by Borland. It is used with Borland's high-level language compilers, such as Turbo Pascal, Turbo Basic and Turbo C. The Turbo Assembler package is bundled with the linker, Turbo Linker, and is interoperable with the Turbo Debugger.

debugging.

1 Step

Creating an Assembly Language Program An assembly language program should be entered with any text editor and have the extension filename.asm.

2 Step

Assembling a Program

Once you have entered this program you need to assemble it. This is done using the following TASM command line syntax. TASM Filename.asm The .asm extension is assumed for the file. The files generated by this command will be; Filename.asm the source file Filename.obj generated by TASM Filename.lst the list file

Step 3

Linking a program

As a final step you need to run the Turbo linker (TLINK) to create an EXE (executable) file by the name of filename.exe. This is done by entering the following command. TLINK Filename.obj The .obj extension is assumed for the file. The files generated by this command will be; Filename.exe the Executable file

Step 4

Running DEBUG

TD, the Turbo Debugger, is run with the following command. TD Filename.exe

Step 5

Execution of Program

The execution of program is done by entering the following command. Filename.exe

First program in Assembly

The following program displays the string "this is my first program in 8086 assembly" on screen. .model small data_Seg segment 'data' ; Add your Data here st1 db "this is my first program in 8086 assembly",13,10,'$' data_Seg ends Code_Seg segment 'code' assume cs:code_Seg, ds:data_Seg, ss:stack_seg main proc far ; Set Segment Registers mov ax,data_Seg mov ds,ax ; Add Your Code Here mov ah, mov dx,offset st1 ;string display INT 21h ;exit to operating system MOV AH,4CH INT 21h MAIN endp code_seg ends ; set entry point and stop the assembler stack_Seg segment stack db 100h dup (?) stack_Seg ends end main YouTube tutorial: https://www.youtube.com/watch?v=m1e8RfmsCNI Required Files Link: TASM https://drive.google.com/file/d/0BxFfQqBvZCltMHdNbFFCZVJkUlE/view DOSBox https://www.dosbox.com/download.php?main= Basic Steps to install and run DosBox, TASM and Compile x86 Assembly Program in Windows 7 64 bit Version

  1. Download the TASM File from above link Step 4:
  2. Extract the contents of the .zip file. Step 5:
  1. Copy the extracted files to the folder TASM (or to the folder you've made awhile ago) Step 6:
  2. Download DOSBOX from the above given link Step 7:
  1. Put your assembly code (e.g .asm) in the same directory where you installed TASM and TLINK and run it by typing: TASM TLINK Step 9:
  1. The executable file is located in the folder TASM or your chosen directory. You can run it as it is or via CMD by typing .exe Step 10: Extra (Optional):
  2. The debug command was deleted in Windows 7 64 bit machines. The file that you've downloaded and installed has the 'debug' executable files. Now, you can run it via DOSBox by typing in DEBUG or DEBUG <your+executable+file>.exe.

Lab Task Task # 1:  Copy the above code in notepad and save the file in c:\temp folder or c:\turbo assembler folder with extension .asm i.e. First_program.asm

 Then go to the command prompt by writing cmd or go to the Dosbox

 Execute the .asm file saved above by writing the instruction tasm , tlink

 Observe the output