0% found this document useful (0 votes)
65 views

1program To Display Single Character PRINT A Character

The document contains 20 programs written in Assembly language. The programs demonstrate various programming concepts like displaying characters, taking user input, performing arithmetic operations, using loops, conditional jumps, procedures, variables and more. Each program has a specific task like printing a number, adding two numbers, swapping values, multiplying numbers etc. to explain the related Assembly language concept.

Uploaded by

Muhammad Talha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views

1program To Display Single Character PRINT A Character

The document contains 20 programs written in Assembly language. The programs demonstrate various programming concepts like displaying characters, taking user input, performing arithmetic operations, using loops, conditional jumps, procedures, variables and more. Each program has a specific task like printing a number, adding two numbers, swapping values, multiplying numbers etc. to explain the related Assembly language concept.

Uploaded by

Muhammad Talha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

1PROGRAM TO DISPLAY SINGLE CHARACTER

PRINT a character

dosseg

.model small

.stack 100h

.data

.code

main proc

mov dl,'A'

mov ah,2

INT 21H

mov ah,4ch

INT 21H

main endp

end main

2.PROGRAM TO PRINT A NUMBER (0-9)

dosseg

.model small

.stack 100h

.data
.code

main proc

mov dl,5

add dl,48

mov ah,2

INT 21H

mov ah,4ch

INT 21h

main endp

end main

3. PROGRAM TO PERFORM ARITHMETIC OPERATION

ADDITION OF 2 NUMBERS

dosseg

.model small

.stack 100h

.data

.code

main proc

mov bl,3

mov cl,2
add bl,cl

add bl,48

mov dl,bl

mov ah,2

INT 21H

mov ah,4ch

INT 21H

main endp

end main

4.PROGRAM TO TAKE INPUT(WITH ECHO)

dosseg

.model small

.stack 100h

.data

.code

main proc

mov ah,l

INT 21H

mov dl,al

mov ah,2
INT 21H

main endp

end main

5.PROGRAM TO TAKE INOUT (WITHOUT ECHO)

dosseg

.model small

.stack 100h

.data

.code

main proc

mov ah,8

INT 21H

mov ah,4ch

INT 21H

main endp

end main

6. PROGRAM USING FEED NEW LINE ASCII CODE

dosseg

.model small
.stack 100h

.data

msg1 db 'hello$'

msg2 db 'word$'

.code

main proc

MOV AX.@datra

MOV DS,AX

mov DX,offset msg1

MOV AH,9

INT 21H

MOV DX.10

MOV AH,2

INT 21H

mov DX,offset msg2

MOV AH,9

INT 21H

MOV AH,4CH

INT 21H

MAIN ENDP

END MAIN
7.loop without using Inc on single line (0-9)

dosseg

.model small

.stack 100h

.data

.code

main proc

Mov cx,10

mov dx,48

start:

mov ah,2

INT 21H

Add dx,l

loop start

mov ah,4ch

INT 21H

main endp

end main
8.loop with using inc (0-9)

dosseg

.model small

.stack 100h

.data

.code

main proc

mov cx,10

mov dx,48

start:

mov ah,2

INT 21H

inc dx

loop start

mov ah,4ch

INT 21H

main endp

end main

9.loop for decrement

dosseg
.model small

.stack 100h

.data

.code

main proc

mov cx,10

mov dx,57

start:

mov ah,2

INT 21H

Sub dx,l

loop start

mov ah,4ch

INT 21H

main endp

end mian

10.Unconditional jump program

dosseg

.model small

.stack 100h
.data

.code

main proc

lI:

mov dl,'A'

mov ah,2

INT 21H

jmp LI

mov ah,4ch

INT 21H

main endp

end main

11.Conditional jump program

dosseg

.mpodel small

.stack 100h

.data

msg1 db,'number is equal$'

msg2 db,'number is not equal$'

.code
main proc

mov ax,@data

mov ds,ax

mov dl,'3'

mov ah,l

INT 21H

CMP al,dl

je L

move dx,offset msg2

mov ah,9

INT 21H

