Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

CX: This is the counter register.

It is of 16 bits and is divided into two 8-bit


registers CH and CL to also perform 8-bit instructions. It is used in looping and
rotation.

AX: This is the accumulator. It is of 16 bits and is divided into two 8-bit registers
AH and AL to also perform 8-bit instructions. It is generally used for arithmetical
and logical instructions but in 8086 microprocessors.

BX: This is the base register. It is of 16 bits and is divided into two 8-bit registers
BH and BL to also perform 8-bit instructions. It is used to store the value of the
offset.

SI- This is the source index register. It is of 16 bits. It is used in the pointer
addressing of data and as a source in some string related operations. ... It is used in
the pointer addressing of data and as a destination in some string related
operations.

DI- This is the destination index register. It is of 16 bits. It is used in the pointer
addressing of data and as a destination in some string related operations. Its offset
is relative to extra segment.

A DB ? / B DW ? – scanf (emne user er theke nile AL e jabe)


MOV AH, 1 – scanf (emne nile automatic AL e jabe tasi AL theke soraia rakhte
hobe onnokhane)
MOV AH, 2 – printf
Perfect New line -
MOV AH,2
MOV DL, 10
INT 21H
MOV AH,2
MOV DL, 13
INT 21H
MOV AH, 4CH – return 0;
MAIN ENDP
END MAIN – Program last e ses korar jonno

Kono message Print korar jonno


EXAMPLE-
.DATA

A DB “Something $”

B DB 10, 13, "Something 2 $"

. CODE

MAIN PROC

MOV AX, @DATA

MOV DS, AX

MOV AH, 9

LEA DX, A

INT 21H

DIVISION:
Reminder – AH
Result- AL
AH 0 korte hobe

.MODEL SMALL

.STACK 100H

.DATA

A DB "Enter First number: $"

B DB 10, 13, "Enter Second number: $"

C DB 10, 13, "Your Result: $"

D DB 10, 13, "Your Reminder: $"

.CODE

MAIN PROC

MOV AX, @DATA

MOV DS, AX

MOV AH, 9

LEA DX, A

INT 21H

MOV AH, 1

INT 21H

SUB AL, 48

MOV BL, AL

MOV AH, 9

LEA DX, B

INT 21H

MOV AH, 1

INT 21H
SUB AL, 48

MOV AH, 0

DIV BL

MOV BL, AL

MOV BH, AH

MOV AH, 9

LEA DX, C

INT 21H

MOV AH, 2

MOV DL, BL

ADD DL, 48

INT 21H

MOV AH, 9

LEA DX, D

INT 21H

MOV AH, 2

MOV DL, BH

ADD DL, 48

INT 21H

EXIT:

MOV AH, 4CH

INT 21H

MAIN ENDP

END MAIN
MULTIPLICATION:
Multiplicatin e AL e ekta value thaktei hobe
MOV CX, AX jate 2 digit er sonkhao print korte pari emne to amra just AL part ta
print kori but AH part ta harai jai

.MODEL SMALL

.STACK 100H

.DATA

A DB "Enter First number: $"

B DB 10, 13, "Enter Second number: $"

C DB 10, 13, "Your Result: $"

.CODE

MAIN PROC

MOV AX, @DATA

MOV DS, AX

MOV AH, 9

LEA DX, A

INT 21H

MOV AH, 1

INT 21H

SUB AL, 48

MOV BL, AL

MOV AH, 9

LEA DX, B
INT 21H

MOV AH, 1

INT 21H

SUB AL, 48

MUL BL

AAM

MOV CX, AX

MOV AH, 9

LEA DX, C

INT 21H

MOV AH, 2

MOV DL, CH

ADD DL, 48

INT 21H

MOV AH, 2

MOV DL, CL

ADD DL, 48

INT 21H

EXIT:

MOV AH, 4CH

INT 21H

MAIN ENDP

END MAIN
Conditional statement:
CMP: Compare
JG: Greater hoile jao to....
JLE: Less then hoile jao to....
JE: Equal hoile jao to....
JNE: Not Equal hoile jao to....
JMP: Jump to....
INC: increment
DEC: decrement

Summation of 1+3+5+7+......+99:
.MODEL SMALL

.STACK 100H

.DATA

JOG DW ?

.CODE

MAIN PROC

MOV AX, @DATA

MOV DS, AX

MOV CX, 50 ; COUNTER VALUE


MOV AX, 0 ; LOWER VALUE

MOV BX, 99 ;UPPER VALUE

SUM:

ADD AX, BX ;0+99 -> 0+97

SUB BX, 2 ;99-2 = 97

MOV JOG, AX

LOOP SUM

MAIN ENDP

END MAIN

Copying one array to another:


INCLUDE 'EMU8086.INC'

.MODEL SMALL

.STACK 100H

.DATA

BOB DB 5 DUP(?)

MARLI DB 5 DUP(0)

.CODE

MAIN PROC

MOV AX,@DATA

MOV DS,AX

MOV SI,OFFSET BOB

MOV CX,5
PRINT 'Enter 5 values for BOB- '

INPUT:

MOV AH,2

MOV DL,32

INT 21H

MOV AH,1

INT 21H

MOV [SI],AL

MOV BL,[SI]

MOV AH,32

INC SI

LOOP INPUT

MOV SI,OFFSET BOB

MOV DI,OFFSET MARLI

MOV CX,5

NEWLINE:

MOV AH,2

MOV DL, 10

INT 21H

MOV AH,2

MOV DL, 13

INT 21H

PRINT 'After copying all the elements of BOB to MARLI- '


OUTPUT:

MOV AH,2

MOV DL,32

INT 21H

MOV AH,2

MOV BL,[SI]

MOV [DI],BL

INT 21H

MOV AH,2

MOV DL,[DI]

INT 21H

INC SI

INC DI

LOOP OUTPUT

EXIT :

MOV AH,4CH

INT 21H

MAIN ENDP

END MAIN

You might also like