T
T
Type Programmer2018-11-18 18:58:15
assembler
Type Programmer, 2018-11-18 18:58:15

Assembler what's wrong with the code?

I want to fill the entire screen with one color, the video memory is located at A0000.
Can someone throw a fixed my code so that I can figure out what's wrong?

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 esi,edi 
mov ax,16
mov gs,ax
p0:            
mov al,1Fh
mov [gs:edi],al
inc edi    
cmp edi,307200
jz $    
jmp p0              

gdt:
  db  0x00, 0x00, 0x00, 0x00, 0x00,      0x00,      0x00, 0x00
  db  0xFF, 0xFF, 0x00, 0x00, 0x00, 10011010b, 11001111b, 0x00  
  db  0FFh, 0FFh, 0x00, 0x00, 0x0A, 92h,40h,0     
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-19
@MegaCraZy6

what's wrong?

In 100h video mode, there is no guarantee that all video memory is available in one contiguous chunk. And if you call the function 0x4f01 of interrupt 0x10, then it will return a structure in which the window size is indicated. It returns 64K (0x40) to me, which is significantly less than 640 * 400 = 256000:
0x7c00:      mov    $0x4f01,%ax
   0x7c03:      mov    $0x100,%cx
   0x7c06:      mov    $0x7c77,%di
   0x7c09:      int    $0x10
(gdb) x/6hx $di
0x7c77: 0x00bb  0x0007  0x0040  0x0040  0xa000  0x0000

To access the rest of the video memory, you need to either switch the video memory banks with the 0x4f05 function, or somehow enable linear access to the video memory.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question