flat assembler
Message board for the users of flat assembler.

Index > OS Construction > CALL-RETD results in triple fault, but macro version works?

Author
Thread Post new topic Reply to topic
newport



Joined: 08 Jun 2012
Posts: 86
Location: Kentucky, USA
newport 20 Aug 2012, 23:53
I've reached a point in the development of my OS where I'm practicing writing macros, and would like to get down some CALL-RETD procedures, however no matter what I do, anytime I use the CALL method I get a triple fault. I've read the manuals, and search the forums, even borrowed some posted code but it's a no go...

Can someone please explain to me where I'm going wrong?

OS is currently in 32-bit protected mode...

This MACRO works:

Code:
macro showchar [char] {

mov al, char
mov edi, 0xB8000
mov byte [es:edi], al
inc edi
mov byte [es:edi], 0Fh

}        
    

showchar "A" results in an 'A' being displayed....

However, writing it as a CALL does not:
Code:
showChar:
        mov al, 'A'
        mov edi, 0xB8000
        mov byte [es:edi], al
        inc edi
        mov byte [es:edi], 0Fh
        retd   
    


CALL showChar results in triple fault....


Thanks in advance! Any help is greatly appreciated!

_________________
It's the desire to learn that leads to success...

http://www.webicomp.com
Post 20 Aug 2012, 23:53
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20593
Location: In your JS exploiting you and your system
revolution 20 Aug 2012, 23:57
We have no idea what you have done. We can't even test what you have posted. Show all your code.
Post 20 Aug 2012, 23:57
View user's profile Send private message Visit poster's website Reply with quote
newport



Joined: 08 Jun 2012
Posts: 86
Location: Kentucky, USA
newport 21 Aug 2012, 00:15
rezinBootLoader.asm
Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;       RezinOS by Rezin aka Newport c 2012
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;; Author:      Rezin aka Newport
;;;;;;;;;;;;; File:      rezin_bootLoader.asm
;;;; Date Modified:      8/20/2012
;;;;;;;;;; Summary:      To initialize the boot sequence ( Sector1 ),
;;;;;;;;;;               and in the sequential section ( Sector2 ),
;;;;;;;;;;               to establish the Rezin Operating System
;;;;;;;;;;               as Outlined below::
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;; Phase 01:      Clear Direction Flag
;;;;;;;;; Phase 02:      Disable Interrupts
;;;;;;;;; Phase 03:      Reset Segment Registers (ds, es, fs, gs, ss)
;;;;;;;;; Phase 04:      Set the stack pointer
;;;;;;;;; Phase 05:      Enable interrupts
;;;;;;;;; Phase 06:      Engage floppy disk controller with correct params (2 sect. flp)
;;;;;;;;; Phase 07:      Read first sector from the floppy and include Boot Macro's
;;;;;;;;; Phase 08:      Jump to section Sector2 for continuation (Define ORG 1000h directly before 2nd Sector Label !!!)
;;;;;;;;; Phase 09:      Set the stack pointer and base of origin
;;;;;;;;; Phase 10:      Enable the A20 gate
;;;;;;;;; Phase 11:      Load the Global Descriptor Table
;;;;;;;;; Phase 12:      Switch to protected mode
;;;;;;;;; Phase 13:      Re-Program the PIC's
;;;;;;;;; Phase 14:      Define and Load the Interrupt Descriptor Table
;;;;;;;;; Phase 15:      Begin Kernel

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        format binary as 'img.flp'

        use16

        org 7C00h
        BeginBoot:
                cld
                cli
                xor ax, ax
                mov ds, ax
                mov es, ax
                mov fs, ax
                mov gs, ax
                mov ss, ax

                mov sp, 7C00h

                sti

                mov dl, 00h
                mov dh, 00h
                mov ah, 02h
                mov al, 2
                mov ch, 0
                mov cl, 02h
                mov bx, nextSector
                int 13h

                include '\macros\bootMacs.macs'

                ;echo 'Boot Sequence Initialized...'
                jmp nextSector

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

       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       ;;;;;;;;;SET STACK AND SECTOR 2 BASE OF ORIGIN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

        org 1000h
        nextSector:
                xor ax, ax
                mov es, ax
                mov si, 1000h

       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       ;;;;;;;;;A20 TESTING AND ENABLING;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

                ;echo 'Enable the A20 gate...'
                ;echo ' '

        A20FuncTest:
                mov ax, 0x2402
                int 0x15
                cmp al, 0 ; ax=2402 status returned to al, 0 means disabled, 1 means enabled
                je a20disabled
                cmp al, 1
                je a20enabled
                jmp A20NonStatus

        a20disabled:
                ;echo 'A20 is disabled and needs to be ENABLED..!!!'
                jmp EnableTheA20

        a20enabled:
                ;echo 'A20 is ENABLED...!!! No need for further action...'
                ;echo 'Time to load our GDT ( Global Descriptor Table )...'
                ;echo ' '
                jmp nextSectorGDT

        A20NonStatus:
                ;echo '***Current A20 Status could not be determined!!!***'
                ;echo ' '
                jmp EndAllBoot

        EnableTheA20:
                mov ax, 0x2401
                int 0x15
                ;echo 'Attempting Enable followed by re-testing of A20....'
                ;echo ' '
                jmp A20FuncTest

       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       ;;;;;;;;;LOAD AND ENGAGE GDT ( GLOBAL DESCRIPTOR TABLE );;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;DEFINE GDT;;;;;;;;;;
                gdt_begin:

                gdt_null:
                        dd 0
                        dd 0

                gdt_code:
                        dw 0ffffh
                        dw 0
                        db 0
                        db 10011010b
                        db 11001111b
                        db 0

                gdt_data:
                        dw 0ffffh
                        dw 0
                        db 0
                        db 10010010b    ;92h
                        db 11001111b    ;0CFh
                        db 0

                gdt_end:

                gdt_descriptor:
                        dw gdt_end - gdt_begin - 1
                        dd gdt_begin

        CODESEG equ gdt_code - gdt_begin
        DATASEG equ gdt_data - gdt_begin
        STACK32 equ [$ + 1024] ;0x8000 ;0x0100 ;0x9000

