Thread: How do I do double buffering in console?

  1. #16
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    It seems wise to me to test my code before calling it slow. I assure you I'm not in the habit of writing slow code.

    Besides text mode at 80x50x2 is only 800 bytes. You won't see any shearing - I doubt at full speed you will be able to see much.


    Code:
    mov  edi,[screen_selector]
    mov  esi,[buffer_selector]
    mov  ecx,200d
    rep   movsd
    800 bytes is only 200 DWORDs. This would go fast on a 386 machine let alone a modern CPU.
    Last edited by VirtualAce; 04-16-2005 at 06:54 AM.

  2. #17
    Registered User
    Join Date
    Jan 2005
    Posts
    24
    Code:
    mov  edi,[screen_selector]
    mov  esi,[buffer_selector]
    mov  ecx,200d
    rep   movsd
    What does it make, I have just some kind of idea of that?
    mov makes a variable but are edi, esi and ecx registers where it's saved into? and what about rep?
    If you know a good site for assembly, can u tell me? I know it's hard to learn it, but I'd like to try.

  3. #18
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Well mov e{di/si},[buffer_ptr] is the same as the 16-bit l{ds/es/gs/fs},[buffer_ptr].

    Except that in 32-bit Windows you don't want to change the current selector so you just use the mov opcode.

    Code:
    
    
    mov edi,[screen_selector]
    This places the screen selector (essentially it's address) into edi or the 32-bit destination index register.

    mov esi,[buffer_selector]
    This places the buffer selector (essentially it's address) in esi or the 32-bit source index register.

    mov ecx,200d
    This places the value of 200 in decimal (d = decimal, h=hex, b=binary, o=octal) into the 32-bit cx register or ecx. The (e)cx register is known as the count register and it is the register that the rep opcode looks at to determine the loop count. If the direction flag is clear then rep will auto-decrement (e)cx and if it's set it will auto-increment (e)cx.

    rep movsd
    MOVSD is a string operation that moves a DWORD from DS:ESI to ES:EDI or in this case from ESI to EDI. The REP prefix will repeat this operation until ECX reaches 0 - see above for increment/decrement behavior.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 04:09 AM
  2. Conversion From C++ To C
    By dicon in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 02:54 PM
  3. Need some help/advise for Public/Private classes
    By nirali35 in forum C++ Programming
    Replies: 8
    Last Post: 09-23-2006, 12:34 PM
  4. Please HELP!!
    By traz in forum C++ Programming
    Replies: 4
    Last Post: 04-14-2003, 09:20 PM
  5. double buffering for allegro
    By Leeman_s in forum C++ Programming
    Replies: 6
    Last Post: 09-12-2002, 02:45 PM