;block transfer
disp macro msg
lea dx,msg
mov ah,09h
int 21h
endm
input macro
mov bl,10
mov ah,01h
int 21h
sub al,30h
mul bl
mov dl,al
mov ah,01h
int 21h
sub al,30h
add dl,al
mov dh,00h
endm
.model small
.stack
.data
arr db 8 dup(0)
m0 db 10,13,'-------MENU------ $'
m1 db 10,13,'1.INPUT $'
m2 db 10,13,'2.NON-OVERLAP $'
m3 db 10,13,'3.OVERLAP $'
m4 db 10,13,'4.EXIT $'
msg0 db 10,13,'NO: $'
msg1 db 10,13,'NON OVERLAPPED ARRAY IS: $'
msg2 db 10,13,'OVERLAPPED ARRAY IS: $'
msgn db 10,13,'$'
.code
main proc
mov ax,@data
mov ds,ax
m: disp m0
disp m1
disp m2
disp m3
disp m4
disp msgn
mov ah,01h
int 21h
cmp al,'1'
je inp
cmp al,'2'
je nol
cmp al,'3'
je ol
cmp al,'4'
je ex
ex: mov ax,4c00h
int 21h
inp: mov cx,0004h
lea si,arr
ip: disp msg0
input
mov [si],dx
inc si
loop ip
jmp m
nol: ;non-overlap
mov cx,04h
mov si,offset arr
mov di,offset arr+4
nl: mov al,[si]
mov [di],al
inc si
inc di
loop nl
mov cx,08h
disp msg1
mov si,offset arr
a1: disp msgn
mov ax,[si]
mov ah,00h
call show
inc si
loop a1
jmp m
ol: ;overlap
mov cx,04h
mov si,offset arr+3
mov di,offset arr+5
lo: mov al,[si]
mov [di],al
dec si
dec di
loop lo
mov cx,08h
disp msg2
mov si,offset arr
b1: disp msgn
mov ax,[si]
mov ah,00h
call show
inc si
loop b1
jmp m
endp main
;hex to deci conv
show proc near
push bx
push cx
push dx
mov cx,00h
mov bx,000Ah
d1:
mov dx,0000h
div bx
push dx
inc cx
cmp ax,00h
jne d1
d2:
pop dx
add dl,30h
mov ah,02h
int 21h
dec cx
jnz d2
pop dx
pop cx
pop bx
ret
endp
end
disp macro msg
lea dx,msg
mov ah,09h
int 21h
endm
input macro
mov bl,10
mov ah,01h
int 21h
sub al,30h
mul bl
mov dl,al
mov ah,01h
int 21h
sub al,30h
add dl,al
mov dh,00h
endm
.model small
.stack
.data
arr db 8 dup(0)
m0 db 10,13,'-------MENU------ $'
m1 db 10,13,'1.INPUT $'
m2 db 10,13,'2.NON-OVERLAP $'
m3 db 10,13,'3.OVERLAP $'
m4 db 10,13,'4.EXIT $'
msg0 db 10,13,'NO: $'
msg1 db 10,13,'NON OVERLAPPED ARRAY IS: $'
msg2 db 10,13,'OVERLAPPED ARRAY IS: $'
msgn db 10,13,'$'
.code
main proc
mov ax,@data
mov ds,ax
m: disp m0
disp m1
disp m2
disp m3
disp m4
disp msgn
mov ah,01h
int 21h
cmp al,'1'
je inp
cmp al,'2'
je nol
cmp al,'3'
je ol
cmp al,'4'
je ex
ex: mov ax,4c00h
int 21h
inp: mov cx,0004h
lea si,arr
ip: disp msg0
input
mov [si],dx
inc si
loop ip
jmp m
nol: ;non-overlap
mov cx,04h
mov si,offset arr
mov di,offset arr+4
nl: mov al,[si]
mov [di],al
inc si
inc di
loop nl
mov cx,08h
disp msg1
mov si,offset arr
a1: disp msgn
mov ax,[si]
mov ah,00h
call show
inc si
loop a1
jmp m
ol: ;overlap
mov cx,04h
mov si,offset arr+3
mov di,offset arr+5
lo: mov al,[si]
mov [di],al
dec si
dec di
loop lo
mov cx,08h
disp msg2
mov si,offset arr
b1: disp msgn
mov ax,[si]
mov ah,00h
call show
inc si
loop b1
jmp m
endp main
;hex to deci conv
show proc near
push bx
push cx
push dx
mov cx,00h
mov bx,000Ah
d1:
mov dx,0000h
div bx
push dx
inc cx
cmp ax,00h
jne d1
d2:
pop dx
add dl,30h
mov ah,02h
int 21h
dec cx
jnz d2
pop dx
pop cx
pop bx
ret
endp
end
No comments:
Post a Comment