;;;;;;;;;;END GDT DEFINITION;;;;;;;;;;


nextSectorGDT:

        cli

        xor ax, ax
        mov ds, ax
        mov es, ax
        mov fs, ax
        mov gs, ax
        mov ss, ax

        lgdt [gdt_descriptor]

        mov eax, cr0
        or eax, 1
        mov cr0, eax

        jmp CODESEG:pmodeBegin     ; 0x08:squeegy or 08h:pmodeBegin ** Far Jump / also updates CS register for flushing

use32
pmodeBegin:
        mov ax, DATASEG         ; 0x10 or 10h
        mov ds, ax
        mov es, ax
        mov fs, ax
        mov gs, ax
        mov ss, ax
        mov esp, STACK32

        jmp LoadMacros

LoadMacros:

      ;include 'macros\mac32.macs'
      include 'asm_Includes\callReturns.asm'


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;       Here we practice the writing strings macro...
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

showchar "B"

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;       Here we practice our calls
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

call showChar

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;       END PRACTICE SECTION
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

      jmp LoadIDT

LoadIDT:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;   Load INTERRUPT DESCRIPTOR TABLE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        ;include 'dts\rezin_idt.asm' -- (Currently Incomplete)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;   End INTERRUPT DESCRIPTOR TABLE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

        jmp EndAllBoot

        EndAllBoot:

                jmp $  ;;;;;;;;;;;;;;;;;;;;;The last statement made conforms a loop



        times 1474560 - ($-$$) db 0
        ;times 1024 - ($-$$) db 0  
    


callReturns.asm
Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;; Author:      Rezin aka Newport
;;;;;;;;;;;;; File:      callReturns.asm
;;;; Date Modified:      8/20/2012
;;;;;;;;;; Summary:      This file used as a macro/Call-Retd practice file only....
;;;;;;;;;;
;;;;;;;;;;
;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
macro showchar [char] {

mov al, char
mov edi, 0xB8000
mov byte [es:edi], al
inc edi
mov byte [es:edi], 0Fh

}

showChar:
        mov al, 'A'
        mov edi, 0xB8000
        mov byte [es:edi], al
        inc edi
        mov byte [es:edi], 0Fh
        retd                       
    


Thanks Revolution for your help!

_________________
It's the desire to learn that leads to success...

http://www.webicomp.com
Post 21 Aug 2012, 00:15
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20593
Location: In your JS exploiting you and your system
revolution 21 Aug 2012, 00:48
Well your problem is that when you include the "callRetuns.asm" file you are immediately executing the showChar function. Remember that "include" places the text of the included file into the assembly as if you have typed the text there yourself.
Code:
LoadMacros:

      ;include 'macros\mac32.macs'
      ;;;include 'asm_Includes\callReturns.asm'

;... inside callReturns.asm

;<snip>

showChar:
        mov al, 'A'
        mov edi, 0xB8000
        mov byte [es:edi], al
        inc edi
        mov byte [es:edi], 0Fh
        retd  
                     
;... back to main file

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;       Here we practice the writing strings macro...
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

showchar "B"
    
Post 21 Aug 2012, 00:48
View user's profile Send private message Visit poster's website Reply with quote
newport



Joined: 08 Jun 2012
Posts: 86
Location: Kentucky, USA
newport 21 Aug 2012, 01:06
oh...so if I was to move it more toward the end it should work?

_________________
It's the desire to learn that leads to success...

