home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.asm.x86      Ahh, the lost art of x86 assembly      4,675 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 3,984 of 4,675   
   bilsch01 to Terje Mathisen   
   Re: using rep movsw instruction to move    
   13 Dec 19 15:39:01   
   
   From: king621@nospicedham.comcast.net   
      
   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.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca