flat assembler
Message board for the users of flat assembler.

flat assembler > DOS > ATN: Dex4u, I'm fairly new to FASM but know basics...

Author
Thread Post new topic Reply to topic
mrblobles



Joined: 05 Apr 2007
Posts: 41
..and I would like to code programs for DexOS can you help me get started?

_________________
pokemon on my iPod = awesome
Post 15 Jun 2007, 21:14
View user's profile Send private message MSN Messenger Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Sure, here's some basic tuts:
http://www.dex4u.com/tuts/tut1
http://www.dex4u.com/tuts/tut2
http://www.dex4u.com/tuts/tut3

Here's a list of functions:
http://www.dex4u.com/tuts/Dex.inc
Note: this is a old list, many more function have bean added.

There also some tuts on here:
http://www.dex4u.com/download.htm
Note: since the above tut was written, the ORG is now " 0x400000" not "0x200000"
Post 16 Jun 2007, 00:28
View user's profile Send private message Reply with quote
mrblobles



Joined: 05 Apr 2007
Posts: 41
thanks very much I'll have a look at this over the next few days, I'm looking for something to devote my summer to as I just finished school and don't go to college untill september
Post 16 Jun 2007, 20:43
View user's profile Send private message MSN Messenger Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Cool, let me know if you have any ?.
Post 16 Jun 2007, 23:10
View user's profile Send private message Reply with quote
roboman



Joined: 03 Dec 2006
Posts: 122
Location: USA
http://home.comcast.net/~dexos/
has a few little demo programs for DexOS
Post 17 Jun 2007, 15:47
View user's profile Send private message Visit poster's website Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1904
Code:
use32                           ; we want 32bit addressing
        ORG   0x400000          ; where our program is loaded to
        jmp   start             ; jump to the start of program.
        db    'DEX1'            ; DexOS checks for this
start:
        mov   ax,18h            ; load ax with the nonlinear data desetor
        mov   ds,ax             ; move it into DS and ES
        mov   es,ax             ; as you can not move it directly.

        mov   edi,Functions     ; this is the interrupt
        mov   al,0              ; we use to load the Dex.inc
        mov   ah,0x0a           ; with the address to DexOS functions.
        int   40h               ; int 40h = to Dos int 21h.
    


Some questions on DexOS:

- Why do you fill DS and ES with $18 ?
- How does the memory model look like ? Flat zero based or not ? Paging is ON or not ?
- What does the AX control in the INT $40 ?
- What is the stack size ? How to change it ?
- What registers are trashed and what are preserved when calling DexOS services ?

Quote:
since the above tut was written, the ORG is now " 0x400000" not "0x200000"


Shocked

Quote:
this is a old list, many more function have bean added


The stuff should get updated ... the manuals and examples Wink

_________________
Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug
Post 17 Jun 2007, 23:39
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Great ? NTOSKRNL_VXE, here some answers:

Q - Why do you fill DS and ES with $18 ?
A - To make addressing identical in real mode and protected mode, we set the base of the code and data descriptors to DS * 16. This number is computed at run-time. We also have a linear descriptors (8h) for writing directly to screen etc.

Q - How does the memory model look like ? Flat zero based or not ? Paging is ON or not ?
A Theres no paging, and it is based on a flat memory model, the basic idea is your are load to 4MB and you are free to use memory from 4MB to top of memory, you can get top of memory by calling a function.
NOTE: This may not be top of real memory, as you can load drivers/modules to top of real memory and then you will have size of real ram, - size of loaded modules, will become top of memory.

Q - What does the AX control in the INT $40 ?
A - As well as a call table, you can call int 40h, with a function number, we tryed to keep them as close to Dos int 21h eg: to print string with int you would mov ah,09h

Q - What is the stack size ? How to change it ?
A - It default to 4096 bytes in size, but you could do something like this if you want a bigger stack
Code:
       ;start of program add this        mov   eax,[return]        mov   [eax],esp        mov   esp,0x800000        ; just before exit do this        mov   eax,[return]        mov   esp,[eax]    


Q- What registers are trashed and what are preserved when calling DexOS services ?
A - All reg are preserved when calling DexOS services, other than the reg that return info.

Quote:

"this is a old list, many more function have bean added"
The stuff should get updated ... the manuals and examples Wink
I agree, but that tut was a old tut, that i did not finish and have not released Wink.
Post 18 Jun 2007, 01:47
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1904
Thanks.

> Great ?

Maybe Shocked

> To make addressing identical in real mode and protected mode, we set the base of the code and data descriptors to DS * 16. This number is computed at run-time.

