flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Simple question about output in PM

Author
Thread Post new topic Reply to topic
merlin



Joined: 17 Nov 2003
Posts: 11
merlin 10 Sep 2006, 19:25
Hi, I coded this simple boot progie, and for some reason I see no
new output when I switch to PM...
I can hardly determine where the problem is, however I'm pretty sure
that PM code is reached, and the GDT looks ok.
Here it is:
Code:
use16
org 0x0

tagStart:
        mov     ax, 0x2000
        mov     ss, ax
        mov     sp, 0xFFFF

        xor     ebp, ebp
        call @@10
@@10:
        pop bp
        sub bp, @@10-tagStart
        mov bx, bp
        shr bx, 4
        mov ds, bx

        mov ax, cs
        mov ss, ax
        mov sp, bp      ; Stack is below the code

        mov     ax, 0x3
        int     0x10

        mov     si, greet
        call    PrintZStringReal

        mov     al, 0x92
        or      al, 2
        out     0x92, al

        xor     eax, eax
        mov     ax, cs
        shl     eax, 4
        add     eax, ebp
        add     eax, gdt
        mov     [gdtr+2], eax
        
        xor     eax, eax
        mov     ax, cs
        shl     eax, 4
        add     eax, ebp
        add     eax, PM_ENTRY
        mov     [entry_offset], eax
        
        lgdt    [gdtr]
        cli

        mov     eax, cr0
        or      al, 1
        mov     cr0, eax
        
        db      0x66    ; Far jmp
        db      0xEA
entry_offset:
        dd      ?
        dw      00001000b


PrintZStringReal:
        push    ax
        push    bx
        push    si

        mov     ah, 0xE
        xor     bx, bx

@@PSZ10:        
        lodsb
        test    al, al
        jz      @@PSZ99
        int     0x10
        jmp     @@PSZ10

@@PSZ99:
        pop     si
        pop     bx
        pop     ax
        ret     

greet db 'RM...', 10, 13, 0

gdt:
        dq      0x0
        
        ; Code descriptor:
        ;       Base = 0, Limit = 0xFFFFFFFF
        db      0xFF, 0xFF, 0x0, 0x0, 0x0, 10011010b, 11001111b , 0x0
        
        ; Data descriptor:
        ;       Base = 0, Limit = 0xFFFFFFFF
        db      0xFF, 0xFF, 0x0, 0x0, 0x0, 10010010b, 11001111b , 0x0

gdtr:
        dw      $-gdt   ; gdt size
        dd      ?       ; gdt offset


STACK_OFFSET equ 0x20000

PM_ENTRY:
        mov     ax, 0x10
        mov     ds, ax
        mov     es, ax
        mov     ss, ax
        mov     esp, STACK_OFFSET

        mov     al, 'a'
        mov     edi, 0xB8000+160
        stosb

        cli
        hlt

times 510-($-$$) db 0
dw 0xAA55
    


Any hint on what's wrong?
Thanks for the help (in advance)...
Post 10 Sep 2006, 19:25
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 10 Sep 2006, 19:47
are you sure with "org 0" isn't that code loaded at org 7C00 or something like that?
Post 10 Sep 2006, 19:47
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
merlin



Joined: 17 Nov 2003
Posts: 11
merlin 10 Sep 2006, 19:49
Usually it does... but not with non-standard BIOSes. As you might
guess I'm working with such, I've never been required to write
such stuff, but now...
Anyway, all offsets are calulated manually, so the code doesn't
really care where it's loaded (as I need).


Last edited by merlin on 11 Sep 2006, 12:58; edited 1 time in total
Post 10 Sep 2006, 19:49
View user's profile Send private message Reply with quote
merlin



Joined: 17 Nov 2003
Posts: 11
merlin 10 Sep 2006, 19:55
s**t, arggggggh ................
I forgot use32, stupid me..............
All works... topic closed...
Well almost...
Any idea on how to move that cursor?
Post 10 Sep 2006, 19:55
View user's profile Send private message Reply with quote
UCM



Joined: 25 Feb 2005
Posts: 285
Location: Canada
UCM 10 Sep 2006, 20:13
Some port (look it up, I forgot.)
Post 10 Sep 2006, 20:13
View user's profile Send private message Reply with quote
merlin



Joined: 17 Nov 2003
Posts: 11
merlin 10 Sep 2006, 20:17
Thanks, I'll check Ralph Brown...
Post 10 Sep 2006, 20:17
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 10 Sep 2006, 21:12
Cursor can be set like this:
Code:
 ;''''''''''''''''''''''''''''''''''''''''''''''''''''; ; Sets cursor pos                                    ; ;----------------------------------------------------; ;                                                    ; ;  Input:                                            ; ;     [screen_x]    points to X                      ; ;                                                    ; ;     [screen_Y]    points to Y                      ; ;                                                    ; ; Output:                                            ; ;      None.                                         ; ;....................................................;set_cursor_pos:        push  eax        push  ebx        push  ecx        push  edx        xor   ebx,ebx        mov   bl,[screen_x]        mov   ecx,ebx        mov   bl,[screen_y]        mov   eax,80        mul   bx        add   eax,ecx        mov   edx,0x3d4        mov   ecx,eax        mov   al,0x0f        out   dx,al        mov   eax,ecx        inc   edx        out   dx,al        mov   al,0x0e        dec   edx        out   dx,al        mov   eax,ecx        mov   al,ah        inc   edx        out   dx,al        pop   edx        pop   ecx        pop   ebx        pop   eax        ret    
Post 10 Sep 2006, 21:12
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 10 Sep 2006, 21:24
Quote:
Anyway, all offsets are calulated manually, so the code doesn't
really care where it's loaded (as I need).


hmm, what's this?
Code:
 mov     [gdtr+2], eax    
Post 10 Sep 2006, 21:24
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
merlin



Joined: 17 Nov 2003
Posts: 11
merlin 11 Sep 2006, 12:50
@Dex4u:
Thanks man... It saved me quite a lot of time Smile

@vid:
In the first lines of code I set the ds selector to point to the start of
the code, so "org 0x0" becomes quite natural after this...
Here it is:
Code:
        mov    ax, cs
        xor     ebp, ebp 
        call @@10 
@@10:
        pop bp 
        sub bp, @@10-tagStart 
        mov bx, bp 
        shr bx, 4 
        add bx, ax
        mov ds, bx
    


In the original I forgot to add cs, however here it's added.
Post 11 Sep 2006, 12:50
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.