简体   繁体   中英

8086 Assembly Video Memory Discrepancy

I'm working on a project in 16-bit TASM, and quite a large part of it involves accessing the video memory quite extensively. The project is in 320x200x256 VGA mode, and I'm running it through Dosbox

For example I have the following set of instructions to fill/wipe the screen at the start of the program:

GFXMode proc    ;Initialize 256-Color Graphics Mode [Args: None] [Returns: None]
    push ax
    mov ax, 0013h
    int 10h
    mov ax, 0a000h
    mov es, ax
    pop ax
    ret
GFXMode endp

RefreshOff proc ;Disables screen refresh while drawing [Args: None] [Returns: None]
    push ax bx
    mov ax, 1201h
    mov bl, 36h
    int 10h
    pop bx ax
    ret
RefreshOff endp

FillScreen proc ;Fills screen with a certain color [Args: 8-bit Color] [Returns: None]
    push bp
    mov bp, sp
    push ax bx
    mov al, ss:[bp + 4] ;Color
    mov bx, 0h
    _fillScreenNextPixel:
        mov es:[bx], al
        inc bx
        cmp bx, 0ffffh
        jb _fillScreenNextPixel
    pop bx ax bp
    ret 2
FillScreen endp

RefreshOn proc  ;Shows changes on screen [Args: None] [Returns: None]
    push ax bx
    mov ax, 1200h
    mov bl, 36h
    int 10h
    pop bx ax
    ret
RefreshOn endp

And the function FillScreen is generally given 0FFh so it should be drawing white.

Since I'm working with TASM, I've been debugging with Turbo Debugger since they came together. And some really odd things have been happening - I can press F7 in the debugger to advance line-by-line or I can press F9 to skip to the end. So I'm watching the content of the es segment (it's set to A000 in both cases), two separate times, once by hitting F9 and then by holding F7 (until I can't bear holding any longer)

When I hit F9 Everything shows up on screen, but nothing is assigned to the video memory. Not at all. At the end of the program I check if there is anything inside es and it's all zeros.

When I hold down F7 for a few minutes, I can see the values being placed in the register, so I know they are there, but when I stop holding down the key after a few hundred pixels and just let it go, the values stop being assigned. When I view the screen it's half one color and half another.

I don't know whether this is a problem with my debugger or with dosbox or something in my code, but I have to keep these values somewhere so I can access them later on. Basically, what the heck is up with my program?

EDIT: I don't have the rep to post an image, so http://puu.sh/3iKhw.png is what it looks like if I hold F7 for 0x600 pixels and then let go for color 0x3B. The line in the middle only appeared after an accidental click

If you stick B800 in es and use di, not bx, you may have a bit more luck

    mov es:[di], al
    inc di
    cmp di, 0ffffh

Might also help to stop at F9FF, not FFFF, (might need to jiggle that number)

I've tested the bottom part of your code and it's fine if you tweak it, there's a colour splash to the screen

 mov bx,B800                     
 mov es,bx                       
 mov bp,sp                       
 ss:mov al,[bp+4]                
 mov di,0                        
 NextPixel                       
 es:mov [di],al                  
 inc di                          
 cmp di,FFF                      
 jb NextPixel                    
 mov ax,1200                     
 mov bl,36                       
 int 10                          

The refresh halt bit however did weird stuff and I excluded it

If you're stuck with A000 memory then fair enough, but es:di are a pairing

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM