assembly - Memory-Mapped Graphics Output -
i'm exploring drawing pixels , lines, using memory-mapped graphics. i'm using tasm in textpad, in windows. when click run whole screen turns blue , that's it, no pixels drawn.
.model small .stack .data savemode db ? xval dw ? yval dw ? .code main proc mov ax, @data mov ds, ax call setvideomode call setscreenbackground call draw_some_pixels call restorevideomode mov ax, 4c00h int 21h main endp setscreenbackground proc mov dx, 3c8h mov al, 0 out dx, al mov dx, 3c9h mov al, 0 out dx, al mov al, 0 out dx, al mov al, 35 out dx, al ret setscreenbackground endp setvideomode proc mov ah, 0fh int 10h mov savemode, al mov ah, 0 mov al, 13h int 10h push 0a00h pop es ret setvideomode endp restorevideomode proc mov ah, 10h int 16h mov ah, 0 mov al, savemode int 10h ret restorevideomode endp draw_some_pixels proc mov dx, 3c8h mov al, 1 out dx, al mov dx, 3c9h mov al, 63 out dx, al mov al, 63 out dx, al mov al, 63 out dx, al mov xval, 160 mov yval, 100 mov ax, 320 mul yval add ax, xval mov cx, 10 mov di, ax dp1: mov byte ptr es:[di], 1 add di, 5 loop dp1 ret draw_some_pixels endp
the issue seems segment video mode 13h associated with.
after setting video mode, next step draw onto screen. vga memory located @ physical address 0xa0000
your code does:
setvideomode proc mov ah, 0fh int 10h mov savemode, al mov ah, 0 mov al, 13h ; video mode 13h int 10h push 0a00h ; incorrect should 0a000h pop es ret setvideomode endp
video mode 13h addressed segment:offset (es:0 in case) of 0a000h:0
. 0a000h:0
physical address (0a000h << 4) + 0 = 0a0000h
.
the code fixed changing to:
push 0a000h pop es
Comments
Post a Comment