Lab # 01 Introduction To Assembly and Assemble: Programming Languages
Lab # 01 Introduction To Assembly and Assemble: Programming Languages
OBJECTIVE:
Developing basic understanding about Assembly and Assembler (emu8086)
INTRODUCTION:
Programming Languages
A programming language is an artificial language that can be used to control the behavior of a
machine, particularly a computer. Programming languages, like human languages, have syntactic
and semantic rules to define meaning.
3. Machine Language
Machine language is at the lowest level, because it is the actual binary code of 1s and 0s that the
computer understands. These are designed to give a better machine efficiency.
Registers Classification
The registers inside the microprocessor are classified according to the function they perform In
general, they are classified as
1. Data registers
2. Address registers
3. Segment register
4. Offset registers
5. Status register
AX (Accumulator Register)
· It is the preferred register to use in the arithmetic, logic and data transfer instructions because
its use generates the shortest machine code.
· In multiplication and division operations, one of the numbers involved must be in AX or AL.
· Input and output operation also requires the use of AX and AL.
BX (Base Register)
Page 1
CX (Count Register)
· Program loop instructions are facilitated by the use of CX register, serves as a loop counter.
· Also used as a counter in the string operations.
· CL is used as count in instructions that shift and rotate bits.
DX (Data Register)
· It is used in multiplication and division operations.
· It is used in IO operation like DL in character output and DX in string output functions.
Register Size:
· We have three different sizes of registers:
· 8-bit register: AH, AL, BH, BL, CH, CL, DH, DL
· 16-bit registers: AX, BX, CX, DX, SP, BP, SI, DI, SS, DS, CS, ES, FS, GS, IP, FLAGS
· 32-bit registers: EAX, EXB, ECX, EDX, ESI, EDI, ESP, EBP, EIP, and EFLAGS.
Examples:
· MOV AH, BL; 8-bits register to register
· MOV BX, AX; 16-bits register to register
· MOV byte1, BL; 8-bit register to memory.
· MOV AX, word1 ;16-bit memory to register
TITLE LAB01
.MODEL SMALL
.STACK 100H
.DATA
MESSAGE1 DB 0AH, 0DH, "INDUS UNIVERSITY$"
.CODE
MAIN:
MOV AX, @DATA
MOV DS, AX
MOV DX, OFFSET MESSAGE1
MOV AH, 09H
INT 21H
Procedure
· Open a notepad editor and create a new file with any name but with the extension “.asm”,eg
lab1.asm. save it to bin folder of tasm.
· Now copy and paste the following code into that file and save again
· Goto command prompt and type cd c:\tasm\bin
· Now type “tasm filename.asm” and press enter
· Now type “tlink filename.obj” and press enter
· Now type “filename.exe” and hit enter
Page 2
·
· Example :
Lab Tasks
CODE:
section .data
msg db "Saadat Irfan", 0ah
section .text
global _start
_start:
mov rax, 1
mov rdi, 1
mov rsi, msg
mov rdx, 13
syscall
mov rax, 60
mov rdi, 0
syscall
CODE:
section .data
msg db "4-15/2019/010", 0ah
section .text
global _start
_start:
mov rax, 1
mov rdi, 1
mov rsi, msg
mov rdx, 13
Page 3
syscall
mov rax, 60
mov rdi, 0
syscall
3. Test your code after removing the $ sign from the string
A) As per the observation after removing $ symbol from the code there was no significant
change noticed in output.
Page 4