Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  nodelist  faq  login

Computers are useless. They can only give you answers. -- Pablo Picasso


programming / comp.lang.asm.x86 / using rep movsw instruction to move text mode screen

SubjectAuthor
* using rep movsw instruction to move text mode screenbilsch01
+* Re: using rep movsw instruction to move text mode screenTerje Mathisen
|`- Re: using rep movsw instruction to move text mode screenbilsch01
`- Re: using rep movsw instruction to move text mode screens dubrovich

1
Subject: using rep movsw instruction to move text mode screen
From: bilsch01
Newsgroups: comp.lang.asm.x86
Organization: A noiseless patient Spider
Date: Thu, 5 Dec 2019 00:50 UTC
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: king...@nospicedham.comcast.net (bilsch01)
Newsgroups: comp.lang.asm.x86
Subject: using rep movsw instruction to move text mode screen
Date: Wed, 4 Dec 2019 16:50:33 -0800
Organization: A noiseless patient Spider
Lines: 34
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <qs9k8s$4j6$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: reader02.eternal-september.org; posting-host="2e3e151cea86ad8f8f8bd94ba9610d7f";
logging-data="8728"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+arz6iO3KEgahlHrQwsVq4ZyyW2YBtzCA="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
Thunderbird/68.2.1
Cancel-Lock: sha1:eHVhoj3yeLbm2weQxCGltSkkKBw=
View all headers
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.



Subject: Re: using rep movsw instruction to move text mode screen
From: Terje Mathisen
Newsgroups: comp.lang.asm.x86
Organization: Aioe.org NNTP Server
Date: Thu, 5 Dec 2019 07:02 UTC
References: 1
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: terje.ma...@nospicedham.tmsw.no (Terje Mathisen)
Newsgroups: comp.lang.asm.x86
Subject: Re: using rep movsw instruction to move text mode screen
Date: Thu, 5 Dec 2019 08:02:32 +0100
Organization: Aioe.org NNTP Server
Lines: 69
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <qsaa28$1639$1@gioia.aioe.org>
References: <qs9k8s$4j6$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="2e3e151cea86ad8f8f8bd94ba9610d7f";
logging-data="2881"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+jrlblqe6D2C88jQHCoOanTx9RxJwS0oo="
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101
Firefox/52.0 SeaMonkey/2.49.4
Cancel-Lock: sha1:0xmxzagpr2Q7KvyXCYixa4xydk0=
View all headers
bilsch01 wrote:
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.


This is the classic overlapping move problem. :-)

You have recognized it partially, in that you are pointing at hte end of the buffer areas instead of the beginning, but you have failed to issue a STD (Set Direction bit, vs CLD which is the default).

However, the real issue here is the fact that you should NOT move text around on a classic PC screen at all! Instead you maintain an off-screen buffer and then you use REP MOVSW to copy the relevant parts into the screen memory.

This is because the screen buffer is/was 3-10 times slower than normal RAM, so it was far faster to do all updates off-screen and then copy in the finished screen.

In my own code I used a list of line buffers for that off-screen display, so that I could do partial scrolling with just a few pointer updates, before using REP MOVSW on individual lines to copy them to the correct screen location.

If you have the original CGA screen then you also need to worry about screen flicker if you write to the CGA memory while the screen is being refreshed! You can copy at least 1-4 lines (afair) of data in the vertical retrace interval and a few characters in each horizontal retrace if you need to.

Terje

--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"



Subject: Re: using rep movsw instruction to move text mode screen
From: s_dubrov...@nospicedham.yahoo.com
Newsgroups: comp.lang.asm.x86
Organization: A noiseless patient Spider
Date: Thu, 5 Dec 2019 16:05 UTC
References: 1
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: s_dubrov...@nospicedham.yahoo.com
Newsgroups: comp.lang.asm.x86
Subject: Re: using rep movsw instruction to move text mode screen
Date: Thu, 5 Dec 2019 08:05:29 -0800 (PST)
Organization: A noiseless patient Spider
Lines: 63
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <26b3b729-2ed1-4ebe-88b4-decba3072077@googlegroups.com>
References: <qs9k8s$4j6$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Date: Thu, 05 Dec 2019 16:05:30 +0000
Injection-Info: reader02.eternal-september.org; posting-host="2e3e151cea86ad8f8f8bd94ba9610d7f";
logging-data="23813"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18axzUnbZmLEZmguQ8Ou8W3BsJJKBYFZfk="
User-Agent: G2/1.0
Cancel-Lock: sha1:4rGvM9UyFhQl8tIjZp3hsezAWgM=
View all headers
On Wednesday, December 4, 2019 at 7:05:50 PM UTC-6, bilsch01 wrote:
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.

