Practical No 9 Qasim 102
Practical No 9 Qasim 102
Roll: 102
Program:
Code snippet
.model small
.stack 100h
.data
.code
main proc
mov ax,@data
mov ds,ax
Output:
*
**
***
****
*****
Code snippet
.model small
.stack 100h
.data
prompt DB 'Enter a sentence (max 80 chars, end with $):', 10,
13, '$'
input_buffer DB 81 DUP(?)
msg_count DB 'Number of uppercase letters: ', '$'
count DB 0
.code
main proc
mov ax, @data
mov ds, ax
next_char:
inc si ; Move to next character
jmp while_loop ; Continue loop
end_while:
; Display the count message
mov ah, 9
lea dx, msg_count
int 21h
; Exit program
mov ah, 4ch
int 21h
main endp
end main
mov bl, 1 ; BL will hold the number to print and the outer loop
counter (1 to 5)
outer_loop:
cmp bl, 6 ; Check if BL is greater than 5 (loop for
numbers 1 to 5)
je exit_program
mov cl, bl ; CL will be the inner loop counter, initialized
with the value of BL
inner_loop:
mov al, bl ; Get the number to print
add al, '0' ; Convert number to its ASCII character
mov dl, al ; Move ASCII character to DL for display
mov ah, 2 ; DOS function to display character
int 21h ; Call DOS
exit_program:
mov ah, 4ch ; DOS function to exit program
int 21h
main endp
end main