flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Problem with doing intersegmental syscalls :( HELP!!!!!!

Thread Post new topic Reply to topic

Joined: 30 Jul 2013
Posts: 339
Location: Asia, Singapore
sid123 17 Nov 2013, 11:53
So, I have got two kernels,
One is the main one called from my own second stage bootloader known as NTLOAD.SYS, as APOS16.SYS (Kernel Filename),
Now that I need to extend my kernel API and keeping my kernel size limited, I've got to do intersegmental syscalls like :
; Assuming I'm in segment 0x2000
; I would do this
jmp 0x3000:0x0000
jmp 0x3000:0x0003
jmp 0x3000:0x0004
; and so on........

Basically I would load a file called BOOTDRV.SYS which contains these calls,
Now I have written some code but they don't seem to work.
My Kernel Caller,
; Load the BOOTDRV.SYS (Boot Drivers) in memory at 0x3000
        ; First Initialize the FDD
        call init_FDD
        ; Set up segments
        cli                             ; Clear interrupts
        mov ax, 0
        mov ss, ax                      
        mov sp, 0FFFFh
        mov ax,2000h                    
        mov ds, ax                      
        mov es, ax                      
        mov fs, ax                      
        mov ax,0x3000 ; ---> Reserved for BOOTDRV.SYS
        mov gs,ax
        call load_kernel
        call os_command_line ; Start the Interface
        mov ax, .pos16_sys
        mov cx, 28768
        call os_load_file
        jc os_fatal_error
        push es
        push 0x3000
        pop es
        mov si, 28768
        mov di, 0
        mov cx, bx
        rep movsb
        mov ax, 0000h
        mov es, ax
        mov word [es:0014h], 0x3000
        mov word [es:0016h], .BOOT_BREAK
        mov word [es:006Ch], 0x3000 
        mov word [es:006Eh], .BOOT_BREAK
        pop es
        .pos16_sys db 'BOOTDRV.SYS',0
        pop ax
        pop ax
        push 2000h
        push os_command_line

And here's how my extended kernel looks like :
; POS16 Extended API
jmp os_lol ; 0x3000:0x0000
        pop word [gs:flags_tmp]
        cmp byte [gs:internal_call], 1
        jge .internal_return
        mov word [gs:return_ax_tmp], ax
        mov ax, fs
        mov ds, ax
        mov es, ax
        pop ax
        push 0x2000
        push ax
        mov ax, [gs:return_ax_tmp]
        push word [gs:flags_tmp]
flags_tmp                       dw 0
internal_call                   dw 0            ; cancels os_return
return_ax_tmp                   dw 0
        mov ah,0x0E
        jmp .loop
        cmp al,0
        je .done
        int 10h
        jmp SEGMENT_RETURN

And I perform the call like this :
ext_print equ 3000h:0000h
mov si,lol2
call ext_print
jmp back_2_interface
lol2 db 'LOL! Printed from the Extended Kernel',0

When I execute this my OS halts and then the screen is almost unreadable?
Is there something wrong?[/code]

"Those who can make you believe in absurdities can make you commit atrocities" -- Voltaire https://github.com/Benderx2/R3X
Post 17 Nov 2013, 11:53
View user's profile Send private message Reply with quote
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 19098
Location: In your JS exploiting you and your system
revolution 18 Nov 2013, 01:36
Seem rather complicated. Perhaps instead you can try something like this:
mov si,text
mov ax,cs
mov ds,ax
call 0x3000:ext_print
jmp $
text: db 'Hello World!',0

;... skip to segment 0x3000
org 0
        call    int_print

        ; 'int 0x10' printing code goes here
Post 18 Nov 2013, 01:36
View user's profile Send private message Visit poster's website 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-2023, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.