After talks with X-calibre about me bbeing able to do a better windows like OS in 32bitasm i have restarted working to my OS. I now have a working version with:
-boot,
-16 bit vesa lfb/pitch detection,
-init 32 bits pmode either gfx or text mode (for debug), setup interupts for timer, keyboard, com/serial mouse, setup ps2 mouse, mouse driver and a blue screen with a mouse pointer on it.

Before i start makeing window/task manager... i have some problems mixing 16 bit code with 32 bit one. I use TASM but i guess MASM is the same here.

i have defined separated segments for boot,init16 and system32 code and a group with all those segments. Now i can not use the extended call syntax (aka invoke) in the 32 bits segment because assembler puts an ENTERW instruction instead of ENTERD at the start of a procedure with parameters...?

I guess assembler belives the group is 16 bits because i have some 16 bits segments inside the big kernel group...

If i place a .MODEL FLAT STDCALL at the starts Calls/invoke works allright...but i can not accest 16 bits data from 32 bits segments :(

As a corolar how do i set a default language calling conventions like STDCALL without using a .MODEL FLAT directive?

Any TASM/MASM boot=>16 bits=>32bits OS startup code tutorials on the net? (allmost all use NASM today... :( )

Any ideeas? non NASM please because i want to use STDCALL and structures in MASM/TASM style not in the NASM style (my personal taste)

Thx
Posted on 2002-01-26 11:48:39 by BogdanOntanu

As a corolar how do i set a default language calling conventions like STDCALL without using a .MODEL FLAT directive?
OPTION LANGUAGE:STDCALL
Posted on 2002-01-26 12:26:36 by bitRAKE
thx bitrake, i just wonder if that works with TASM also...

besides i have found a TASM related bug description on Elicz home page that describes onw of the problem i have: ENTERW instead of ENTERD in a 32 bit segment :( i wonder if there is a workaround?

if i used .Model FLAT,STDCALL it generated corect ENTERD in the PROC Prologue...but other errors come in, like: unable to acces data with current assumed segments ... argh...
i wonder what exactly does .MODEL FLAT do? and how can i emulate with SEGMENTS and GROUPS?

or how to acces my 16 bit data in a USE16 segment if i place a .Model FLAT at code start ?
Posted on 2002-01-26 13:46:01 by BogdanOntanu
	_TEXT	SEGMENT READONLY PUBLIC FLAT 'CODE'

_TEXT ENDS
CONST SEGMENT READONLY PUBLIC FLAT 'CONST'
CONST ENDS
_DATA SEGMENT PUBLIC FLAT 'DATA'
_DATA ENDS
_BSS SEGMENT PUBLIC FLAT 'BSS'
_BSS ENDS
If you don't use .MODEL then the segments have to be setup correctly not to break anything. There is much good info in the MASM manual, but I do not believe these things would be compatible with TASM.

From Appendix E:


Flat Model
Name Align Combine Class Group
.CODE _TEXT DWORD PUBLIC 'CODE'
.FARDATA _DATA DWORD PUBLIC 'DATA'
.FARDATA? _BSS DWORD PUBLIC 'BSS'
.DATA _DATA DWORD PUBLIC 'DATA'
.CONST CONST DWORD PUBLIC 'CONST'
.DATA? _BSS DWORD PUBLIC 'BSS'
.STACK STACK DWORD PUBLIC 'STACK'
Posted on 2002-01-26 14:11:12 by bitRAKE
Bogdan, why not keep 16 and 32bit code separate? Do the 16bit
initialization (shouldn't be too much) in nasm or whatever, since nasm
is very well suited for bootsector and similar "messy" stuff. Write
all the 32bit code in masm/tasm.
Posted on 2002-01-28 10:01:42 by f0dder
That is my latest solution to my problems: i use separated modules for: boot, init_code16bits, init_code32_bits

and link them at abbsolute address with John Fine's JLOC ....

i looks the wrong protocol (ENTERW instead of ENTERD) is still there after all but i have found a workarround because now i can have modules without .model flat,stdcall directive and modules with it:

in the 32 bit code module i have a skeleton like this:



.MODEL FLAT,STDCALL

code32 SEGMENT PRIVATE USE32
code32 ENDS

and in the code part :

code32 SEGMENT
assume cs:code32,ds:code32,es:code32,ss:code32
( ...... enter system code here...... )
ENDS

end


this layout will work okIF you prefix ALL OFFSETS like this:
OFFSET code32:my_variable . Also direct variable references like: mov eax, work with no prefix and PROC's now generate the right prologue code :)

JLOC control file for linking:


ALL:
SYSTEM32.obj
SYS32: 0,8E00,0
*,*,CODE,code32,system32.obj

*

assuming my 32 bit part of the OS is loaded at 00008E00h
and named system32.asm

Separated parts for boot,16bit initialization code and 32 bit system code looks logical but is a little painfull at the start.

Transfering data from the 16 bit system detection part (like VESA version, LFB and pitch) to the 32 bits code is done by abbsolute data (I place it at 0600h) but after all you will not change the boot/16bits part so much after a time. The big action is going to be in the 32bits part anyway.

maybe others will have the same problems and is good to know...
Posted on 2002-01-28 14:16:55 by BogdanOntanu