T
T
Type Programmer2018-11-17 17:21:36
assembler
Type Programmer, 2018-11-17 17:21:36

Assembler how to work with video memory in protected mode?

I want to fill the screen completely with one color, for this it is necessary to fill the entire video frame with the address of the beginning of which is 0A000h.
When I do this, for some reason, only a smaller part of the screen is painted over.
The code:

use16
org 0x7c00
start:
  mov ax,4F02h
  mov bx,100h
  int 10h
  in  al, 0x92
  or  al, 2
  out 0x92, al
  lgdt  [gdtr]
  cli                                 
  in  al, 0x70
  or  al, 0x80
  out 0x70, al
  mov  eax, cr0
  or   al, 1
  mov  cr0, eax
  jmp 00001000b:pm_entry
 

use32
pm_entry:
cld 
xor edi,edi
mov eax,0xA000  
mov edi,eax   
p0:   
mov al,1Fh 
stosb
jmp p0              

gdt:
  db  0x00, 0x00, 0x00, 0x00, 0x00,      0x00,      0x00, 0x00
  db  0xFF, 0xFF, 0x00, 0x00, 0x00, 10011010b, 11001111b, 0x00
gdt_size  equ $ - gdt

gdtr:
  dw  gdt_size - 1
  dd  gdt

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2018-11-17
@MegaCraZy6

for some reason, only a smaller part of the screen is painted over.

For many reasons:
- you forgot to load ds and es after switching to protected mode
- you have nothing to load them with, because there are no writable segments in gdt
- video memory address is 0xa0000, and 0xa000 is like you

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question