MZ EXE Skeleton Made By hand
MZ EXE Skeleton Made By hand
I have the sample of an EXE file with code, data and a stack. I built it fully by hand and set up its stack in the program's code, also by hand.
They all (data and stack variables) are referenced relative to the position after the paragraphs of the MZ header.
I have included the file SAVEMEG.DAT to show the exact position and layout in memory of the EXE when loaded into memory. We just need to find the string "This is a command line to find the start and the end of" to find the sample command line of this program and its PSP as a result.
We can see that the EXE loader just interprets the EXE header, removes it from the image to load (normally 32 bytes long). After removing it, it generates a 256-byte PSP at the start of a segment and then loads the rest of the EXE as indicated by the size of the EXE in the MZ header as if it was a COM file but that can be more than 64K in size.
Obviously each compiler will have its own techniques to be able to use code and data among several segments, with a structure and techniques very similar to those used for being able to call and reference BIOS code and data.
But since this EXE is made fully by hand (without compilers or linkers involved), we will have to develop and maintain our own techniques to achieve the same.
We could have also created a COM file loader, then just have loaded a COM file greater than 64K. With that, we would have loaded a big COM file that supplies the vast majority of needs of a regular EXE file.
With this skeleton we can now start to learn bit by bit more practical things, like loading and executing VxD drivers all by ourselves.
However, I need to investigate and document how to implement and use relocations, which will surely be aboundantly used in VxDs.
Also, it will help to better understand LE (used by VxDs) and NE EXEs (used by Win16).
With that, along with the information about building and implementing GUIs, we could start making simple 16-bit programs that contain WinAPI functions implemented by us and now treat the WinAPI as yet another library ported natively to DOS and then to our own OSes.
Main source code:
http://archive.org/download/tmp_tests/M ... avemeg.asm
Full source code:
http://archive.org/download/tmp_tests/M ... AVEMEG.zip
Sample memory disposition of the EXE in memory (it starts with the 256-byte PSP at physical offset 0x1920):
http://archive.org/download/tmp_tests/M ... AVEMEG.DAT
They all (data and stack variables) are referenced relative to the position after the paragraphs of the MZ header.
I have included the file SAVEMEG.DAT to show the exact position and layout in memory of the EXE when loaded into memory. We just need to find the string "This is a command line to find the start and the end of" to find the sample command line of this program and its PSP as a result.
We can see that the EXE loader just interprets the EXE header, removes it from the image to load (normally 32 bytes long). After removing it, it generates a 256-byte PSP at the start of a segment and then loads the rest of the EXE as indicated by the size of the EXE in the MZ header as if it was a COM file but that can be more than 64K in size.
Obviously each compiler will have its own techniques to be able to use code and data among several segments, with a structure and techniques very similar to those used for being able to call and reference BIOS code and data.
But since this EXE is made fully by hand (without compilers or linkers involved), we will have to develop and maintain our own techniques to achieve the same.
We could have also created a COM file loader, then just have loaded a COM file greater than 64K. With that, we would have loaded a big COM file that supplies the vast majority of needs of a regular EXE file.
With this skeleton we can now start to learn bit by bit more practical things, like loading and executing VxD drivers all by ourselves.
However, I need to investigate and document how to implement and use relocations, which will surely be aboundantly used in VxDs.
Also, it will help to better understand LE (used by VxDs) and NE EXEs (used by Win16).
With that, along with the information about building and implementing GUIs, we could start making simple 16-bit programs that contain WinAPI functions implemented by us and now treat the WinAPI as yet another library ported natively to DOS and then to our own OSes.
Main source code:
http://archive.org/download/tmp_tests/M ... avemeg.asm
Full source code:
http://archive.org/download/tmp_tests/M ... AVEMEG.zip
Sample memory disposition of the EXE in memory (it starts with the 256-byte PSP at physical offset 0x1920):
http://archive.org/download/tmp_tests/M ... AVEMEG.DAT
Last edited by ~ on Tue Aug 30, 2016 3:00 pm, edited 4 times in total.
YouTube:
http://youtube.com/@AltComp126
My x86 emulator/kernel project and software tools/documentation:
http://master.dl.sourceforge.net/projec ... 7z?viasf=1
http://youtube.com/@AltComp126
My x86 emulator/kernel project and software tools/documentation:
http://master.dl.sourceforge.net/projec ... 7z?viasf=1
- BrightLight
- Member
- Posts: 901
- Joined: Sat Dec 27, 2014 9:11 am
- Location: Maadi, Cairo, Egypt
- Contact:
Re: MZ EXE Skeleton Made By hand
I have added you to my "foes" list.
I really think the mods should do something about your posts. I'd like a decent explanation for their quietness until now. This is not a DOS programming forum. If you know so much on MZ, then maybe write something on the MZ Wiki entry, but not here.
I really think the mods should do something about your posts. I'd like a decent explanation for their quietness until now. This is not a DOS programming forum. If you know so much on MZ, then maybe write something on the MZ Wiki entry, but not here.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
Re: MZ EXE Skeleton Made By hand
I know relatively little.
But I need to study and publish this information in a much clearer way, by examples.
After fully developing this basic level, I will try to advance a simple step towards using VxD drivers in my own OS and GUI.
This is not a DOS-exclusive forum but that is a valid OS which can be ported to 32 and 64 bits, and also invoke those modes and return from them, for example, to start and finish loading a custom OS.
It's temporary code, it is better referenced on the spot.
I guess that if I was to implement a full DOS system, it would receive criticism all the same by several people, but I really need to work at that level because it matches perfectly what I know and what I need to explain in the way I better can.
But I need to study and publish this information in a much clearer way, by examples.
After fully developing this basic level, I will try to advance a simple step towards using VxD drivers in my own OS and GUI.
This is not a DOS-exclusive forum but that is a valid OS which can be ported to 32 and 64 bits, and also invoke those modes and return from them, for example, to start and finish loading a custom OS.
It's temporary code, it is better referenced on the spot.
I guess that if I was to implement a full DOS system, it would receive criticism all the same by several people, but I really need to work at that level because it matches perfectly what I know and what I need to explain in the way I better can.
YouTube:
http://youtube.com/@AltComp126
My x86 emulator/kernel project and software tools/documentation:
http://master.dl.sourceforge.net/projec ... 7z?viasf=1
http://youtube.com/@AltComp126
My x86 emulator/kernel project and software tools/documentation:
http://master.dl.sourceforge.net/projec ... 7z?viasf=1
- BrightLight
- Member
- Posts: 901
- Joined: Sat Dec 27, 2014 9:11 am
- Location: Maadi, Cairo, Egypt
- Contact:
Re: MZ EXE Skeleton Made By hand
The only OS which supports MZ executables is DOS. Windows and Linux support them through emulation, and even 64-bit Windows doesn't support them due to the absence of virtual 8086 mode.
Oh, and about LE and NE executables, both are just as deprecated as DOS is. Maybe you could document on PE instead; that would be more useful for this forum/wiki.
What does this even mean? An MZ executable is not an OS, and cannot be ported to 32-bit or 64-bits. PE32 and PE64 files have an MZ header, but that doesn't make them MZ executables. The MZ program just prints "This program cannot be run in DOS mode." or a similar message.~ wrote:This is not a DOS-exclusive forum but that is a valid OS which can be ported to 32 and 64 bits
Oh, and about LE and NE executables, both are just as deprecated as DOS is. Maybe you could document on PE instead; that would be more useful for this forum/wiki.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
Re: MZ EXE Skeleton Made By hand
Probably, DOS-excluding was meant.omarrx024 wrote:What does this even mean?~ wrote:This is not a DOS-exclusive forum but that is a valid OS which can be ported to 32 and 64 bits
Re: MZ EXE Skeleton Made By hand
I must say, this (creation of various DOS/Windows/Linux/whatever executables manually) has been done before and examples can be found online. It may be a good exercise for you, but I seriously doubt that the rest of the forum users are interested in this code of yours or in making DOS MZ EXEs by hand. Or in trying to resurrect and reuse bits of Windows 9x.
-
- Member
- Posts: 1146
- Joined: Sat Mar 01, 2014 2:59 pm
Re: MZ EXE Skeleton Made By hand
Stop using archive.org as a file sharing platform.~ wrote:Main source code:
http://archive.org/download/tmp_tests/M ... avemeg.asm
Full source code:
http://archive.org/download/tmp_tests/M ... AVEMEG.zip
Sample memory disposition of the EXE in memory:
http://archive.org/download/tmp_tests/M ... AVEMEG.DAT
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.
Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
Re: MZ EXE Skeleton Made By hand
Hi,
Also note that what people consider an OS has changed in the last several decades; and MS-DOS no longer really qualifies as an OS (if it ever did). If you compare MS-DOS to UEFI you'll find that UEFI is more like an OS than MS-DOS ever was, but nobody thinks UEFI firmware is an OS. In today's world, you'd have to downgrade DOS to "about 10% of an OS".
Cheers,
Brendan
The "OS Development" sub-forum (and the entire OSdev forums in general) are specifically for people creating new operating systems. It is not for people creating applications for any existing OS (Windows, Linux, FreeDOS, MS-DOS, etc).~ wrote:This is not a DOS-exclusive forum but that is a valid OS which can be ported to 32 and 64 bits, and also invoke those modes and return from them, for example, to start and finish loading a custom OS.
Also note that what people consider an OS has changed in the last several decades; and MS-DOS no longer really qualifies as an OS (if it ever did). If you compare MS-DOS to UEFI you'll find that UEFI is more like an OS than MS-DOS ever was, but nobody thinks UEFI firmware is an OS. In today's world, you'd have to downgrade DOS to "about 10% of an OS".
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
-
- Member
- Posts: 501
- Joined: Wed Jun 17, 2015 9:40 am
- Libera.chat IRC: glauxosdever
- Location: Athens, Greece
Re: MZ EXE Skeleton Made By hand
Hi,
Regards,
glauxosdever
I second that.omarrx024 wrote:I really think the mods should do something about your posts. I'd like a decent explanation for their quietness until now.
Please, don't encourage him to use the wiki. He will spam it with, well, spam.omarrx024 wrote:If you know so much on MZ, then maybe write something on the MZ Wiki entry, but not here.
Regards,
glauxosdever
- Kazinsal
- Member
- Posts: 559
- Joined: Wed Jul 13, 2011 7:38 pm
- Libera.chat IRC: Kazinsal
- Location: Vancouver
- Contact:
Re: MZ EXE Skeleton Made By hand
Of the list of 16 moderators on this forum, only three of them actively visit. One other one is in the IRC frequently. The rest haven't been around in years, or show up once in a blue moon to post and then disappear again.omarrx024 wrote:I really think the mods should do something about your posts. I'd like a decent explanation for their quietness until now.
Re: MZ EXE Skeleton Made By hand
The simple answer is to put the guy on your Foes list and stop replying to his posts, rather than feeding him. That way you need never know that they exist.glauxosdever wrote:Hi,
I second that.omarrx024 wrote:I really think the mods should do something about your posts. I'd like a decent explanation for their quietness until now.
Please, don't encourage him to use the wiki. He will spam it with, well, spam.omarrx024 wrote:If you know so much on MZ, then maybe write something on the MZ Wiki entry, but not here.
Regards,
glauxosdever
Re: MZ EXE Skeleton Made By hand
I think it's not a complete answer. I did that, but I still see him in "View unread posts". I can also see his posts in the forum index and the forums themselves. Why can't Brendan or Combuster just ban him? Aren't we all sure he is not appropriate for this forum and only spreads unrelated garbage?
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
- Alan Kay
Re: MZ EXE Skeleton Made By hand
Why are you guys so mad about him using that website???onlyonemac wrote:Stop using archive.org as a file sharing platform.~ wrote:Main source code:
http://archive.org/download/tmp_tests/M ... avemeg.asm
Full source code:
http://archive.org/download/tmp_tests/M ... AVEMEG.zip
Sample memory disposition of the EXE in memory:
http://archive.org/download/tmp_tests/M ... AVEMEG.DAT
When I type archive.org and press enter I go to a site called "way back machine"? What is going on?
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
-
- Member
- Posts: 1146
- Joined: Sat Mar 01, 2014 2:59 pm
Re: MZ EXE Skeleton Made By hand
archive.org is a project aimed at preserving digital artefacts for historical reasons, much like a traditional archive or museum preserves physical artefacts. The Wayback Machine part of the site archives (read: preserves) old versions of websites. They also archive other forms of historically-significant (or likely to be historically-significant in the future) digital media, such as e-books/digital texts, music/internet radio/podcasts and software. ~ is using the site as a cloud storage and file-sharing site, specifically to store his code in a place that he can find it easily and to link to it from this forum.octacone wrote:Why are you guys so mad about him using that website???
When I type archive.org and press enter I go to a site called "way back machine"? What is going on?
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.
Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
Re: MZ EXE Skeleton Made By hand
+1. ~ shall not be given premission to upload that or I'm going to report him in archive.org, if he adds any other random DOS executable posted on this forum.onlyonemac wrote:archive.org is a project aimed at preserving digital artefacts for historical reasons, much like a traditional archive or museum preserves physical artefacts. The Wayback Machine part of the site archives (read: preserves) old versions of websites. They also archive other forms of historically-significant (or likely to be historically-significant in the future) digital media, such as e-books/digital texts, music/internet radio/podcasts and software. ~ is using the site as a cloud storage and file-sharing site, specifically to store his code in a place that he can find it easily and to link to it from this forum.octacone wrote:Why are you guys so mad about him using that website???
When I type archive.org and press enter I go to a site called "way back machine"? What is going on?