Program To Print A Single Character On Screen: Facebook: Gmail: Youtube
Program To Print A Single Character On Screen: Facebook: Gmail: Youtube
Program To Print A Single Character On Screen: Facebook: Gmail: Youtube
.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
Program to print your name on screen with characters using mov ah, 2
.model small
.stack 100h
.data
.code
main proc
mov dl, 'A'
mov ah,2
INT 21h
www.youtube.com/Programology
mov dl, 'L'
mov ah,2
INT 21h
end main
.model small
.stack 100h
.data
.code
main proc
mov ah,1
INT 21h
mov dl, al
mov ah,2
INT 21h
mov ah,4ch
INT 21h
main endp
end main
www.youtube.com/Programology
Program to add two numbers
.model small
.stack 100h
.data
.code
main proc
mov bl,2
mov dl,1
add dl,bl
add dl,48
mov ah,2
INT 21h
mov ah,4ch
INT 21h
main endp
end main
.model small
.stack 100h
.data
.code
main proc
mov cx, 26
mov ah, 2
mov dl, 65
L1:
int 21h
inc dl
www.youtube.com/Programology
loop L1
mov dl, 10
mov ah,2
INT 21h
mov dl, 13
mov ah,2
INT 21h
mov cx, 26
mov dl, 97
mov ah, 2
L2:
int 21h
inc dl
loop L2
mov ah,4ch
INT 21h
main endp
end main
.model small
.stack 100h
.data
S1 db "Helloworld$"
.code
main proc
mov ax,@data
mov ds,ax
lea dx,s1
mov ah,9
INT 21h
www.youtube.com/Programology
mov ah,4ch
INT 21h
main endp
end main
.MODEL SMALL
.STACK 100H
.DATA
STRING_1 DB 'Ali$'
STRING_2 DB 'Hassan Soomro $'
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
MOV AH, 2
MOV DL, 10
INT 21H
MOV DL, 13
INT 21H
LEA DX, STRING_2
MOV AH, 9
INT 21H
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN
Program to input a capital letter from user and convert it into small letter (uppercase
to lowercase)
.model small
.stack 100h
www.youtube.com/Programology
.data
.code
main proc
mov ah, 1
int 21h
mov dl, al
add dl,32
mov ah, 2
int 21h
mov ah,4ch
int 21h
main endp
end main
Program to input a small letter from user and convert it into capital letter (lowercase
to uppercase)
.model small
.stack 100h
.data
.code
main proc
mov ah, 1
int 21h
mov dl, al
sub dl,32
mov ah, 2
int 21h
mov ah,4ch
int 21h
main endp
end main
www.youtube.com/Programology
Program to input string from user and print it
.model small
.stack 100h
.data
var1 db 100 dup("$")
.code
main proc
mov ax,@data
mov ds,ax
mov si,offset var1
l1: mov ah,1
int 21h
cmp al,13
je printString
mov [si],al
inc si
jmp l1
printString:
mov dx, offset var1
mov ah,9
int 21h
mov ah,4ch
int 21h
main endp
end main
.model small
.stack 100h
.data
var1 db 100 dup("$")
.code
main proc
mov ax,@data
mov ds,ax
mov bl, 0 ; counts the length of string
mov si,offset var1
l1: mov ah,1
int 21h
www.youtube.com/Programology
cmp al,13
je printString
mov [si],al
inc si
inc bl
jmp l1
printString:
mov dl, bl
mov ah,2
add dl, 48
int 21h
mov ah,4ch
int 21h
main endp
end main
Get an integer from user and display whether the number is even or odd.
.model small
.stack 100h
.data
ev db 'Even$'
od db 'Odd$'
.code
main proc
mov ax,@data
mov ds,ax
mov ah,1
int 21h
mov bl,2
div bl
cmp ah,0
je IsEven
mov dx,10
mov ah,2
int 21h
www.youtube.com/Programology
mov dx,13
mov ah,2
int 21h
mov dx,offset od
mov ah,9
int 21h
mov ah,4ch
int 21h
IsEven:
mov dx,10
mov ah,2
int 21h
mov dx,13
mov ah,2
int 21h
mov dx,offset ev
mov ah,9
int 21h
mov ah,4ch
int 21h
main endp
end main
.model small
.stack 100h
.data
.code
main proc
mov ax,@data
mov ds,ax
mov cx,1
mov ax,0
l1:
www.youtube.com/Programology
add ax,cx
add cl,2
cmp cl,100
jl l1
mov dx,0
mov bx,10
mov cx,0
l2:
div bx
push dx
mov dx,0
mov ah,0
inc cx
cmp ax,0
jne l2
mov ah,02h
l3:
pop dx
add dx,48
int 21h
loop l3
mov ah,4ch
int 21h
main endp
end main
.model small
.stack 100h
.data
.code
main proc
www.youtube.com/Programology
mov ax,@data
mov ds,ax
mov cx,0
mov ax,0
l1:
add ax,cx
add cl,2
cmp cl,100
jle l1
mov dx,0
mov bx,10
mov cx,0
l2:
div bx
push dx
mov dx,0
mov ah,0
inc cx
cmp ax,0
jne l2
mov ah,02h
l3:
pop dx
add dx,48
int 21h
loop l3
mov ah,4ch
int 21h
main endp
end main
.model small
.stack 100h
www.youtube.com/Programology
.data
STRING1 DB 1,2,7,5
res db ?
.code
main proc
mov ax,@data
mov ds,ax
mov cx, 4
mov bl, 0
LEA SI, STRING1
up:
mov al, [SI]
cmp al, bl
jl nxt
mov bl, al
nxt:
inc si
dec cx
jnz up
mov res,bl
mov dl,res
add dl,48
mov ah,2
int 21h
mov ah,4ch
int 21h
main endp
end main
.model small
.stack 100h
.data
STRING1 DB 2,1,7,5
res db ?
.code
main proc
mov ax,@data
www.youtube.com/Programology
mov ds,ax
mov cx, 4
mov res,bl
mov dl,res
add dl,48
mov ah,2
int 21h
mov ah,4ch
int 21h
main endp
end main
lea dx,msg
mov ah,9 ;print message
www.youtube.com/Programology
int 21h
mov ah,1
int 21h ;read data from user
cmp al,39h
jnle invalid
shr bh,cl
add bh,30h
xor bh,bh
mov bh,bl
add bh,30h
www.youtube.com/Programology
mov ah,2 ;print second last bit
mov dl,bh
int 21h
xor bh,bh
mov bh,bl
jmp exit
invalid:
exit:
mov ah,4ch
int 21h
main endp
end main
; Conversion program
; 1) Accept a decimal value (up to 5 digits), and print its hex value
; 3) Quit program.
.MODEL SMALL
.STACK 100h
.DATA
Menu DB 10, 13, 'Enter a choice (1 or 2):'
DB 10, 13, '1) Convert 1 to 5 Decimal values to Hex'
www.youtube.com/Programology
DB 10, 13, '2) Quit Program', 10, 13, '$'
MenuErr DB 10, 13, 'Choice must be a 1, 2, or 3!'
DB 10, 13, 'Try again!', 10, 13, '$'
AskDec DB 10, 13, 'Enter a number with 1 to 5 digits: ', 10, 13, '$'
.CODE
START PROC
MOV AX, @DATA ; Startup code
MOV DS, AX
dispMenu:
MOV DX, OFFSET Menu ; Display menu
MOV AH, 09H
INT 21H
dispErr:
MOV DX, OFFSET MenuErr ; Display menu error.
MOV AH, 09H
INT 21H
JMP dispMenu
goDec:
CALL DEC2HEX ; Call DEC2HEX procedure.
JMP dispMenu
goQuit:
www.youtube.com/Programology
START ENDP
DEC2HEX PROC ; *** Accept a decimal value (up to 5 digits) > print it's hex value.
Again:
SDiv1:
mov cx, 0
MOV BX, 16
pop ax
Div1:
www.youtube.com/Programology
ADD CX, 1 ; Add one to counter
MOV DX, 0 ; Clear Remainder (DX)
CMP AX, 0 ; Compare Quotient (AX) to zero
JNE Div1 ; If AX not 0, go to "Div1:"
END START
.data
counter db 0
curValue db 0
prevValue db 0
octal db 0
msg db "Enter a decimal number and press Enter: $"
octmsg db 13,10,"In octall: $"
www.youtube.com/Programology
.code
main proc
mov ax, @data ;initialize DS
mov ds, ax
accept:
mov ah, 01
int 21h ;read a digit
inc_ctr:
mov prevValue, al ;move al to prevValue
exit:
mov bl,prevValue ;move prevValue to bl
www.youtube.com/Programology
jmp convertTooctall ;jump to convertTooctall
convertTooctall:
main endp
end main
www.youtube.com/Programology
Display which is divisible by 2 and 3.
.model small
.stack 100h
.data
ev db 'divisible by 2$'
od db 'divisible by 3$'
.code
main proc
mov ax,@data
mov ds,ax
mov ah,1
int 21h
mov bl,2
div bl
cmp ah,0
je IsEven
mov dx,10
mov ah,2
int 21h
mov dx,13
mov ah,2
int 21h
mov dx,offset od
mov ah,9
int 21h
mov ah,4ch
int 21h
IsEven:
mov dx,10
mov ah,2
int 21h
mov dx,13
mov ah,2
www.youtube.com/Programology
int 21h
mov dx,offset ev
mov ah,9
int 21h
mov ah,4ch
int 21h
main endp
end main
Get 10 numbers from user and display after placing them in an array.
.model small
.stack 100h
.data
msg db 'Please 10 Digits: $'
array db 11 dup('$')
.code
main proc
mov ax,@data
mov ds,ax
lea si,array
l1:
mov ah,1
int 21h
cmp al,13
je Print
mov [si],al ; placing in array
inc si
jmp l1
Print:
mov dx,10
mov ah,2
int 21h
mov dx,13
www.youtube.com/Programology
mov ah,2
int 21h
mov dx,offset array ; displaying array to get confirm numbers are placed
mov ah,9
int 21h
mov ah,4ch
int 21h
main endp
end main
dosseg
.model small
.stack 100h
.data
msg db 'Please 5 Digits in terms of array: $'
array db 11 dup('$')
.code
main proc
mov ax,@data
mov ds,ax
lea si,array
l1:
mov ah,1
int 21h
cmp al,13
je Print
cmp al,bl
je l1
mov [si],al ; placing in array
inc si
jmp l1
Print:
mov dx,10
mov ah,2
int 21h
mov dx,13
mov ah,2
www.youtube.com/Programology
int 21h
mov dx,offset array ; displaying array to get confirm numbers are placed
mov ah,9
int 21h
mov ah,4ch
int 21h
main endp
end main
.code
main proc
mov ax,@data
mov ds,ax
L1:
mov ax, [si]
push ax
inc si
loop L1
mov cx, 4
L2:
pop dx
mov ah, 2
int 21h
inc si
loop L2
mov ah,4ch
int 21h
main endp
www.youtube.com/Programology
end main
printString:
mov cl, bl
print:
dec si
mov dx,[si]
mov ah,2
int 21h
loop print
mov ah,4ch
int 21h
inputString endp
end inputString
Program to input two numbers and check if they are equal, unequal, greater or
lesser
Dosseg
.model small
www.youtube.com/Programology
.stack 100h
.data
MsgEq db 'Numbers are Equal $'
MsgUneq db 'Numbers are Unequal and $'
MsgGr db ' First Number is greater than second number $'
MsgLs db ' First Number is lesser than second number $'
.code
main proc
mov ax, @data
mov ds, ax
L1:
cmp bl,cl ; Comparing whether they are equal or not
je EQUAL ; Jump to Equal box, where we print the equal msg
mov dx, offset MsgUneq ; but if not equal, then print msg they are not equal
mov ah, 9
int 21h
mov dx, offset MsgLs ; but if not greater, print lesser msg
mov ah, 9
int 21h
jmp PRINT
Greater:
mov dx, offset MsgGr
mov ah, 9
int 21h
www.youtube.com/Programology
jmp PRINT
EQUAL:
mov dl, 10 ; for next line feed
mov ah, 2
int 21h
mov dl, 13 ; for carriage return
mov ah, 2
int 21h
PRINT:
mov ah,4ch
int 21h
main endp
end main
dosseg
.model small
.stack 100h
.data
.code
main proc
mov ax,@data
mov ds,ax
www.youtube.com/Programology
mov bx, 1
mov cx, 5
L1:
push cx
mov cx, bx
L2:
Mov dl, '*'
mov ah,2
int 21h
loop L2
mov dl,10
mov ah, 2
int 21h
mov dl,13
mov ah, 2
int 21h
inc bl
pop cx
loop L1
mov ah,4ch
int 21h
main endp
end main
.model small
.stack 100h
.data
www.youtube.com/Programology
.code
main proc
mov ax,@data
mov ds,ax
mov ah, 1
int 21h
mov cl, al
sub cl, 48
mov dl,10
mov ah, 2
int 21h
mov dl,13
mov ah, 2
int 21h
mov bx, 1
L1:
push cx
mov cx, bx
L2:
Mov dx, bx
add dx, 48
mov ah,2
int 21h
loop L2
mov dl,10
mov ah, 2
int 21h
mov dl,13
mov ah, 2
int 21h
inc bl
pop cx
www.youtube.com/Programology
loop L1
mov ah,4ch
int 21h
main endp
end main
Program to read a character and display that character 100 times on next line
using loop
;program to read a character and display that character 100 times on next line using loop
dosseg
.model small
.stack 100h
.data
.code
main proc
mov ah, 1
int 21h
mov bl,al
mov cx, 100
l1:
mov dl, bl
mov ah, 2
int 21h
mov dl, 10
mov ah, 2
int 21h
mov dl,13
mov ah, 2
int 21h
loop l1
www.youtube.com/Programology
Program to take input two numbers and multiply them
.MODEL SMALL
.STACK 100H
.DATA
iMsg1 db 10,13,"Enter First Number:$"
iMsg2 db 10,13,"Enter Second Number:$"
outputMsg db 10,13,"Their Product is = :$"
n1 db ?
n2 db ?
.CODE
MAIN PROC
INT 21H
ADD AX,48
MOV DL,AL
MOV AH, 02H
INT 21H
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN
www.youtube.com/Programology
Take a character as input from user and find the occurrence of that character in
hard coded string
.model small
.stack 100h
.data
String db 'helloworld$'
.code
main proc
mov ax,@data
mov ds,ax
L1:
cmp bl,[si] ; comparing $ and letter of string
je ToEnd
Counter:
add dl,1 ; increment to dl register for counting occurrence
inc si
jmp L1
ToEnd:
add dl,48
mov ah,2 ; printing the counter
INT 21h
mov ah,4ch
INT 21h
www.youtube.com/Programology
main endp
end main
Take two numbers from the user, divide those numbers and print quotient and
reminder with a proper message
.model small
.stack 100h
.data
Num db "Numerator = $"
Dino db "Denominator = $"
Quo db "Quotient = $"
Rem db "Reminder = $"
N db ?
D db ?
.code
Main proc
mov ax,@data
mov ds,ax
mov ah,1
int 21h
sub al,48
mov N,al ; input numerator
mov dl,10
www.youtube.com/Programology
mov ah,2
int 21h
mov dl,13
mov ah,2
int 21h
mov dl,10
mov ah,2
int 21h
mov dl,13
mov ah,2
int 21h
mov dl,10
mov ah,2
int 21h
mov dl,13
mov ah,2
int 21h
www.youtube.com/Programology
int 21h
mov dl,cl
add dl,48
mov ah,2
int 21h
mov dl,10
mov ah,2
int 21h
mov dl,13
mov ah,2
int 21h
mov ah,4ch
int 21h
Main endp
end Main
.model small
.stack 100h
.data
var1 db 100 dup("$")
.code
inputString proc
mov ax,@data
mov ds,ax
mov bl, 0 ; counts the length of string
mov si,offset var1
www.youtube.com/Programology
l1: mov ah,1
int 21h
cmp al,13
je printString
mov [si],al
inc si
inc bl
jmp l1
printString:
mov ah,4ch
int 21h
inputString endp
end inputString
.model small
.stack 100h
.data
var1 db 100 dup("$")
.code
inputString proc
mov ax,@data
mov ds,ax
mov bl, 0 ; counts the length of string
mov si,offset var1
l1: mov ah,1
int 21h
cmp al,13
je printString
www.youtube.com/Programology
mov [si],al
inc si
inc bl
jmp l1
printString:
mov si,offset var1
mov cl, bl
lowercase:
mov dx,[si]
add dx, 32
mov ah,2
int 21h
inc si
loop lowercase
mov ah,4ch
int 21h
inputString endp
end inputString
mov ah, 1
int 21h
mov cl, 8
mov bl, al
l1:
shl bl, 1
mov ah, 2
mov dl, 0
adc dl, 48
int 21h
www.youtube.com/Programology
loop l1
main endp
end main
.model small
.stack 100h
.data
num db 10 dup('$')
msgNeg db 'Given Number is Negative. $'
msgPos db 'Given Number is Positive. $'
.code
main proc
mov ax,@data
mov ds,ax
inputString:
mov ah, 1
int 21h
cmp al, 13
JE CheckNum
mov [si],al
inc si
jmp inputString
CheckNum:
www.youtube.com/Programology
cmp num,'-'
JE PrintNeg
mov ah,4ch
int 21h
PrintNeg:
mov dx, offset msgNeg
mov ah, 9
int 21h
mov ah,4ch
int 21h
main endp
end main
www.youtube.com/Programology