NASM - The Netwide Assembler
NASM Forum => Programming with NASM => Topic started by: bilsch01 on December 05, 2019, 05:53:42 AM
-
My program uses 4000 bytes at segment 0xb800 for text mode display. The bottom 3 lines of the screen (160 bytes of memory per line) are static display and are not to be moved. Bytes 0 thru 3519 contain part of a text document and are the area to be moved up/down.
1. The code below moves the displayed document text up one line. It works fine:
mov ax,0xb800
mov ds,ax
mov es,ax
mov cx,1680
mov si,160
mov di,0
rep movsw
2. I tried the code below to move the displayed document text DOWN one line:
mov ax,0xb800
mov ds,ax
mov es,ax
mov cx,1680
mov si,3200
mov di,3360
rep movsw
It moves the line beginning at b800:3200 down one line on the screen but the lines above it are not moved down. It is unfortunate that the static display gets overwritten, I can handle that later. I tried some variations of the code but I wasn't able to get the entire document area to move down one line. Can someone here tell me how to move the document area down one line.
TIA. Bill S.
-
The problem is overlapping data...
Try to point ES:DI to the end of the last line and DS:SI to the end of the line above, CX to 80*24, change the DF to 1 and do REP/MOVSW:
; OBS: destroys ax,cx, si and di.
scrolldown1line:
push ds
push es
mov ax,0xb8000
mov ds,ax
mov es,ax
mov di,160*25-2
mov si,160*24-2
mov cx,80*24
std ; to move backwards
rep movsw
cld
pop es
pop ds
ret