mov ah,4ch

INT 21H

move dx,offset msgl

mov ah,9

INT 21H

mov ah,4ch

INT 21H

main endp

end main
12. Programming example for nested loop

dosseg

.model small

.stack 100h

.data

.code

main proc

Mov cx,10

mov dx,48

start:

mov ah,2

INT 21H

Add dx,1

loop start

mov ah,4ch

INT 21H

main endp

end main
13.programming of loop using new line

dosseg

.model small

.stack 100h

.data

.code

main proc

mov cx,5

mov dx,49

start:

mov ah,2

INT 21H

add dx,l

mov bx,dx

mov dx,10

INT 21H

mov dx,13

INT 21H

mov dx,bx

loop start
mov ah,4ch

INT 21H

main endp

end main

14. Programing swapping two 2 numbers using push pop

dosseg

.model small

.stack 100h

.data

.code

main proc

mov ax,'2'

mov bx,'5'

push ax

push bx

pop ax

pop bx

mov dx,ax

mov ah,2
int 21h

mov dx,bx

mov ah,2

int 21h

mov ah,4ch

int 21h

main endp

end main

15. Program print 3 char name using push pop

dosseg

.model small

.stack 100h

.data

.code

main proc

mov ax,'a'

mov bx,'l'

mov cx,'i'

push ax

push bx
push cx

pop ax

pop bx

pop cx

mov dx,ax

mov ah,2

int 21h

mov dx,bx

mov ah,2

int 21h

mov dx,cx

mov ah,2

int 21h

mov ah,4ch

int 21h

main endp

end main

16.Program using division

dosseg
.model small

.stack 100h

.data

.code

Q db?

R db?

.code

main proc

mov ax,26

mov bl,5

Div bl

mov Q,AL

mov R,AH

mov dl.Q

add dl,48

mov ah,2

int 21h

mov dl,R

add dl,48

mov ah,2

int 21h
mov ah,4ch

int 21h

main endp

end main

17.Program multiply 2 numbers

dosseg

.model small

.stack 100h

.data

.code

main proc

mov bl,3

mov al,2

mul bl

mov dx,ax

add dl,48

mov ah,2

int 21h

mov ah,4ch

int 21h
main endp

end main

18.Program multiply 2 numbers and result in form of 2 digits

dooseg

.model small

.stack 100h

.data

.code

main proc

mov bl,5

mov al,2

mul bl

AAM

mov ch,ah

mov cl,al

mov dl,ah

add dl,48

mov ah,2

int 21h
mov dl,cl

add dl,48

mov ah,2

int 21h

mov ah,4ch

int 21h

main endp

end main

PROGRAM 19:HOW TO DEFINE AND INITIALIZED VARIABLE

dosseg

.model small
.stack 100h
.data
var1 db '1' ;variable define and initialized
.code
main
proc

MOV AX,@data ; @ data is name of data directive where the variable/data is stored
;while ax will store that address(address is 16 bits)
MOV DS,AX ;address will be moved to DS(data segment get initialized as a
;heap memory(random or direct access for fastly data access
MOV DL, var1 ;the size of variable is 1 byte and size of dl is also 1 byte so value
;of var1 will be stored in register(size of register=size of variable)
MOV
AH,2

INT
21H
MOV AH, 4CH ; return
control to DOS INT 21H

MAIN ENDP
END MAIN

PROGRAM 20:HOW TO DEFINE VARIABLE IN .DATA AND INITIALIZED VARIABLE IN. CODE

dosseg

.model small
.stack 100h
.data
var1 db ? ;variable define but not initialized
.code
main
proc

MOV AX,@data ; @ data is name of data directive where the variable/data is stored
;while ax will store that address(address is 16 bits)
MOV DS,AX ;address will be moved to DS(data segment get initialized as a
;heap memory(random or direct access for fastly
data access MOV var1,'2' ;the variable initialized

MOV
DL,var1
MOV
AH,2 INT
21H
MOV AH, 4CH ; return control
to DOSINT 21H

MAIN ENDP
END MAIN

You might also like