this procedure for writing into video memory while in Protected Mode doesnt work
it takes position information followed by ascii-z string
(note: is has been taken from PM tutorial by Till Gerken)
;----------------------------------------------------------------------------
; protected mode translation of write_msg
; In: DS:ESI - pointer to format string
proc write_msg_pm
push ax esi edi es
mov ax,18H ;the index of a segment selector
;which has a base of zero and limit of
;FFFFFFFF
mov es,ax
movzx di,[esi+2] ; get Y position
imul edi,160
add di,[esi] ; add X position
add di,[esi]
add edi,0b8000h ; physical address of text screen
mov ah,[esi+4] ; get attribute byte
add esi,5
write_loop:
mov al,[esi]
or al,al ; end of string?
jz loop_end
inc esi
mov [es:edi],ax
inc edi
inc edi
jmp write_loop
loop_end:
pop es edi esi ax
ret
endp write_msg_pm
;----------------------------------------------------------------------------
this procedure was called from a main function as follows, with interrupts
disabled (since i am initializing the pmode):
;----------------------------------------------------------------------------
mov esi,offset pm_msg ; just put the message...
call write_msg_pm
;----------------------------------------------------------------------------
the message is stored as follows:
;----------------------------------------------------------------------------
pm_msg db 0,0,1,0,1fh,'Now in Protected Mode'
;----------------------------------------------------------------------------
the descriptor of the segment is defined as follows
;----------------------------------------------------------------------------
struc segment_descriptor
seg_length0_15 dw ? ; low word of the segment length
base_addr0_15 dw ? ; low word of base address
base_addr16_23 db ? ; low byte of high word of base addr.
flags1 db ?
flags2 db ?
base_addr24_31 db ? ; highest byte of base address
ends segment_descriptor
;then our descriptor
segment_descriptor <0ffffh,0,0,92h,0cfh,0> ; 4GB 32-bit core
;----------------------------------------------------------------------------
the code is written in TASM ideal.
i believe switching has been done succesfully, since the interrupts map to
the correct handlers and other procedures for speaker output works fine,
but this one doesnt work.
i believe too that i am using the memory location, i used it just before
switching to PMODE and it worked fine.
why doesnt this code work?
-
- Posts: 12
- Joined: Fri Jul 01, 2005 11:00 pm
Re: why doesnt this code work?
I will try your code soon. Just one question though. You say it doesn't work. Does nothing show up on the screen, does the wrong stuff appearm or what happens? I wonder if this is the problem, but there is no 0 at the end of your string. (I notice you don't use NASM so your assembler might automatically put them there. Tell me if I'm wrong.) you should probably write
Code: Select all
pm_msg db 0,0,1,0,1fh,'Now in Protected Mode',0
Re: why doesnt this code work?
I agree with yetAnotherOS, you are missing a 0 at the end of your string. However you should really post how it doesn't work, does it not assemble, or is it when trying to boot the OS? In the latter case please post what does happen, how far does the OS get in it's loading, does it reboot with error or does it simply not display your string or display it wrong?
If the computer reboots it could mean trouble already before your write_msg_pm is called.
Please if you post more code place it in codeboxes as yetAnotherOS did, it makes reading easier.
Let us know when/if it has been fixed and what was the problem/what fixed it.
/Wrigley
If the computer reboots it could mean trouble already before your write_msg_pm is called.
Please if you post more code place it in codeboxes as yetAnotherOS did, it makes reading easier.
Let us know when/if it has been fixed and what was the problem/what fixed it.
/Wrigley
-
- Member
- Posts: 25
- Joined: Sat Jun 25, 2005 11:00 pm
Re: why doesnt this code work?
I am sorry for being too late to reply
a zero did exist but i have forgotten it in the post
any way, i have skipped the problem totally (with no solution found) and replaced all that stuff with another code that switches to the video mode 13H and prints a message in graphics mode
thank you very much for your cooperation
a zero did exist but i have forgotten it in the post
any way, i have skipped the problem totally (with no solution found) and replaced all that stuff with another code that switches to the video mode 13H and prints a message in graphics mode
thank you very much for your cooperation