You are on page 1of 9

Assembly Tutorials

BY MO3AZ
General Registers
16 bit

AX AH AL

BX BH BL

CX CH CL

DX DH DL

8 bit 8 bit

MO3AZ SAIF
More Instructions
MOV AX , 5h Used to move data from the source to the destination operand ( AX = 5h )

ADD , SUB ( Adds , Subtracts ) the source operand to the destination operand.

Multiplies the contents of the AX register (implicitly) by the value of operand,


MUL BX , and the result is stored in the DX:AX register pair.

Used to obtain the memory address (offset) of a variable , array or label.


OFFSET Arr Mostly used with arrays and strings.

MO3AZ SAIF
Variables
Name Size Initial Value

DB DW
1 Byte 2 Byte

X DB 10H SUM DW ?
Null Value

MO3AZ SAIF
Arrays
Name Size of each element Initial Value

DB DW
1 Byte 2 Byte

Arr DB 10H , 15H , 20H , 30H

MO3AZ SAIF
I/O Instructions
INT 21H

AH = 01H AH = 02H AH = 09H


Reading a single value from
Print Single Value From DL Print String From DX
the console and storing it in AL

MSG DB ‘HELLO’ , ‘$’


MOV DL , ‘*’
MOV AH , 01H MOV DX , OFFSET MSG
MOV AH , 02H
INT 21H MOV AH , 09H
INT 21H
INT 21H

MO3AZ SAIF
Conditions
CMP AX , BX Compare AX with BX and jump to the
EQ label if equal. Use JE (Jump if
Equal) instruction
JE EQ
------
------
JMP END_IF Jump to End_If Label to end Program
EQ:
------ Labels used as markers for specific
------ locations in the code
END_IF:
RET
MO3AZ SAIF
LOOPS
Cx Register => Counter of LOOP

Initialize the counter of the


MOV CX , 5 loop. This loop works 5 times.
LP:
------
LOOP LP
RET
Decrease CX ( CX - 1 ), jump to label if CX not zero.
IF CX = 0 -> End Loop

MO3AZ SAIF
Playlists Link
Mohamed Reda

Ahmed Sallam

Sherif Ezzat

MO3AZ SAIF

You might also like