Pmode screen printing, asm, using Flat assembler
Pmode screen printing, asm, using Flat assembler
Hi all out there, i have a littel problem i pmode.
When try to write to memory location: 0xb800, it dont.
after some time analysion what ´happend, I found out that a error happend using FASM.
i typede in the code:
mov edi,0xb8000
, but at runtime it was RDI=000000000008b800
even if i try this:
mov di,0xb800
it ends up beeing dÃffrent.
I Use BOCHS...
Can someone solve this problem
When try to write to memory location: 0xb800, it dont.
after some time analysion what ´happend, I found out that a error happend using FASM.
i typede in the code:
mov edi,0xb8000
, but at runtime it was RDI=000000000008b800
even if i try this:
mov di,0xb800
it ends up beeing dÃffrent.
I Use BOCHS...
Can someone solve this problem
Hi,
The linear address of the textmode framebuffer is 0xB8000 (note three zeroes!)
In real mode you access this with a segment selector of 0xB800, because segment selectors are shifted left 4 bits (one nibble, or that extra '0').
In pmode no such shifting takes place, so you must access 0xB8000 directly.
Hope this helps,
James
The linear address of the textmode framebuffer is 0xB8000 (note three zeroes!)
In real mode you access this with a segment selector of 0xB800, because segment selectors are shifted left 4 bits (one nibble, or that extra '0').
In pmode no such shifting takes place, so you must access 0xB8000 directly.
Hope this helps,
James
Does this work ?
Code: Select all
mov byte [es:0xB8000], "T"
Are your segment-registers and segment-descriptors setup right?
De base must be 0, otherwise an offset of 0xb8000 won't work.
Ofcourse you can a base > 0, but your offset will became different, a base of zero must work.
Did you setup the protected mode well?
What didn't work? Did only nothing appear on your screen, does the computer reboot or freeze?
Maybe (I don't think that's your problem) you are not in the right videomode. Execute the instructions "MOV AX,3" and "INT 0x10" (setting mode 3 textmode 80x25 color by calling the BIOS) before entering protected mode.
De base must be 0, otherwise an offset of 0xb8000 won't work.
Ofcourse you can a base > 0, but your offset will became different, a base of zero must work.
Did you setup the protected mode well?
What didn't work? Did only nothing appear on your screen, does the computer reboot or freeze?
Maybe (I don't think that's your problem) you are not in the right videomode. Execute the instructions "MOV AX,3" and "INT 0x10" (setting mode 3 textmode 80x25 color by calling the BIOS) before entering protected mode.
Last edited by svdmeer on Sat May 17, 2008 10:23 am, edited 1 time in total.
Re: Pmode screen printing, asm, using Flat assembler
Hmmm strange.. I assume you like to use 32-bit code.kmtdk wrote:Hi all out there, i have a littel problem i pmode.
When try to write to memory location: 0xb800, it dont.
after some time analysion what ´happend, I found out that a error happend using FASM.
i typede in the code:
mov edi,0xb8000
, but at runtime it was RDI=000000000008b800
Can someone solve this problem
If FASM set to use 32-bit code and addressing?
Are your segmentdescriptors set to use 32-bit segments? Maybe you are using a 16-bit segment, what can explain the strange value of EDI.
I use the gdt from http://www.brokenthorn.com/Resources/OSDev8.html,
and i had set a20.
The segement is 32 bit.
I dont know if Fasm is set to 32 bit, but i can use it.
the code, all or the printing.
the printing is all types, in- and directly.
i just attachmented the code, atfer the bootsector.
KMT
and i had set a20.
The segement is 32 bit.
I dont know if Fasm is set to 32 bit, but i can use it.
the code, all or the printing.
the printing is all types, in- and directly.
i just attachmented the code, atfer the bootsector.
KMT
- Attachments
-
- boot2.asm
- the secound action
- (2.06 KiB) Downloaded 165 times
The code is a messy.
I assume the first part (in realmode) prints? The messages ver and kernmsg appear on screen?
And after the proctedmode switch?
The code you uploaded is does not contain the code from your question.
First the code is running in realmode, doing some realmode screen-writing. After that, it switches to 32-bit protectedmode. So first 16-bit code is needed, after the pm-switch 32-bit. But nowhere inside the code the assembler is told to use 32-bit or 16-bit code.
I don't use Fasm, so I don't know it's defaults, but Fasm uses 16-bit or 32-bit for all the code. When the first strings appear on screen, it seems Fasm uses 16-bit code. Your pm-part will not work, you need a directive to tell Fasm the piece of code after the far-jump to protected-mode codesegment is 32-bit.
When the first part of your program isn't working, maybe fasm is using 32-bit for the whole program.
Maybe you can temporary remove your printing-code, and use a really simple piece of test-code.
Testing in your real-mode part:
In your protected-mode part:
I assume the first part (in realmode) prints? The messages ver and kernmsg appear on screen?
And after the proctedmode switch?
The code you uploaded is does not contain the code from your question.
First the code is running in realmode, doing some realmode screen-writing. After that, it switches to 32-bit protectedmode. So first 16-bit code is needed, after the pm-switch 32-bit. But nowhere inside the code the assembler is told to use 32-bit or 16-bit code.
I don't use Fasm, so I don't know it's defaults, but Fasm uses 16-bit or 32-bit for all the code. When the first strings appear on screen, it seems Fasm uses 16-bit code. Your pm-part will not work, you need a directive to tell Fasm the piece of code after the far-jump to protected-mode codesegment is 32-bit.
When the first part of your program isn't working, maybe fasm is using 32-bit for the whole program.
Maybe you can temporary remove your printing-code, and use a really simple piece of test-code.
Testing in your real-mode part:
Code: Select all
mov ax,0xb800
mov es,ax
mov byte [es:0],'R'
mov byte [es:1],0x1f
Code: Select all
mov byte [0xb8004],'P'
mov byte [0xb8005],0x1f
Hello!
Did not had the time to take a proper look at your code. Anyway, at the beginning of your file you should insert
and, after "Stage3" label
Also, in setpmode, you set interrupt flag and you clear it again ... ?! And you go with the flag cleared untill the end. A IDT would be also usefull at one point ...
The purpose of use16 - use32 is that - when in protected mode - the CPU interprets instructions a 16 bit. Once you step in protected mode, CPU espects 32 bit instruction. But be carefull if you nest 16 and 32 bit code. For example, if you have Real Mode (16 bit) code at the start of the file, then code that is executed in Protected Mode (32 bit), and then some procs that you call in Real Mode, you should use "usexx" before each of them:
Regards,
Nick
Did not had the time to take a proper look at your code. Anyway, at the beginning of your file you should insert
Code: Select all
use16
Code: Select all
use32
The purpose of use16 - use32 is that - when in protected mode - the CPU interprets instructions a 16 bit. Once you step in protected mode, CPU espects 32 bit instruction. But be carefull if you nest 16 and 32 bit code. For example, if you have Real Mode (16 bit) code at the start of the file, then code that is executed in Protected Mode (32 bit), and then some procs that you call in Real Mode, you should use "usexx" before each of them:
Code: Select all
org 0x1000
use16
; ... some real mode code
mov eax, cr0
or eax, 1
mov cr0, eax
jmp ChangeCS
ChangeCS:
use32
; ... some code
hlt
use16
EnableA20:
; ...
ret
;(assuming you get to 0x1000 by relocating yourself. If you read this pice of code from the disk, then this proc should obviously be placed in first sector.
ReadDisk16:
; ...
ret
Nick