0..3519 is 3520 bytes
3520/160 = 22 lines?, or 21?


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  ;; begins screen offset
mov ds,ax      ;; prep ds for source segment, assumed ds value was saved,
                 ;; and CLD was done for increment block moves.
mov es,ax      ;; destination segment, same as src segm
mov cx,1680    ;; count is 1680/80 words per line = 21 lines
mov si,3200    ;; starting source offset ?? --I think you mean from line zero
                 ;;  whose offset is 0000h
mov di,3360    ;; destination offset is ?? 3360/80 words is line 42 ???
                 ;; one line is 80 words, to scroll one line down, add 80 to
                 ;; the starting offset to put into the destination offset.
                 ;; Scrolling from line zero down, then the DI value is line 0 plus
                 ;;  80 words, mov di, 80
rep movsw      ;; means DS:SI++ -> ES:DI++ by word size

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

I guess this means from line 0 toward line 21.
I think your perception might be that scrolling is done from the bottom of the screen toward the top of the screen.. but with CLD, the scrolling is from bottom of memory (top of the screen) toward the top of memory (bottom of the screen).
A little counter intuitive.

You could develop using STD, block moves (scrolling) toward lower memory (from bottom of screen toward the top of the screen) just watch your indexing SI, DI and think of CX as a form of line count: mov cx, line_cnt*80

There are also the int 10h functions:
o  Fn 6, scroll window up
o  Fn 7, scroll window down

-as options, see RBIL

hth,

Steve


to move down one line. Can someone here tell me how to move the document
area down one line.
TIA.   Bill S.



Subject: Re: using rep movsw instruction to move text mode screen
From: bilsch01
Newsgroups: comp.lang.asm.x86
Organization: A noiseless patient Spider
Date: Fri, 13 Dec 2019 23:39 UTC
References: 1 2
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: king...@nospicedham.comcast.net (bilsch01)
Newsgroups: comp.lang.asm.x86
Subject: Re: using rep movsw instruction to move text mode screen
Date: Fri, 13 Dec 2019 15:39:01 -0800
Organization: A noiseless patient Spider
Lines: 68
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <qt17el$snl$2@dont-email.me>
References: <qs9k8s$4j6$1@dont-email.me> <qsaa28$1639$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="b135932de83ecdcb8e7edec664bf908c";
logging-data="1053"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/cr21bH5JI3VWisM3IE3KWhkLFHhsDAsE="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
Thunderbird/68.2.2
Cancel-Lock: sha1:0TzluSKRbZNM+ttpks0v/1XWSpc=
View all headers
On 12/4/19 11:02 PM, Terje Mathisen wrote:
bilsch01 wrote:
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.


This is the classic overlapping move problem. :-)

You have recognized it partially, in that you are pointing at hte end of the buffer areas instead of the beginning, but you have failed to issue a STD (Set Direction bit, vs CLD which is the default).

However, the real issue here is the fact that you should NOT move text around on a classic PC screen at all! Instead you maintain an off-screen buffer and then you use REP MOVSW to copy the relevant parts into the screen memory.

This is because the screen buffer is/was 3-10 times slower than normal RAM, so it was far faster to do all updates off-screen and then copy in the finished screen.

In my own code I used a list of line buffers for that off-screen display, so that I could do partial scrolling with just a few pointer updates, before using REP MOVSW on individual lines to copy them to the correct screen location.

If you have the original CGA screen then you also need to worry about screen flicker if you write to the CGA memory while the screen is being refreshed! You can copy at least 1-4 lines (afair) of data in the vertical retrace interval and a few characters in each horizontal retrace if you need to.

Terje

Thanks.



1
rocksolid light 0.7.2
clearneti2ptor