Inside the kernel and in one low memory 64-KiB segment only ? CS also ? Why doesn't the kernel set them all before starting the app ? Seems NOT to be ZERO based then ... the base is somewhere >0 in low memory ?

> We also have a linear descriptors (8h) for writing directly to screen etc.

Any of them is ZERO based (VGA ram at $A0000, BIOS variables accessible, ...) ?

Any list of them all around ?

> based on a flat memory model, the basic idea is your are load to 4MB and you are free to use memory from 4MB to top of memory, you can get top of memory by calling
> can load drivers/modules to top of real memory and then you will have size of real ram, - size of loaded modules, will become top of memory.

* Kernel: in low memory
* Kernel's buffers: 1+1/16 Mi ... 4 Mi + x
* My application: 4 Mi + x ... "top"
* "top" ... physical top: drivers

Right ^^^ ? And 2 Mi changed to 4 Mi because the kernel became more
memory hoggy (look at Vi$ta for a really memory hoggy thing Laughing ) ?
And DexOS requires 8 MiB RAM at least ?

> you can call int 40h, with a function number, we tryed to keep them as close to Dos int 21h eg: to print string with int you would mov ah,09h

So I can bypass using the table, and AH is the function number, and AL a parameter / reserved for sub-functions ?

> but you could do something like this if you want a bigger stack

Brew a bigger stack anywhere above my app ? So in DexOS I can use memory without allocating, just respecting the "top" ?

_________________
Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug
Post 18 Jun 2007, 06:19
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
NTOSKRNL_VXE wrote:
Thanks.

> Great ?

Maybe :shock:

> To make addressing identical in real mode and protected mode, we set the base of the code and data descriptors to DS * 16. This number is computed at run-time.

Inside the kernel and in one low memory 64-KiB segment only ? CS also ? Why doesn't the kernel set them all before starting the app ? Seems NOT to be ZERO based then ... the base is somewhere >0 in low memory ?

The kernel DOES set them, its just to make sure Wink. Your right its not 0 based, but we set all pointer etc to this nonezero base, so you can think as if it is 0 base ( unless you want to point to vesa ram, VGA ram at $A0000, BIOS variables accessible, ..).
Even App load address is 4MB + base.
Note when you call a function that use any of these"VGA ram at $A0000, BIOS variables accessible," you do not need to switch as the function takes care of it.
Quote:

> We also have a linear descriptors (8h) for writing directly to screen etc.

Any of them is ZERO based (VGA ram at $A0000, BIOS variables accessible, ...) ?

Any list of them all around ?

No but its agood idea, i will make one.
Quote:

> based on a flat memory model, the basic idea is your are load to 4MB and you are free to use memory from 4MB to top of memory, you can get top of memory by calling
> can load drivers/modules to top of real memory and then you will have size of real ram, - size of loaded modules, will become top of memory.

* Kernel: in low memory
* Kernel's buffers: 1+1/16 Mi ... 4 Mi + x
* My application: 4 Mi + x ... "top"
* "top" ... physical top: drivers

Right ^^^ ? And 2 Mi changed to 4 Mi because the kernel became more
memory hoggy (look at Vi$ta for a really memory hoggy thing Laughing ) ?
And DexOS requires 8 MiB RAM at least ?

Not more memory hoggying, but i needed space to put the tcp/ip stack and also space for loading modules that need to be under 15MB.
You still load program to 2MB, if you want, by using "load AppName.dex" at the CLI.
This means its possible to use a PC with 4MB.
Quote:

> you can call int 40h, with a function number, we tryed to keep them as close to Dos int 21h eg: to print string with int you would mov ah,09h

So I can bypass using the table, and AH is the function number, and AL a parameter / reserved for sub-functions ?
Yes.
Quote:

> but you could do something like this if you want a bigger stack

Brew a bigger stack anywhere above my app ? So in DexOS I can use memory without allocating, just respecting the "top" ?
Yes thats right.

So DexOS was never designed to be a desktop OS, but to be simple to code for and give the coder full control.
Post 18 Jun 2007, 18:09
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1904
Quote:
The kernel DOES set them, its just to make sure


Voila Shocked

And SS?=$18=DS also ?

IMHO the kernel should set all to defined values ( crap removed EAX=EBX=ECX=EDX=ESI=EDI=0, ESP=$1000, SS=?).

Quote:
you want to point to vesa ram, VGA ram at $A0000, BIOS variables


That's what I probably want Shocked

