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,980 of 4,675   
   s_dubrovich@nospicedham.yahoo.com to All   
   Re: using rep movsw instruction to move    
   05 Dec 19 08:05:29   
   
   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.   
      
   --- 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