flat assembler
Message board for the users of flat assembler.
Index
> Main > about compileing from source |
Author |
|
zbenjudah 11 Aug 2004, 23:02
Hi
I am a newbe doobie and this is probably a really crazzy weird idea but anyway what I would like to be able to do is, to compile the compiler without the compiler. Is it possable to get fasm to compile itself without the aid of an os say like an empty harddrive with just the dos prompt or rather just the boot files command.com msdos.sys io.sys....... I know that sounds rediculouse and why would anyone want to do that but I am a minimalist and thats how I like to run my computer start with it empy and reinvent the wheel it is an interesting challange anyway............ if anyone could give me an email with that info it would be great thanks xzbenjudahx@aol.com |
|||
11 Aug 2004, 23:02 |
|
pelaillo 11 Aug 2004, 23:30
You will need however a compiled compiler otherwise the source is simply an ascii text file.
To have bare-bones fasm without any other OS is a possible thing. Or in other words, having a small tiny OS embeded in fasm sources. It could be done with a little bootloader plus a routine to access memory, a routine to handle the source (stored in some way) and some means to store the output. Latter two end up to resemble a filesystem. MenuetOS started that way and it is still adding capabilities. |
|||
11 Aug 2004, 23:30 |
|
zbenjudah 12 Aug 2004, 17:33
well I was just curious about this becouse I have always wonderd how you get a compiler before you ever had a compiler kinda like wich came first the chicken or the egg. But it would or could always com in handy to know how to do such a thing if you ever found yourself in a servival situation and needed to create a file system from scratch in an empty computer
|
|||
12 Aug 2004, 17:33 |
|
pelaillo 12 Aug 2004, 18:10
Furtunately we have the answer for this problem. Chicken or egg is still to be solved.
The first assembler must be written directly as machine instructions and then it must be able to process a source file with a set of rules in order to produce machine instructions. The very first version of fasm was assembled by another assembler until it reaches the self-compiling ability. (and what a nice ability life ) |
|||
12 Aug 2004, 18:10 |
|
fasm9 12 Aug 2004, 23:08
Having say that, everything is already there, but, we don't know how to reach there.
-- http://lambda-the-ultimate.org/node/view/173 |
|||
12 Aug 2004, 23:08 |
|
zbenjudah 13 Aug 2004, 00:47
hey thanks fasm9
I am hearing a lot of talk but no real answers.whats he big secret just a few bits a code just asking for a leg up is all |
|||
13 Aug 2004, 00:47 |
|
crc 13 Aug 2004, 11:06
There is an article, and source code, showing how a simple compiler can be bootstrapped from almost nothing. It starts with a small sublanguage implemented by hand in hex, and builds up to a simple structured language. See http://www.rano.org/bcompiler.html for the article and http://www.rano.org/bcompiler.tar.gz for the source code.
|
|||
13 Aug 2004, 11:06 |
|
i-don 15 Aug 2004, 21:08
zbenjudah,
I just did it soon after reading this topic. But before you start, you need to download fasm 1.54 DOS version, pkunzip v2.4 for DOS and a copy of edit.com or any 16bit text editor. Since, I don't have any extra spare PC, I boot up from safe-mode command prompt. It mean, no environment setting, no extended memory and nothing running in the memory. 1. Copying files Once you got the 'blank' pc boot-up, copy pkunzip, fasm154.zip and edit.com into it harddisk. Then unpack fasm with recursive directory into your choice of directory name for fasm. In this case I assumed c:\fasm. For who un-familiar of DOS command how to create directory and copy from files from diskette, here in the commands: Code: mkdir fasm <ENTER> Then go inside the directory with CD command: Code: cd\fasm <ENTER> Then, we need to copy fasm154.zip,pkunzip.exe and edit.com from diskette to harddisk. Let say we place edit.com and pkunzip.exe into root harddisk and fasm154.zip into fasm directory. By assuming you still in fasm directory. Your prompt will look like this (C:\fasm>), here we go: Code: copy a:\edit.* c:\ <ENTER> copy a:\pkunzip.* c:\ <ENTER> copy a:\fasm154.zip <ENTER> 2. Unpacking fasm Now we need to unpack fasm to c:\fasm which you're already in it. We need to unpack with the directory structure stored in zip file still intact. SO, here we go: Code: ..\pkunzip -d fasm154.zip <ENTER> All the fasm files will be extracted. To confirm there is sub-directory is also being extracted, we use dir command: Code: dir/w <ENTER> your screen will looks something like this: Code: Microsoft(R) Windows TX-No-horn (C)Copyright Microsoft Corp 1981-2006. C:\fasm>dir/w Volume in drive C is FREEZING Volume Serial Number is WHOC-ARE1 Directory of C:\fasm [.] [..] FASM.EXE FASM.TXT LICENSE.TXT WHATSNEW.TXT [SOURCE] [EXAMPLES] 5 file(s) 224,923 bytes 4 dir(s) A lots a GB free C:\fasm> 3. Re-compiling FASM Now, we try to re-compile FASM from the source. Since, the source directory and files are there, let go to main fasm source file: Code: cd source\dos <ENTER> There is 3 files in this directory. Fasm.asm, modes.inc and System.inc. So, we're ready to compile. Here we go: Code: ..\..\fasm fasm.asm <ENTER> Soon after, if there are no problems, you'll get fasm.exe created in this directory. 4. Testing the new compiled FASM Now, we need to test it. We'll use one of the example file. I choose EXEDEMO in EXAMPLES directory. We go there first: Code: cd..\..\examples\exedemo <ENTER> And we need to backup the binary that comes with the package: Code: ren exedemo.exe exedemo.bak <ENTER> Let compile exedemo.asm using the new compiled fasm program: Code: ..\..\source\dos\fasm exedemo.asm <ENTER> A new exedemo.exe will be compiled and you could run it to test for valid executable format. You'll be able to see Hello world! string on your screen if nothing wierd happened during compile. From here, you could continue your quest create your own assembly source code for fasm using edit.com or any DOS edit you preferred. I guess, thats it. Hopefully this info would be usefull to anyone who need it. |
|||
15 Aug 2004, 21:08 |
|
crc 16 Aug 2004, 01:41
i-don: What you showed will work to recompile fasm, but that's not what zbenjudah asked about. He said:
Quote: Is it possable to get fasm to compile itself without the aid of an os say like an empty harddrive with just the dos prompt or rather just the boot files command.com msdos.sys io.sys....... You can't compile FASM itself without an OS and some basic tools. You can slowly bootstrap a new OS & language from an existing OS as shown in the example. I doubt that there is any way to bootstrap an x86 from a switch panel |
|||
16 Aug 2004, 01:41 |
|
zbenjudah 16 Aug 2004, 04:40
i don
that is very noble aproach that you have and i commend you for that. Only not what I was asking what if you did not have fasm or any compiler or assembler what would you do. Personally I think that it can be done just have to find out how |
|||
16 Aug 2004, 04:40 |
|
crc 16 Aug 2004, 04:48
Quote: Only not what I was asking what if you did not have fasm or any compiler or assembler what would you do. Personally I think that it can be done just have to find out how 1) Translate the assembly into machine code 2) ALT+keypad to enter them 3) Redirect them into a .COM file 4) Build off of the .COM file Seriously, on anything other than a simple hobby development board, you won't get very far with today's computers. If you had a new computer with no software, you'd cross-compile for the new target, but that's still not what you want. On an x86 PC, you aren't going to be able to build an OS or compiler without additional software. |
|||
16 Aug 2004, 04:48 |
|
i-don 16 Aug 2004, 06:37
You mean you want to build fasm straight from machine code? he.he.he..
That was not "fasm compile itself" as I understand it. But, creating an assembler or compiler from OS boot environment without tools. Am I correct? You need at at least debug.com program. event alt+key can't do. it came into a problem when you reach ascii character 013 or 009 or similar, the 'file' getting mess-up already (copy con fasm.exe?). But then, you already have an assembler if you using debug.com program. In old days programmers create a compiler using a punch card or something like that. That was not OS dependent. In some cases, it depend on the OS itself. With MS-DOS System boot only, it will restrict you from making a new binary file except batch file, which is a text file to be interpreted by the OS. The idea of making assembler/compiler is begin with idea and methods to write it. Then assembler/compiler exist as collective shortcut/rules from the methods they do with a hard way previously. But in DOS, there is no method to write a binary efficiently except using another tools. Probably on other OS there is a way to do key sequence and toggle some switches on the pc hardware that is to translate your input into 'un-execute' binary contents. In DOS, if use Alt+Key it will execute it instantly. So you didn't have a control to it before completing writing and save a binary file. just my 2 cents. ps - There always a genius guy who will be able to do that with the mysterious way than usual. Just wait for this guy to surface. |
|||
16 Aug 2004, 06:37 |
|
zbenjudah 16 Aug 2004, 19:49
well maybe I do need to re-think this then........ tell what machine would one use other than a pc for doing this type of thing alpha machines or main frames of some sort...... and if you can on them whats the differance between these and a pc
|
|||
16 Aug 2004, 19:49 |
|
i-don 16 Aug 2004, 22:40
You can't find those type computer anymore except in a museum. But, I did remember during childhood, they use CP/M system if I'm not wrong where the last thing that capable to write binary from it's OS boot. Still, it use use some kind of editor which is capable to write text and binary file. At the time, all PC is running 8bit environments with very limited and expensive memory chips.
If you really had energy to persue such kind of difficulties, you may begin with eeprom programming. You need to assemble all the parts into an electronic breadboard or custom made circuit board. Usually it accompany using a little OS source code which is written in gw-basic alike intepreter. I remember, in an old electronic magazine, they provide the source code for an 8bit OS which is very long and only use LCD as it screen as output. If you could find some old electronic magazines that has eeprom programming articles, you might get lucky to built one with the old ways. Then you need to make some switches to control transistors to handle binary signals (something like 100101). Next, you need to tweak a magnetic tape recorder to record your binary signal into it. Next time you need the same binary sequences, you just replay the tape stripe. Cut each stripe and paste into a cardboard or something. Or in this modern day, you need to buy a blank or credit card and it's reader which is using magnetic stripe to store the data. The signal you've saved in the tape is a just a fraction of an assembler/compiler building block. You need to record thousand of sequences to have a simple 16bit assembler like debug.com program. I would recommend you begin with using fasm for dos from a bootable diskette, instead. The first step, is to make your own tiny operating system. What make the different is if you able to embed the assembler into your tiny OS. That make your OS capable to write a binary file from anywhere it's was booted. From there, you could start over again about your idea "to re-inventing the wheel from the scratch". I think you could use menouet os source code and take out the gui part. Since it use fasm, it would ease the journey. Modified it's source to take input from console screen only. This could be done by studying it's installer option source code. just some thought |
|||
16 Aug 2004, 22:40 |
|
Dragontamer 18 Aug 2004, 00:19
“If I have seen farther than others, it is because I was standing on the shoulders of giants.†-- Newton
That just about sums it up. The first assembler was written in machine code. The first compiler was made in assembly. And then from then on, people just used assemblers and compilers instead of "hex editors"... actually punching the cards themselves. |
|||
18 Aug 2004, 00:19 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.