flat assembler
Message board for the users of flat assembler.

Index > OS Construction > JUMP [SOLVED]

Author
Thread Post new topic Reply to topic
BOTOKILLER



Joined: 07 Jan 2011
Posts: 154
Location: Ukraine
BOTOKILLER 25 Jul 2011, 11:30
Hi everyone!!!
I've decided to rewrite the whole code so, that it becomes cleaner and more scalable, also try using paging. Well, I ran into a problem.
Code:
        USE16
        ORG 0h

        ;NOT ASSEMBLED!!!
        PRE_ASM_VAR:
        SSBL_Size equ 80h           ;should be like in MBR
        SSBL_Stack equ 20h          ;same
        Primary_CS equ 8h
        SDAq equ 0
        KERN_LOAD_Seg equ 0
        END_PRE_ASM_VARS:
        ;ASSEMBLED!!!

        jmp START


        DATASECT:

        DAP:                              ;DATA;REL
        DAP_Size             db 10h       ;0h  ;1h
        DAP_Res1             db 0         ;1h  ;2h
        DAP_Bytes2Transfer   db 1h        ;2h  ;3h
        DAP_Res2             db 0         ;3h  ;4h
        DAP_Buff_Addr1       dw 0h        ;4h  ;6h
        DAP_Buff_Addr2       dw 8000h     ;6h  ;8h
        DAP_LBA              dq 1h        ;8h  ;9h

        DAT_Disk_Num         db 80h       ;10h ;12h          number of device 80h-winchester
        DAT_Num_Of_Sects     dw 04h       ;11h ;13h          the number of 512byte sectors, that contain your kernel your kernel + 1

        END_DAP:

        GDT:
                dw GDT_ENDS + GDT_STARTS - 1h              ;size of GDT
                dd 0h                                       ;value to be inserted during execution
        GDT_STARTS:
        REC0:
                dq 0h

        REC1:
                dw 0FFFFh      ;Limit_0_15
                dw 00000h      ;Base_0_15
                db 00h         ;Base_16_23
                db 10011010b   ;||Present bit||Priviligies||1||Code-1, Data - 0||if want to execute from low levels - 1, else 0|| can write here? yes=1||0||
                db 11001111b   ;||Granularity||1||0||0||Limit 16-19||
                db 00h         ;Base_24_31

        REC2:
                dw 0FFFFh      ;Limit_0_15
                dw 00000h      ;Base_0_15
                db 00h         ;Base_16_23
                db 10010010b   ;||Present bit||Priviligies||1||Code-1, Data - 0||if want to execute from low levels - 1, else 0|| can write here? yes=1||0||
                db 11001111b   ;||Granularity||1||0||0||Limit 16-19||
                db 00h         ;Base_24_31


        GDT_ENDS:

        END_DATEASECT:

        START:

        SETREG_SSBL:
        xor eax, eax                       ;clean eax
        mov ax, cs                         ;ax = cs
        mov ds, ax                         ;ds = cs
        mov ss, ax                         ;ss = cs
        mov sp, (SSBL_Stack + SSBL_Size)*10h;stack points 256 bytes above end of SSBL
        shl eax, 4h                         ;get raw address of start of segment
        add eax, GDT_STARTS                 ;adding ofset of start of GDT
        mov dword [ds:GDT+2], eax          ;GDT offset ready
        mov bp, DATASECT                   ;base pointer = datasect
        ;well... thats all

        PMJMP:
        cli                                ;disable interrupts

        lea eax, [ds:GDT]
        lgdt [eax]

        mov ax, 2401h
        int 15h

        xor eax, eax
        mov ax, cs
        shl eax, 4h
        add eax, PMODE

        mov ebx, cr0
        or ebx, 1
        mov cr0, ebx

        jmp Primary_CS:eax  ;!!! HERE ERROR!!!

        USE32
        PMODE:


        FIN:
        times 2047d - FIN db 0h
        db 'F'        

    

I need to make a jump into protected mode code through address calculated in eax, but compiller doesnt lets me do it! Code is loaded right before EBDA and I dont know address where it is executed before compilation. How do I make that jump???

_________________
_______________________________
NSOS


Last edited by BOTOKILLER on 25 Jul 2011, 13:06; edited 1 time in total
Post 25 Jul 2011, 11:30
View user's profile Send private message Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto 25 Jul 2011, 12:05
put the address in memory and make a jump Wink

Code:

Jmp  [16:32]
    

_________________
Nil Volentibus Arduum Razz
Post 25 Jul 2011, 12:05
View user's profile Send private message Reply with quote
BOTOKILLER



Joined: 07 Jan 2011
Posts: 154
Location: Ukraine
BOTOKILLER 25 Jul 2011, 13:07
Thats what i did:
Code:
        PMJMP:
        cli                                 ;disable interrupts

        xor eax, eax
        mov ax, cs
        shl eax, 4h
        add eax, PMODE
        mov [cs:JUMP_+2], eax

        lea eax, [ds:GDT]
        lgdt [eax]

        mov ax, 2401h
        int 15h

        mov ebx, cr0
        or ebx, 1
        mov cr0, ebx

        JUMP_:
        jmp pword Primary_CS:0h

                      

_________________
_______________________________
NSOS
Post 25 Jul 2011, 13:07
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.