flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
sid123 01 Apr 2014, 06:54
Hello,
I am in process of porting FASM to a non-conventional operating system. The operating system supports directories and files through FAT16 file system, it gives the program access to all possible memory (runs in ring0) so there is no such memory allocation, there is no concept of file handle, loading and writing files is done through direct file names, arguments returned are null-terminated and are passed in ESI, (there is no need for the program to grab it from ESI, the application library will setup the stack and save the arguments for you). I have managed to "run" FASM (by simply filling the display_char function, the rest are all stubs). To give an overview of syscalls: Quote:
My questions here: 1. Would it be possible to port FASM to such a system? I think many of the functions rely on file handles, the system doesn't have a concept of file handles at all. 2. If yes what changes would be needed in the internal FASM routines? _________________ "Those who can make you believe in absurdities can make you commit atrocities" -- Voltaire https://github.com/Benderx2/R3X XD |
|||
![]() |
|
DOS386 01 Apr 2014, 07:52
> I am in process of porting FASM to a non-conventional operating system.
DexOS ??? > Problem #2: Not provided. I am not a POSIX expert so > I don't know what lseek is supposed to do RTFRBIL: http://www.ctyme.com/intr/rb-2799.htm it had been around since M$-DOG 2.0 ![]() > 1. Would it be possible to port FASM to such a system? YES > I think many of the functions rely on file handles YES > the system doesn't have a concept of file handles at all. bad > 2. If yes what changes would be needed in the internal FASM routines? Load your complete file into memory at OPEN, then send data on "fileread" and "lseek" in memory Better idea: implement a proper file I/O system, as-is your OS is inferior to bad old M$-DOG 2.0 (now "open source" ...) ![]() |
|||
![]() |
|
sid123 02 Apr 2014, 09:54
Hi guys!
Okay I have managed to teach the kernel about File Handles ![]() It's a large table (for now) which contains smaller entries call file handles. Each Handle is given a number which is what is returned when fopen is called. read() has also been implemented, however remember that the bytes to read will be rounded off to the next cluster (provided that it doesn't exceed the limit, kernel will take care of it) Would this be problematic? One solution could be loading by rounding off to next cluster into memory and then clearing the "extra" crap. Basically if FASM requests to read say 4000 bytes, and sectors per cluster is 2048, then it would be rounded off to 4096, and therefore exactly 2 clusters will be read. I'm planning to read the clusters into memory and then clear the 96 extra bytes, this can be problematic as it may destroy code or data which may be in the "extra" 96 bytes. I'm not sure about lseek my file handle contains a "last known memory location" attribute, and lseek works by taking the last known memory location as the location of the file. And another solution as DOS386 mentioned would be loading an entire file into memory, and copying it on read(). This wastes memory, plus what if a nasty programmer tries to load say a file larger than a Gigabyte? Although source code files aren't larger than a megabyte, so... yeah ![]() Any suggestions? |
|||
![]() |
|
revolution 02 Apr 2014, 10:11
sid123 wrote: Any suggestions? |
|||
![]() |
|
alexfru 02 Apr 2014, 10:12
[lf]seek() simply says that the next file read/write will occur at the provided location in file. Works just like a pointer/address. The read/write will automatically advance that "pointer" by the amount read/written.
If you take the perverted path of padding files to sector/cluster/block sizes, spaces or ends of lines are probably the best throw-away input for an assembler/compiler. |
|||
![]() |
|
JohnFound 02 Apr 2014, 11:19
KolibriOS does not support file access by handles, but FreshLib needs standard file access.
You can see how this file access is implemented in the corresponding library source file. |
|||
![]() |
|
neville 02 Apr 2014, 19:49
You might find looking at my fasm port to FAMOS to be useful for you. As a first step I created a "Memory-Only" DOS version of fasm which involved amending SYSTEM.INC and other modules. Full source code is included. See http://board.flatassembler.net/topic.php?t=9197
_________________ FAMOS - the first memory operating system |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.