http://www.webicomp.com
Post 21 Aug 2012, 01:06
View user's profile Send private message Visit poster's website Reply with quote
newport



Joined: 08 Jun 2012
Posts: 86
Location: Kentucky, USA
newport 26 Aug 2012, 00:00
OK...sorry for such a long delay since my last post, but moving the call instruction further down in the program doesn't work either. After several days of testing I have come to the conclusion that the ret(d) instruction fails when it is part of an include file..As long as the call/ret routine is within the same file everything works as expected, but the minute I try to call to a routine from another file, that's when I get my error (ie: it fails to return) ...

Has anyone encountered this or know of a solution...I have searched high and low, and read tons of articles/tutorials to no-avail....

Thanks in advance to anyone who can shed some light on this for me....

_________________
It's the desire to learn that leads to success...

http://www.webicomp.com
Post 26 Aug 2012, 00:00
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20593
Location: In your JS exploiting you and your system
revolution 26 Aug 2012, 00:05
Show your latest code so we can help solve it for you.
Post 26 Aug 2012, 00:05
View user's profile Send private message Visit poster's website Reply with quote
newport



Joined: 08 Jun 2012
Posts: 86
Location: Kentucky, USA
newport 26 Aug 2012, 00:54
ok...thanks revolution...here it is....

my directory structure is as follows:

C:\fasm\myOS\rezin_bootLoader.asm
C:\fasm\myOS\asmIncs\cRets.asm

rezin_bootLoader.asm
Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;       RezinOS by Rezin aka Newport copyright 2012
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;; Author:      Rezin aka Newport
;;;;;;;;;;;;; File:      rezin_bootLoader.asm
;;;; Date Modified:      8/25/2012
;;;;;;;;;; Summary:      To initialize the boot sequence ( Sector1 ),
;;;;;;;;;;               and in the sequential section ( Sector2 ),
;;;;;;;;;;               to establish the Rezin Operating System
;;;;;;;;;;               as Outlined below::
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;; Phase 01:      Clear Direction Flag
;;;;;;;;; Phase 02:      Disable Interrupts
;;;;;;;;; Phase 03:      Reset Segment Registers (ds, es, fs, gs, ss)
;;;;;;;;; Phase 04:      Set the stack pointer
;;;;;;;;; Phase 05:      Enable interrupts
;;;;;;;;; Phase 06:      Engage floppy disk controller with correct params (2 sect. flp)
;;;;;;;;; Phase 07:      Read first sector from the floppy and include Boot Macro's
;;;;;;;;; Phase 08:      Jump to section Sector2 for continuation (Define ORG 1000h directly before 2nd Sector Label !!!)
;;;;;;;;; Phase 09:      Set the stack pointer and base of origin
;;;;;;;;; Phase 10:      Enable the A20 gate
;;;;;;;;; Phase 11:      Load the Global Descriptor Table
;;;;;;;;; Phase 12:      Switch to protected mode
;;;;;;;;; Phase 13:      Re-Program the PIC's
;;;;;;;;; Phase 14:      Define and Load the Interrupt Descriptor Table
;;;;;;;;; Phase 15:      Begin Kernel

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        format binary as 'img.flp'

        use16

        org 7C00h
        BeginBoot:
                cld
                cli
                xor ax, ax
                mov ds, ax
                mov es, ax
                mov fs, ax
                mov gs, ax
                mov ss, ax

                mov sp, 7C00h

                sti

                mov dl, 00h
                mov dh, 00h
                mov ah, 02h
                mov al, 2
                mov ch, 0
                mov cl, 02h
                mov bx, nextSector
                int 13h

                include '\macros\bootMacs.macs'

                ;echo 'Boot Sequence Initialized...'
                jmp nextSector

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

       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       ;;;;;;;;;SET STACK AND SECTOR 2 BASE OF ORIGIN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

        org 1000h
        nextSector:
                xor ax, ax
                mov es, ax
                mov si, 1000h

       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       ;;;;;;;;;A20 TESTING AND ENABLING;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

                ;echo 'Enable the A20 gate...'
                ;echo ' '

        A20FuncTest:
                mov ax, 0x2402
                int 0x15
                cmp al, 0 ; ax=2402 status returned to al, 0 means disabled, 1 means enabled
                je a20disabled
                cmp al, 1
                je a20enabled
                jmp A20NonStatus

        a20disabled:
                ;echo 'A20 is disabled and needs to be ENABLED..!!!'
                jmp EnableTheA20

        a20enabled:
                ;echo 'A20 is ENABLED...!!! No need for further action...'
                ;echo 'Time to load our GDT ( Global Descriptor Table )...'
                ;echo ' '
                jmp nextSectorGDT

        A20NonStatus:
                ;echo '***Current A20 Status could not be determined!!!***'
                ;echo ' '
                jmp theEnd

        EnableTheA20:
                mov ax, 0x2401
                int 0x15
                ;echo 'Attempting Enable followed by re-testing of A20....'
                ;echo ' '
                jmp A20FuncTest

       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       ;;;;;;;;;LOAD AND ENGAGE GDT ( GLOBAL DESCRIPTOR TABLE );;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;DEFINE GDT;;;;;;;;;;
                gdt_begin:

                gdt_null:
                        dd 0
                        dd 0

                gdt_code:
                        dw 0ffffh
                        dw 0
                        db 0
                        db 10011010b
                        db 11001111b
                        db 0

                gdt_data:
                        dw 0ffffh
                        dw 0
                        db 0
                        db 10010010b    ;92h
                        db 11001111b    ;0CFh
                        db 0

                gdt_end:

                gdt_descriptor:
                        dw gdt_end - gdt_begin - 1
                        dd gdt_begin

        CODESEG equ gdt_code - gdt_begin
        DATASEG equ gdt_data - gdt_begin
        STACK32 equ  0x9000

