why doesnt this code work?
Posted: Fri Jul 01, 2005 11:00 pm
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.
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.