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

Q1)=================sum-of-num=====================

.model small
.stack 100h
.data

msg db 'Enter number : $'

.code
main proc
mov ax,@data
mov ds,ax

xor cx,cx

while_:
mov ah,01h
int 21h

cmp al,0dh
je end_while

and al,0fh
push ax
inc cx
jmp while_

end_while:

mov ah,02h
mov dl,0dh
int 21h
mov dl,0ah
int 21h

pop_for:
pop ax
add bx,ax
loop pop_for

mov ah,02h
add bl,30h
mov dl,bl
int 21h

end_if:
mov ah,4ch
int 21h

main endp
end main
Q1-END)==================================

Q2)===============slice-string=============
.model small
.stack 100h
.data

arr db 's','h','a','h','r','l','o','l','b','a','n','o'
arrCopy db 10 dup('$')

point dw 5
range dw 3

.code

main proc
mov ax,@data
mov ds,ax

xor si,si

mov cx,12
mov bx,cx

end_input:

xor si,si
xor di,di

;copying correct string


for_arr:
cmp si, word ptr point
je skip_
mov al,arr[si]
mov arrCopy[di],al
inc si
inc di
back_2:
loop for_arr
jmp out_

back_1:
mov si,5
jmp back_2

skip_:
add si,range
jmp back_2

out_:

mov cx,12
sub cx,range

xor si,si
for_output:
mov ah,02h
mov dl,arrCopy[si]
inc si
int 21h
loop for_output

end_if:
mov ah,4ch
int 21h

main endp
end main
Q2-END)===============================

Q3)==========correct-sequence=======================
.data

arr db 25 dup('$')

.code
main proc

mov ax,@data
mov ds,ax

xor cx,cx
xor si,si

while_:
mov ah,01h
int 21h

cmp al,0dh
je end_while

inc cx

push ax
jmp while_

end_while:

mov dx,cx

pop_for:
pop ax
mov arr[si],al
inc si
loop pop_for

mov cx,dx
xor dx,dx

;new line
mov ah,02h
mov dl,0dh
int 21h
mov dl,0ah
int 21h

dec si
disp_Arr:
mov ah,02h
mov dl,arr[si]
int 21h
dec si
loop disp_Arr

end_if:
mov ah,4ch
int 21h

main endp
end main

Q3-END)======================================

Q4)===================copy-array=======================
.model small
.stack 100h
.data

arz db 5 dup(0)

rr db 1,2,3,4,5,6,7,8,9,10

msg db 'Enter number : $'

.code
main proc

mov ax,@data
mov ds,ax

;print string
mov ah,09h
lea dx,msg
int 21h

;user input
mov ah,01h
int 21h

and al,0fh

;mov al,5

xor si,si
xor di,di
mov di,-1

mov cx,10
for_:
cmp rr[si],al
jae copy
back:
inc si
loop for_
jmp out_

copy:
inc di
mov dl,rr[si]
mov arz[di],dl
jmp back

out_:
mov cx,di
xor si,si

mov ah,02h
mov dl,0dh
int 21h
mov dl,0ah
int 21h

for_output:
mov ah,02h
mov bl,arz[si]
add bl,30h
mov dl,bl
int 21h
inc si
loop for_output

mov ah,4ch
int 21h

main endp
end main

Q4-END)========================================

You might also like