ALP to perform non-overlapped and overlapped block transfer
2. Write 8086 ALP to perform non-overlapped and overlapped block transfer (with and without string specific instructions). Block containing data can be defined in the data segment.
;ALP to perform NON-overlapped block transfer
.model small
.data
msg1 db 10,13 ,"enter size of array:$"
msg2 db 10,13,"enter the array elements: $"
msg3 db 10,13,"second array elements are: $"
arr1 db 10 dup(0)
arr2 db 10 dup(0)
cnt db 1 dup(0)
.code
mov ax,@data
mov ds,ax
mov es,ax
lea dx,msg1
mov ah,09h
int 21h
mov ah,01h
int 21h
sub al,30h
cmp al,09h
jbe next
sub al,07h
next: mov cnt,al
mov ch,cnt
mov bl,cnt
lea si,arr1
mov cl,04h
l1: lea dx,msg2
mov ah,09h
int 21h mov ah,01h
int 21h
sub al,30h
cmp al,09h
jbe l2
sub al,07h
l2: mov bh,al
rol bh,cl
mov ah,01h
int 21h
sub al,30h
cmp al,09h
jbe l3
sub al,07h
l3: add bh,al
mov [si],bh
inc si
dec ch
jnz l1
l4: mov cl,cnt
mov ch,00h
lea si,arr1
lea di,arr2
cld
rep movsb
lea dx,msg3
mov ah,09h
int 21h
lea di,arr2
mov bl,cnt
up2: mov cx,0204h
mov dh,[di]
up: rol dh,cl
mov dl,dh
and dl,0fh
cmp dl,09h
jbe l5
add dl,07h
l5: add dl,30h
mov ah,02h
int 21h
dec ch
jnz up
mov dl,' '
mov ah,02h
int 21h
inc di
dec cnt
jnz up2
mov ah,04ch
int 21h
end
output
C:\tasm>tasm non.asm
Turbo Assembler Version 2.0 Copyright (c) 1988, 1990 Borland International
Assembling file: non.asm
Error messages: None
Warning messages: None
Passes: 1
Remaining memory: 475k
C:\tasm>tlink non
Turbo Link Version 3.0 Copyright (c) 1987, 1990 Borland International
Warning: No stack
C:\tasm>non
enter size of array:5
enter the array elements: 01
enter the array elements: 02
enter the array elements: 03
enter the array elements: 04
enter the array elements: 05
second array elements are: 01 02 03 04 05
C:\tasm>
;ALP to perform overlapped block transfer
.data
msg1 db 10,13 ,"enter size of array:$"
msg2 db 10,13,"enter the array elements: $"
msg3 db 10,13,"second array elements are: $"
arr1 db 10 dup(0)
arr2 db 10 dup(0)
cnt db 1 dup(0)
.code
mov ax,@data
mov ds,ax
mov es,ax
lea dx,msg1
mov ah,09h
int 21h
mov ah,01h
int 21h
sub al,30h
cmp al,09h
jbe next
sub al,07h
next: mov cnt,al
mov ch,cnt
mov bl,cnt
lea si,arr1
mov cl,04h
l1: lea dx,msg2
mov ah,09h
int 21h mov ah,01h
int 21h
sub al,30h
cmp al,09h
jbe l2
sub al,07h
l2: mov bh,al
rol bh,cl
mov ah,01h
int 21h
sub al,30h
cmp al,09h
jbe l3
sub al,07h
l3: add bh,al
mov [si],bh
inc si
dec ch
jnz l1
l4: mov cl,cnt
mov ch,00h
lea si,arr1
lea di,arr2
cld
rep movsb
lea dx,msg3
mov ah,09h
int 21h
lea di,arr2
mov bl,cnt
up2: mov cx,0204h
mov dh,[di]
up: rol dh,cl
mov dl,dh
and dl,0fh
cmp dl,09h
jbe l5
add dl,07h
l5: add dl,30h
mov ah,02h
int 21h
dec ch
jnz up
mov dl,' '
mov ah,02h
int 21h
inc di
dec cnt
jnz up2
mov ah,04ch
int 21h
end
output
C:\tasm>tasm non.asm
Turbo Assembler Version 2.0 Copyright (c) 1988, 1990 Borland International
Assembling file: non.asm
Error messages: None
Warning messages: None
Passes: 1
Remaining memory: 475k
C:\tasm>tlink non
Turbo Link Version 3.0 Copyright (c) 1987, 1990 Borland International
Warning: No stack
C:\tasm>non
enter size of array:5
enter the array elements: 01
enter the array elements: 02
enter the array elements: 03
enter the array elements: 04
enter the array elements: 05
second array elements are: 01 02 03 04 05
C:\tasm>
.MODEL SMALL
.DATA
ARR1 DB 10 DUP(0)
;ARR2 DB 5 DUP(0)
COUNT DB 1 DUP(0)
OV_COUNT DB 1 DUP(0)
MSG1 DB 10,13,"ENTER SIZE:-$"
MSG2 DB 10,13,"ENTER NO:-$"
MSG3 DB 10,13,"ENTER OVELAPED COUNT:-$"
MSG4 DB 10,13,"ARRAY IS COPIED$"
MSG5 DB 10,13,"NEW ARRAY:-$"
.CODE
MOV AX,@DATA
MOV DS,AX
MOV ES,AX
LEA DX,MSG1
MOV AH,09H
INT 21H
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,09H
JBE L
SUB AL,07H
L:MOV COUNT,AL
MOV CL,COUNT
LEA SI,ARR1
L1:LEA DX,MSG2
MOV AH,09H
INT 21H
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,09H
JBE L2
SUB AL,07H
L2:MOV DL,CL
MOV CL,04H
MOV BH,AL
ROL BH,CL
MOV CL,DL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,09H
JBE L3
SUB AL,07H
L3:ADD BH,AL
MOV [SI],BH
INC SI
LOOP L1
LEA DX,MSG3
MOV AH,09H
INT 21H
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,09H
JBE N
SUB AL,07H
N:MOV OV_COUNT,AL
MOV BH,COUNT
MOV DH,OV_COUNT
LEA SI,ARR1 ;MOVE OFFSET OF ARR1 TO SI REG.
LEA DI,ARR1 ;MOVE OFFSET OF ARR1 TO DI REG.
MOV CL,BH
L4:
INC SI
DEC CL
JNZ L4 ;INCREMENT SI BY 1
DEC SI ;DECREMENT SI BY 1
MOV DI,SI ;MOVE SI TO DI
MOV CL,DH
L5:INC DI ;INCREMENT DI BY 1
DEC CL
JNZ L5
MOV CH,00H
MOV CL,COUNT
STD
REP MOVSB ;TRANSFER CONTAINS OF SI TO DI BYTE BY BYTE
;REPEAT MOVSB INSTRUCTION UNTIL CX IS NOT 0
DEC DI
MOV BH,OV_COUNT
LEA SI,ARR1
MOV AL,00H
L6:MOV [SI],AL
INC SI
DEC BH
JNZ L6
LEA DX,MSG4
MOV AH,09H
INT 21H
LEA SI,ARR1
MOV CL,COUNT
ADD CL,OV_COUNT
LEA DX,MSG5
MOV AH,09H
INT 21H
MOV CH,COUNT
ADD CH,OV_COUNT
LEA SI,ARR1
L7:MOV CL,04H
MOV BL,[SI]
ROL BL,CL
AND BL,0FH
MOV DL,BL
CMP DL,09H
JBE L8
ADD DL,07H
L8:ADD DL,30H
MOV AH,02H
INT 21H
MOV BL,[SI]
AND BL,0FH
MOV DL,BL
CMP DL,09H
JBE L9
ADD DL,07H
L9:ADD DL,30H
MOV AH,02H ;DISPLAY ARRAY
INT 21H
INC SI
DEC CH
JNZ L7
EXIT:MOV AH,4CH
INT 21H
END
OUTPUT:-
Turbo Assembler Version 2.0 Copyright (c) 1988, 1990 Borland International
Assembling file: OM241.ASM
Error messages: None
Warning messages: None
Passes: 1
Remaining memory: 441k
C:\tasm>TLINK OM241.OBJ
Turbo Link Version 3.0 Copyright (c) 1987, 1990 Borland International
Warning: No stack
C:\tasm>OM241
ENTER SIZE:-5
ENTER NO:-11
ENTER NO:-12
ENTER NO:-13
ENTER NO:-14
ENTER NO:-15
ENTER OVELAPED COUNT:-3
ARRAY IS COPIED
NEW ARRAY:-00 00 00 11 12 13 14 15
C:\tasm>
0 comments:
Post a Comment