Quote:
So DexOS was never designed to be a desktop OS, but to be simple to code for and give the coder full control.


Laughing

_________________
Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug


Last edited by DOS386 on 19 Jun 2007, 23:41; edited 1 time in total
Post 19 Jun 2007, 00:28
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
They are set to CS = 10h (which is same base as DS)
DS, SS, ES, FS = 18h (which is set to realmode ds *16)
GS, = 8h (which is 0 based)
EAX=EBX=ECX=EDX=ESI=EDI=0, on app start, the ESP depends on load address, as "Dos" loads DexOS at differant address than "Bootprog".

Because of the way DexOS is coded, you can use int 10h function or change vidio modes etc, as its easy to go to and from realmode Smile.
Post 19 Jun 2007, 03:59
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1904
Quote:
They are set to CS = 10h (which is same base as DS)


Grrrr Sad Same base, different values ... I have no idea why but already
got many GPF's because of this Sad

Code:
;
; DexOS Hello world // Compile with FASM
;

  format binary ; .DEX
  use32
  org  $400000         ; where our program is loaded to
  jmp  @f              ; jump to the start of program.
  db   'DEX1'
@@:
        mov  esi,tx1     ; this point's to our string.
        mov  ah,9
        int  $40         ; PrintString
        mov  ah,4
        int  $40         ; WaitForKeyPress
        ret

tx1:   db 'Hello world! ',13,0
    


WaitForKeyPress using INT seems not to work Sad

Quote:

DS, SS, ES, FS = 18h (which is set to realmode ds *16)
GS, = 8h (which is 0 based)
EAX=EBX=ECX=EDX=ESI=EDI=0, on app start, the ESP depends on load address, as "Dos" loads DexOS at differant address than "Bootprog"


Code:
;
; DexOS Hello world & register report // Compile with FASM
;

q=$500000

  format binary ; .DEX
  use32
  org  $400000         ; where our program is loaded to
  jmp  @f              ; jump to the start of program.
  db   'DEX1'
@@:
        pushfd         ; EFLAGS
        push eax       ; EAX
        call @f        ; EIP
@@:     mov eax,esp
        sub eax,8
        push eax       ; ESP
        push ebx       ; EBX
        push ecx       ; ECX
        push edx       ; EDX
        push esi       ; ESI
        push edi       ; EDI
        push ebp       ; EBP
        xor eax,eax
        mov ax,ss
        push eax       ; SS
        mov ax,cs
        push eax       ; CS
        mov ax,ds
        push eax       ; DS
        mov ax,es
        push eax       ; ES
        mov ax,fs
        push eax       ; FS
        mov ax,gs
        push eax       ; GS

        mov ax,$0A00
        mov edi,q
        int $40           ; Load table

        mov   esi,tx1           ; this point's to our string.
        call dword [q+36]       ; PrintString

        xor ecx,ecx
@@:     mov al,[tx2+ecx*4]
        call dword [q+44]       ; PrintCharCursor
        mov al,[tx2+1+ecx*4]
        call dword [q+44]       ; PrintCharCursor
        mov al,[tx2+2+ecx*4]
        call dword [q+44]       ; PrintCharCursor
        mov al,[tx2+3+ecx*4]
        call dword [q+44]       ; PrintCharCursor
        mov al,32
        call dword [q+44]       ; PrintCharCursor
        pop eax
        call dword [q+52]       ; WriteHex32
        mov  esi,tx3            ; EOL
        call dword [q+36]       ; PrintString

        inc cl
        cmp cl,16
        jnz @b

        mov   esi,tx4           ; this point's to our string.
        call dword [q+36]       ; PrintString

        call dword [q+16]       ; WaitForKeyPress

        mov   esi,tx5           ; this point's to our string.
        call dword [q+36]       ; PrintString

;       ud2
        ret

tx1:   db 'Hello world! Look at it:',13,0
tx2:   db 'GS  FS  ES  DS  CS  SS  EBP EDI ESI EDX ECX EBX ESP EIP EAX EFLG'
tx3:   db 13,0
tx4:   db 'Press any key',13,0
tx5:   db 'Exiting',13,0
    


Well, WaitForKeyPress seems to work now ... using the " table" Rolling Eyes

Results:

- DS and ES are correctly set Smile
- GS=$18, not 8 Shocked
- EBP,ESI,EDI are not zeroized Shocked
- ud2 does not work - does DexOS provide a crash handling at all ? Question
- Is the stack in low memory even below the kernel, at relative address 0 ? Question
- PrintCharCursor fails to EOL Confused

