when and where to create stack

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
akash

when and where to create stack

Post by akash »

I am trying to develope small os.
i can load my kernel.
i can print single characters with 10h.
but when i call function and pass pointers for printing string
it is not working.

please help
Adek336

RE:when and where to create stack

Post by Adek336 »

hm another stack question

anyways, how bad does it do? is it possible to call a function and get back from it? perhaps you've got to set up [org] correctly, and test if DS is correct (I think for you it is DS = CS). You say it is a small kernel, can you post it?

Adrian
akash

RE:when and where to create stack

Post by akash »

Thank you Adek336 for your help.
I got it solved by foll code
before my main in kernel.
If you feel stack is less or can create problems
please let me know




[BITS 16]
group DGROUP _TEXT _DATA _BSS _STACK

extern _main
; ****************************CODE-Segment*********************************
segment _TEXT class=CODE
..start:
main:                mov ax, cs
                     mov ds, ax
                     mov es, ax
                     cli
                     mov ss, ax
                     mov sp, StackEnd
                     sti

                     call _main

.hang:               jmp .hang

; ****************************DATA-Segment*********************************
segment _DATA class=DATA

; ****************************BSS-Segment**********************************
segment _BSS class=BSS

; ****************************STACK-Segment********************************
segment _STACK class=STACK
                     resw 256
StackEnd:
Post Reply