;;;;;;;;;;END GDT DEFINITION;;;;;;;;;;


nextSectorGDT:

        cli

        xor ax, ax
        mov ds, ax
        mov es, ax
        mov fs, ax
        mov gs, ax
        mov ss, ax

        lgdt [gdt_descriptor]

        mov eax, cr0
        or eax, 1
        mov cr0, eax

        jmp CODESEG:pmodeBegin     ; 0x08:squeegy or 08h:pmodeBegin ** Far Jump / also updates CS register for flushing

align 4
use32

pmodeBegin:
        mov ax, DATASEG         ; 0x10 or 10h
        mov ds, ax
        mov es, ax
        mov fs, ax
        mov gs, ax
        mov ss, ax
        mov esp, STACK32

        jmp LoadMacros

LoadMacros:

      jmp LoadIDT


LoadIDT:


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;   Load INTERRUPT DESCRIPTOR TABLE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        ;include 'dts\rezin_idt.asm' -- (Currently Incomplete)
        ;include 'dts\idt_test.inc'  -- (Sample IDT)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;   Emd INTERRUPT DESCRIPTOR TABLE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


        jmp EndAllBoot

        EndAllBoot:
        jmp procover
        showChar:
        mov edi, 0xB8000
        mov byte [es:0xB8000], 'a'
        inc edi
        inc edi
        mov byte [es:0xB8002], 62h
        inc edi
        retd

        procover:
                call showChar
                jmp procover2

       procover2:

                include 'C:\fasm\RezinOS\asmIncs\cRets.ASM'
                 ;if this routine is put within this file (rezin_bootloader.asm) all is fine
                call showChar2
                jmp theEnd
       theEnd:
       jmp $




        times 1474560 - ($-$$) db 0
        ;times 1024 - ($-$$) db 0

    

cRets.asm
Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;; Author:      Rezin aka Newport
;;;;;;;;;;;;; File:      callReturns.asm
;;;; Date Modified:      8/25/2012
;;;;;;;;;; Summary:      This file used as a macro/Call-Retd practice file only....
;;;;;;;;;;
;;;;;;;;;;
;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


    showChar2:

        mov edi, 0xB8000
        mov byte [es:0xB8000], 'c'
        inc edi
        mov byte [es:0xB8001], 0fh
        inc edi

        retd

    

_________________
It's the desire to learn that leads to success...

http://www.webicomp.com


Last edited by newport on 26 Aug 2012, 01:05; edited 2 times in total
Post 26 Aug 2012, 00:54
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20593
Location: In your JS exploiting you and your system
revolution 26 Aug 2012, 01:00
So you have the same problem as last time. You execute the retd with no associated call to it.

Try something like this instead:
Code:
       procover2:
                call showChar2
                jmp theEnd
       theEnd:
       jmp $

                include 'C:\fasm\RezinOS\asmIncs\cRets.ASM    
Post 26 Aug 2012, 01:00
View user's profile Send private message Visit poster's website Reply with quote
newport



Joined: 08 Jun 2012
Posts: 86
Location: Kentucky, USA
newport 26 Aug 2012, 01:04
Absolutely freaking amazing!!!

I can't believe I've spent almost a week on this and the solution was that simple....


But, ... I don't understand why the file include must be after the call rather than before?

_________________
It's the desire to learn that leads to success...

http://www.webicomp.com
Post 26 Aug 2012, 01:04
View user's profile Send private message Visit poster's website Reply with quote
newport



Joined: 08 Jun 2012
Posts: 86
Location: Kentucky, USA
newport 26 Aug 2012, 01:10
nevermind...you just said i executed the retd with no associated call, and now I can see that...how could I have been so blind...

Thanks for the help revolution! You saved me again.....

_________________
It's the desire to learn that leads to success...

http://www.webicomp.com
Post 26 Aug 2012, 01:10
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.