Issues:

- DexOS has startup problems (not even verify that CPU is in RM ?)
- Very lacking file I/O: HD support only first primary partition FAT32, read only, no FAT16, no writing, forget about other partitions, boots from FAT16 only, but then can access FAT32 only ? One can't use it like this Crying or Very sad
- Tries to load GUI from floppy and CLI defaults to floppy even if started from HD
- Hard freezer always if no disk in the floppy drive
- Included FASM is obsolete (and one can't use it anyway since you can't save the output file)
- DEX.INC is buggy and incomplete, starting from typos ( CompearString ), 62.Count clock ticks - how to use it at all ? , What is function 10 ($0A) - load table or "PrintChar" ? Last but not least calling the functions with INT seems to be a bad idea for those using EAX as input - if you need AH for the function number Exclamation

I also had a look at the "can program in C" feature - attempts to target to DexOS, hosted still on Win32 Crying or Very sad , header and startup code generated using inline ASM in GAS Sad syntax , the "library" is inexistent - you can't compile anything useful with it, it's equivalent to usage of any other C compiler and reusing it's ASM output, or extracting the flat binary from the OBJ file Wink

Quote:
DexOS was never designed to be a desktop OS


I don't need a "DeskOS" , especially if "features" like dancing AERO "windows" are a must for such an "OS" Laughing ... but the file I/O is a must for a DOS like OS Rolling Eyes

Well ... very promising but still very much to do ... Rolling Eyes

_________________
Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug
Post 20 Jun 2007, 00:30
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
I will try and answer your issues, here goes :

1. DexOS CS is set to "; (10h) Code segment, read/execute, nonconforming"
DS,ES,FS, is set to "(18h) Data segment, read/write, expand down"

2. Waitkey using int is :
Code:
mov al,0mov ah,2int 40h    


3. The kernel32 avalable on the site is set to DS, ES, GS, FS, SS, = 18h, thats right, but i have decided to set GS = 8h for the next release and that why i said GS = 8h. esp, esi, edi are not 0.
UD2 should give you the letter i in the top right hand corner and does on my tests.
There is error handling as it print a letter in right hand corner, but its not recoverable, also i dump reg etc on error to com port, but this is only available with a dev kernel.

Quote:
- DexOS has startup problems (not even verify that CPU is in RM ?)
I am not sure i know what you mean, do you mean it does not print info at start ?

4. DexOS Reads/writes to a fat16 hdd and reads fat32 hdd, i do not know why you say it can not reads/writes to fat16, as it can, but only the first partion.
As for booting from hdd and still trying to read floppy yes, this is a problem, for now you need to do this
c: <enter>
and it should be OK.
And thanks NTOSKRNL_VXE for taking the time to test everthing Smile.

PS: If you have a fat16 first partion hdd and you can not read/write to with DexOS, let me know,
As you should beable to as long as you load the ide from the hdd, as i have not add change drive in IDE yet, but i will.
Post 20 Jun 2007, 01:40
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1904
See also: http://board.flatassembler.net/topic.php?t=6328

Quote:

2. Waitkey using int is :
Code:
mov al,0
mov ah,2
int 40h
    



Yeah ... NOT the same AH value as index in table Shocked

Any list of supported INT accesses around ?

Quote:
4. DexOS Reads/writes to a fat16 hdd and reads fat32 hdd, i do not know why you say it can not reads/writes to fat16, as it can, but only the first partion.


You wrote 1/2 year ago:

Quote:

As for not reading Hdd maybe your Hdd is fat16 ?, as fat32 only in that


Suggesting only FAT32 would be supported Confused

And I had FAT16 some time ago and did not work ... and I did not insist since you wrote it is unsupported ... but now I have FAT32 only Sad

Code:
        use32
        ORG    0x400000                             
        jmp    start                                
        db     'DEX1'                                
start:
        mov     esi,hello
        mov     ah,9
        int     40h

        mov     ah,02h
        int     40h

hello db 'Hello from protected mode!',0Dh,0Ah,0
    


Using INT $40/AH=2 as Exit ? Or missing RET / RAT ? Laughing

_________________
Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug
Post 20 Jun 2007, 22:19
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
There should be a "ret" at the end typo error, as for int function numbers, they are not the same, but i could easy link them to the table, which is a good idea, i will add that, thanks.
But theres net may int supported as we voted not to use int's but call-table.

And now it has support for fat16 read/write and fat32 read.
Post 21 Jun 2007, 13:08
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-2019, Tomasz Grysztar.

Powered by rwasa.