.model small
.data
src db 15h,16h,17h,18h,19h
count db 05h
.code
mov ax,@data ;initialize data segment
mov ds,ax
mov es,ax ;initialize extra segment
lea si,src ;si to point source block
mov cl,count ;initialize counter
mov dh,cl ;initialize counter
dec cl ;decreament counter
up1: inc si ;making si to point to last number in block
dec cl
jnz up1
mov bl,count ;loading bl with count
sub bl,03h ;subtract overlapping bytes
mov di,si ;making di point to exceeding bytes from
up2: inc di ;last number in source block
dec bl
jnz up2
mov cl,count ;initialize counter
mov ch,00h ;making cx as counter by loading 00h in ch
std
rep movsb ;string
;transfering data in reverse order
inc di ;making di point to initial number in transfered block
up4: mov bl,[di] ;moving content of address stored in di
mov ch,02h ;count of digits to be displayed
mov cl,04h ;count of digits to be rolled
up5: rol bl,cl ;roll bl so that MSB comes to LSB
mov dl,bl ;load dl with data to be displayed
and dl,0fh ;ANDing to get only LSB
cmp dl,09h ;check if digit is 0-9 or letter A-F
jbe down ;if letter add 37h else only 30h
add dl,07h
down: add dl,30h
mov ah,02h ;Funcion 02 under INT 21H
int 21h
dec ch ;jump if displaying digits in number is not overed
jnz up5
mov dl,' ' ;Displaying void space
mov ah,02h ;Funcion 02 under INT 21H
int 21h
inc di ;incrementing di
dec dh ;decrementing dh
jnz up4 ;jump if all numbers in destinatio block not displayed
mov ah,4ch ;normal termination to DOS prompt
int 21h
end
-----------------------------------------------OUTPUT------------------------------------------------
C:\Tasm>tasm ass1d.asm
Turbo Assembler Version 1.0 Copyright (c) 1988 by Borland International
Assembling file: ASS1D.ASM
Error messages: None
Warning messages: None
Remaining memory: 487k
C:\Tasm>tlink ass1d.obj
Turbo Link Version 2.0 Copyright (c) 1987, 1988 Borland International
Warning: no stack
C:\Tasm>ass1d.exe
15 16 17 18 19
C:\Tasm>
.data
src db 15h,16h,17h,18h,19h
count db 05h
.code
mov ax,@data ;initialize data segment
mov ds,ax
mov es,ax ;initialize extra segment
lea si,src ;si to point source block
mov cl,count ;initialize counter
mov dh,cl ;initialize counter
dec cl ;decreament counter
up1: inc si ;making si to point to last number in block
dec cl
jnz up1
mov bl,count ;loading bl with count
sub bl,03h ;subtract overlapping bytes
mov di,si ;making di point to exceeding bytes from
up2: inc di ;last number in source block
dec bl
jnz up2
mov cl,count ;initialize counter
mov ch,00h ;making cx as counter by loading 00h in ch
std
rep movsb ;string
;transfering data in reverse order
inc di ;making di point to initial number in transfered block
up4: mov bl,[di] ;moving content of address stored in di
mov ch,02h ;count of digits to be displayed
mov cl,04h ;count of digits to be rolled
up5: rol bl,cl ;roll bl so that MSB comes to LSB
mov dl,bl ;load dl with data to be displayed
and dl,0fh ;ANDing to get only LSB
cmp dl,09h ;check if digit is 0-9 or letter A-F
jbe down ;if letter add 37h else only 30h
add dl,07h
down: add dl,30h
mov ah,02h ;Funcion 02 under INT 21H
int 21h
dec ch ;jump if displaying digits in number is not overed
jnz up5
mov dl,' ' ;Displaying void space
mov ah,02h ;Funcion 02 under INT 21H
int 21h
inc di ;incrementing di
dec dh ;decrementing dh
jnz up4 ;jump if all numbers in destinatio block not displayed
mov ah,4ch ;normal termination to DOS prompt
int 21h
end
-----------------------------------------------OUTPUT------------------------------------------------
C:\Tasm>tasm ass1d.asm
Turbo Assembler Version 1.0 Copyright (c) 1988 by Borland International
Assembling file: ASS1D.ASM
Error messages: None
Warning messages: None
Remaining memory: 487k
C:\Tasm>tlink ass1d.obj
Turbo Link Version 2.0 Copyright (c) 1987, 1988 Borland International
Warning: no stack
C:\Tasm>ass1d.exe
15 16 17 18 19
C:\Tasm>