Trouble With Loading Memory in Protected Mode

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
ElasticRaven
Posts: 5
Joined: Mon Sep 19, 2011 6:18 pm

Trouble With Loading Memory in Protected Mode

Post by ElasticRaven »

Hello. After some work, I managed to get into 32-bit protected mode. I can access some memory correctly, but not all.

Code: Select all

[bits 16]
[org 0x8000] ; stage1 loads me at 0x0000:0x8000
...
set video mode, disable interrupts, enable A20, load gdt, set cr0 LSB
jmp 0x8:pmode_start
...
pmode_start:
[bits 32]
mov  al,[tmpvar]
mov  ebx,[tmpvar2]
mov  [0xb8000+ebx],al
mov  byte [0xb8000+ebx+1],0x7

jmp hang

tmpvar db 'A'
tmpvar2 dw 0
I would expect this to write 'A' at the top left corner. It does not. However, if I replace "[tmpvar2]" with "0", it does write 'A'. So it seems like I can get to tmpvar, but not tmpvar2. Can anyone shed some light?
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: Trouble With Loading Memory in Protected Mode

Post by gerryg400 »

I think you need

Code: Select all

tmpvar2 dd 0
or else you will be loading garbage into the upper word of ebx
If a trainstation is where trains stop, what is a workstation ?
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: Trouble With Loading Memory in Protected Mode

Post by egos »

Usually following logic is used:

Code: Select all

  movzx ebx,[superpos]
  mov [videobuf+ebx*2],al
  mov byte [videobuf+ebx*2+1],7
  ...
  superpos dw 0
Last edited by egos on Wed Sep 21, 2011 6:50 am, edited 1 time in total.
If you have seen bad English in my words, tell me what's wrong, please.
ElasticRaven
Posts: 5
Joined: Mon Sep 19, 2011 6:18 pm

Re: Trouble With Loading Memory in Protected Mode

Post by ElasticRaven »

gerryg400 wrote:I think you need

Code: Select all

tmpvar2 dd 0
or else you will be loading garbage into the upper word of ebx
Facepalm :shock: It works now.... Thanks.
Post Reply