Assembler Compiler In Bash
sTeF writes "This guy is crazy, he wrote an assembler totally in Bash. After all those awk/sed/ps httpservers this is the next crazy step. what's next? a virtual machine in Bash? anyhow here's the url to the source."
← Back to Stories (view on slashdot.org)
a friend of mine once, when writing his thesis, "renamed" his Postscript pictures like this:
rm foo*.eps bar*.eps
fortunately he had a (one day old) backup. It's not exactly an admin horror story, but he knew the root password (his machine).
The poster said " How about a java virtual machine written in bash. Would that be slow enought?".
Was the poster correct saying it would be slow. Yes!!! Guess who is the troll?
I once turned in my solutions for a Miller-Rabin Primality Tester ( to test large ( >15 digit ) primes ) in Javascript! The Professor was amazed he could surf to a webpage, type a large number in a textfield, hit a button & test primality , all on the client-side without any C/perl/whatever, plus he could do a "View Source" & see the javascript source code right there. That's how you misuse tools, my man.
For crackers who want to do some stack smashing, this would be quite useful for compiling a buffer overflow attack from a compromised machine that didn't have any compilers installed. Systems Administrators beware.
The mnemonic language is better known as assembly, while the word assembler indicates the translator.
:)
1st Law Of Networking: Loose ends are bad, termination is good.
WWJD? JWRTFM!!!
Please take some time and read the documentation which comes with the assembler. It got some points why the assembler was written and possible usages.
The guy who wrote this Colorg (Rick) , also maintains cLIeNUX (Client orientated Linux)
Is he the guy that started that huge flamewar by suggesting that /bin, /etc, etc. be renamed to /.bn, /.et etc. to hide them, and then adding symlinks like "/Binaries -> /.bn". What a weird bloke.
Those nutty Amiga people...
y
Oh come on, everyone knows that Java running under Bash is slow. But when bash is running on Linux it's faster than everything else. In fact, it'd be so fast, it'll finish compiling even before you finish writing the code.
What we're all waiting for is the JVM in E-macs. That'll be the day. :-)
ticks = jiffies;
while (ticks == jiffies);
ticks = jiffies;
Have you read my journal today?
In your dreams (:
-- Hulver's site
You probably want CFLAGS=-S
:)
Quidquid latine dictum sit, altum viditur.
Machine code is another language. You could even program in it if you felt the masochistic urge. It is a language that is interpreted by a microprocessor. I am perfectly aware of what is normal terminology in "the trade." But compiler is also a computer science term that is much broader than the original poster indicated. A lot of terms in "the trade" change pretty frequently (for example, try to define "operating system" in a manner that cannot be debated). So I don't see the point of jumping on someone because of some terminology usage just because it offends some arrogant programmer.
Get off your fsking high horse. The definition of a compiler is a little more broad than what you've given.
A compiler takes something in language source and translates it into its equivalent in language target. Language target is commonly machine code. However, language could be something like assembly code, C code, or even a TeX DVI file (tex has rightly been called a compiler).
What's the big deal if source is an assembly language instead of a high-level language? Yeah, you might want to be more specific and call it an assembler, but by the accepted definition of a compiler it is in the domain of compilers.
Now, consider your definition of a compiler:
Basically, an assembler is a compiler by my definition and your definition. So stop the elitist arrogancy because you think you know what is and is not a compiler unlike the so-called uneducated masses.
Instead of a shell script that converts C code to machine language. Yes, it would require other atomic pieces (sed/awk) but the shell script would do the conversion.
Dacels Jewelers can't be trusted.
Who is the madman that gets credit for this compiler?
Hey... what's the big deal? WHen I was in university, I wrote a C compiler, and linker, in BASIC on my TRS-80/Model I.
:)
Okay, so 'Hello world\n' took 20 minutes to compile...
Sorry.. I don't think so..
Many years ago I used VMS DCL to write what would now be called a bytecode compiler for a menusystem description language. Getting DCL to output arbitrary binary was, ah, an interesting experience.
I'm glad to see I'm not the only weirdo out there. Be creative! Think about what your tools *do*, not just how everybody else uses them. Has anybody else tried doing DHTML in m4?
...but I have much greater respect for Greg Ubben's complete implementation of dc in sed. It comes with newer versions of GNU sed and therefore probably hides somewhere on your hard disk (try locate dc.sed). Or look here.
what about that?
;-)
f C compilers are written in C why not write a BASH interpreter using BASH...
that'll probably be about 100 times slower than the original BASH, so you can even run SHASM in this new thing and get a 10000 times slower assembler..
which will be cool of course
for i in `seq 1 1000`; do
echo "Shell-script is not an effective tool for complex programming tasks."
done
Does anyone know of a good z80 asmbler for linux? I've got an itching to work on my TI-83 again, and no TASM to do it with!
One of my buddies wrote an assembler in HP Basic back in 1976 while we were sophmores in high school. We used Model 25 Teletypes to connect to our highschools mainframe. He also wrote a virtual machine kinda based on the 6800.
A 6502 cannot last a 1020 years
Three possibilities:
1) Hardened militarized versions of the chip were discovered and used in the bender units,
2) The 6502 was reversed engineered from surviving copies of 'Attack of the Mutant Camels'
3) The templates used in the manufacture of 6502s were discovered and reused.
'Intellectual Properties' are uncontrollable in the wild. To base an economy on them is just stupid.
If you mean by that that EMACS doesn't have an assembler, au contraire (did I spell that right? ;-). EMACS has the only assembler you'll ever need, once you have Emacs installed. It translates elisp into bytecodes.
:-).
Now for those of you thinking -- wait, isn't that a compiler? -- remember that the bytecode compiler has a lower level section that you can use as an assembler, which again points out that with LISP you can do anything, and make it look the way you like, as long as you like lists
I *love* EMACS... I love LISP even more.
I hate to say it, MicroSoft has beaten you to the punch!
MS-DOS since v 1.0 has included Paul Allen's DEBUG.COM . IMHO, this is the unsurpassed high-water mark of MS's products.
DEBUG.COM (now DEBUG.EXE) is remarkably interactive. It has a built-in miniassembler and disassembler and is remarkably interactive in use.
IIRC I had heard that there is someone, somewhere, merrily hacking away writing PerlOS (complete with device drivers, of course.)
There is a spellbook here; eat it? [ynq]
You've truly inspired me. I think I'm going to write an OS in QBasic now!
Gamingmuseum.com: Give your 3D accelerator a rest.
Replace the ftp with http and all is well.. Seems they aren't allowing anonymous ftps any longer or something.
Ed.
Ed.
To Be or not to Be.. It's all the same at the end.
Superiority, bah. GNU zealot.
i've always called what you call assemblers compilers. they're no different from what you call compilers. they're going from high level language to low enough to run. and how come it doesnt even say what hardware the compiler is for? assembly languages differ.
he was confused, it was really ascii art, he just thought it was perl code.
This Bash of Borg. Resistance is futile. You will be assembilated.
(Sorry--Couldn't resist)
Joe Ganley
ganley.org
I thought a C++ Compiler in XSLT sounded pretty crazy until my brother said he'd thought about writing one, "just for fun".
Bash compiler... What will this guy think of next. Seems like colorg (rick) is always coming up w/ a new crazy idea. For those of you that dont know Clienux (colorg's distribution) uses a unique directory structure (no /etc for example). Its unique and you all should try it...
-jester
[...]
Moderators: copy/pasting text from the site a story links to isn't "Informative," it's "Redundant."
I don't know, but don't you think someone else is being really really pedantic?
Jesus, you must be a fun guy to work with.
I know him, and he is.
--
Object Oriented Assembler (OOA that is.) Come up with that, and you're all set for the trip to a nut house.
You can't handle the truth.
yeah,absolutely everything else was fine. When i came back i expected to see no posts all day, but instead it was business as usual!
Talking of slashdotted, i couldnt get into SlashDot yesterday from 09.00 -> about 17.00 uk time - anyone else have this prob?
"For me to bash on!"
Long time ago, an anonymous hacker where I worked did a fortran compiler in TECO. Someone else started to (re)write system utilities in Teco, as well (like SYSDPY on the PDP-10.) Nice hack....
----- Lotus Super 7 - A real car.
How can a 5cr1pt k1dd13, with an IQ that large, possibly figure out what the result of `xor ax, ax is?
I have provided this mirror on Freenet:
KSK@/slashdot/mirror/shasm.TGZ
The direct CHK is CHK@CZMmKmFfPIBICsilSsDybTofi1oOAwE,cNNb4iRSoRGynx ANzqhByQ
If you have Freenet node and a plugin for your browser that can understand freenet: URIs, you can click the above to get it. Otherwise, go to www.freenetproject.org and download and install Freenet. Then request the key.
------
Not a typewriter
I have provided this mirror on Freenet:
KSK@/slashdot/mirror/shasm.TGZ
The direct CHK is CHK@CZMmKmFfPIBICsilSsDybTofi1oOAwE,cNNb4iRSoRGynx ANzqhByQ
If you have Freenet node and a plugin for your browser that can understand freenet: URIs, you can click the above to get it. Otherwise, go to www.freenetproject.org and download and install Freenet. Then request the key.
------
Not a typewriter
Ah, grasshopper, you are missing the whole point of Unix - The pipe. Everything on Unix is [intended to be] part of everything else.
By that logic I could make a C compiler by just making a bash script that runs gcc...
--
Why then takes this more than ten hours?
My suggestion was a compromised server, since
the trace stopped dead somewhere in the states.
Hmmm...
> Now what I'd love to see, is a free X server for OS X. Mmm, that would make my life complete!
What about XFree86 4.0.2 ? Get the darwin distribution at xfree86.org then the rest from http://mrcla.com/XonX/
Now that I have completed your life, could you refrain to post garbage ? A bash assembler is just awsome...
Cheers,
--fred
1 reply beneath your current threshold.
WTF is bash? errrr... oke mum, i'll be down in a minute!
Now, take this pencil and pad of paper and go sit in the corner. Write the following line 1,000 times:
Shell-script is not an effective tool for complex programming tasks.
------
Life would be better and Linux would have far fewer bugs if we could somehow force this time-out on lots of other folks too. Case in point: teTeX.
If by "beat the Emacs people" you mean, "Invented something needlessly slow to perform a task which is already better-performed elsewhere", then you are wrong. Emacs has been doing that since its inception.
--
ALL YOUR KARMA ARE BELONG TO US
"You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
Duh. But you're still missing the point of my post, which was to say that no app in unix is intended to stand alone. The whole IDEA of Unix is that you can string your commands together; Implementing something solely in bash is the right way to do it if it's the fastest and/or easiest, but if using sed and/or awk would have made it easier, then doing it without them is contrary to the lazy* nature of Unix.
* This is, of course, the type of laziness made famous by Larry Wall.
--
ALL YOUR KARMA ARE BELONG TO US
"You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
When I started this sub-thread (way up the tree from here) I wasn't saying I didn't get it; I was saying that it was pointless and unnecessary, and I was attempting to explain why.
HTH, HAND.
--
ALL YOUR KARMA ARE BELONG TO US
"You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
Ah, grasshopper, you are missing the whole point of Unix - The pipe. Everything on Unix is [intended to be] part of everything else.
Remember, pipes as we know them in the Unix (and everything else these days) shells came from Unix. That's where that shit was invented. The idea was to produce a bunch of atomic utilities that one could tie together with shell scripts, exactly as one does on any other mainframe (Or at least, you used to need a 'frame to run this junk. OS/400. OS/390. Etc.)
ObDisclaimer: I don't think OS/400 or OS/390 are junk. I Think they're both very nice. Please do not send men in blue suits to beat me up.
--
ALL YOUR KARMA ARE BELONG TO US
"You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
The PS1 was supposed to be C only (and it had great C libraries from launch) but soon many titles had optimized ASM in small portions--Crash Bandicoot was entirely in ASM!
The same will probibly happen with the PS2. While it is a multiprocessor system, I doubt anything will be 100% pure ASM, but with the absence of a good C library like the PS1 had, eventually many functions will likely be given to some ASM procedures.
Me too, from Australia. Got k5 and rootprompt fine though.
Weird
This was surely true 10 years ago, but today just take any assembler source file and read it through. You'll find alot of non-assembler text in there. It might be processor directives, or simplified function calls, mmx/3dnow macros, perhaps even OOP declarations. Assembler has developed into a semi-compiled language over the years, where you still have full control over the generated code, but the "assembler/compiler" supports added features that can help you write simpler, more readable code.
-Billco, Fnarg.com
yeah, i'm l337!
I think the link to the big source archive should not be in the article, since few people will actually want to use the source right now, and this will waste bandwidth :-)
I'm still trying to figure out what people mean by 'social skills' here.
A disassembler in bash (or in gawk) would demonstrate the superiority of GNU software.
Promise that you won't program a video codec or a web browser in bash.
"Ancillary does not mean you get to rule the world." --U.S. Circuit Judge Harry Edwards, speaking to the FCC's lawyer
Genius is often mis-understood. ;]
Then again, maybe both?
So... why?
The only question is: Which way do we do it?
This sig intentionally left blank.
-------------------------------------
Where is my mind?
As funny as that is, there isnt anything wrong with being a fag.
The question he/she should have been asking was:
Can you guys teach me what assemly is really good for and what the difference between that and a HLL is?
Fight censors!
"Not my manner of thinking but the manner of thinking of others has been the source of my unhappiness." - M
Now we can have a cross-platform x86 assembler anywhere there's a bash shell available. Windows, DOS, Linux, Solaris, oh my!
Oh...wait a second. It's only NASM in interpreted form but isn't as useful.
Neat for hack value alone though.
The truth about Michael
So you can write a driver in a HLL huh?
So you can code a routine to a certain byte size in a HLL?
So you can code a routine to execute in a certain number of cycles in a HLL?
Is it pointless to squeeze the last bit of performance from a routine?
Need I go on?
>> I am a regular contributor to a rather large ;)
:)
>> open-source project (xmame/xmess) so that
>> probably gives me an idea or two
>WTF are you doing making a tit of yourself on slashdot then? Get back to work whiping boy!
Maybe 'cos I'm a tr0ll trying to start a flamewar?
>BTW, you are talking shit about being able to code a routine to execute in a set number of instructions. Have you hear of branching? If you even think about keeping count of branches and burning cycles at the end to compensate for any missed then _I'm_ gonna have to kill you
Why burn cycles when you can use the time to do something productive with them. There's always a few things that could be done in those extra cycles....
Yeah, first you have to actually GET IN with one of those services. etc/hosts.allow and run MON with another non-internet box prevents shit like that. Plus the new statefull firewall. And I'm not even the sysadmin.
Moving at the speed of government.
sh2p!!!!!!! try it :)
"Ummmm..."
Is even worse than slashtotted http. Never,never, do this again, or provide mirrors. Is there a mirror anywhere?
Just because I can imagine doing a hippopotamus, doesn't mean I'd like to do it.
Compiling can get complicated, as there are many system dependent and version conflicting libraries. Bash is bash, and it runs out of the box. Maybe slowly, but it runs. But you are right, a developer, who wants to make asm code, has a decent compiler, and can build an assembler. But there might be exceptions, and then bash asm enters the stage.
Just because I can imagine doing a hippopotamus, doesn't mean I'd like to do it.
"Assembler is machine dependent, so why make it portable?" was my fist thougt. But then! Now it is possible to create x86 executeables from any system with a bash! Quite important for a new boot code or similar low level tasks. Especially when you dont have a working system on a destination machine type. And a bash is available on rather more systems than Java!
Nice hack! Should be done for more processor types, as it is more important for less widespread and new types as IA64 or PPC.
Just because I can imagine doing a hippopotamus, doesn't mean I'd like to do it.
Yep, me. From Germany.
Just because I can imagine doing a hippopotamus, doesn't mean I'd like to do it.
But then again there kinda busy workning on emacsWM.
I even made an assembler for 6502 in Basic.
Yeah, but that was looooong ago on a PET Commodore !
Listing 1: for(;;){ /*do something*/
}
Listing 2:
mov edx, 1
mov ecx, 2
mov ebx, 3
mov eax, 4
Listing 1 would probably work on an Alpha, a PPC, i386, Ultra Sparc, PDP-11 yadda yadda yadda.
Listing 2 would only work on x86 compatibles.
Why can't we just define what an assembler is ? It would be much easier. An assembler assembles assembly. Simple. Anything that does not do this is not an assembler.
So Listing 1 is a high level language, Listing 2 is not.
I'm guessing you just fell off the boat yesterday. While the current jvms are a bit faster than some of the previous ones they are still slower than their non p code counterparts. I for one am tired of hearing the bs from zealots like you who have probably never done any real coding and think java is a god send. It has it's points but it is hardly the end all be all so many make it out to be.
Assembly language is NOT machine code, so it does need a compiler to turn it into Machine code. Thats what this is, its a compiler for assembly language.
Assembly language is pretty much a straight one for one conversion into machine code, but the assembler does do things like, convert labels into relative jumps. Things like that are a real pain when you are coding in straight Machine Code.
-- Hulver's site
Why? The single-quote is not a special character to a Unix filesystem. It may be special to the shell, it's true. So change your shell? Or just use the facilities in the shell for dealing with this. I have files with single-quotes in. I don't find typing \ or enclosing the name in double-quotes to be appallingly hard work.
My guess is it's just slashdot effect, and the problem is that the quota for simultaneous anonymous connections is exceeded. Or the sysadmin was so horrified by the number of people hammering on her server that she disabled the anonymous acct. altogether. Wait 24 hours, it'll be ok -_-
Irritable, left-wing and possibly humorous bumper stickers and t-shirts
Don't laugh, you just know SOMEBODY in the slashdot reading audience saw jawtheshark's post and started writing a oneline perl assembler immediately -_-
(hell.. whenever i can get through to the /.ed ftp server, i'll try to write one myself.. :)
Irritable, left-wing and possibly humorous bumper stickers and t-shirts
sed and awk aren't part of bash.
I will not rest until I have a 36 bit operating system written in base. TOPS-10 ALL THE WAY!!!!
-- "In order to have power, I must be taken seriously." -Mojo Jojo
Just think what would have happened if Linus decided to go for a walk instead of hack!!! Flood. Famine.
Indeed, on some processors the assembler does even more including expanding one assembly instruction into multiple machine instructions. On a MIPS for example there's even a register reserved for the assembler ( at - assembler temporary) to use when expanding instructions.
Enjoy your job, make lots of money, work within the law. Choose any two.
Clearly the ultimate would be bash in bash.
It appears that the IP address for www.slashdot.org (and just plain slashdot.org) changed in the last 24 hours or so - my nameserver hadn't sync'd up with the change until sometime yesterday afternoon. But people on other name servers were apparently able to connect just fine. I must have a slow nameserver here...
- Mike
Once I wrote a plot program for an HP71B, a handheld computer, in that machine's dialect of BASIC, which would print out lines and arcs (land survey drafting) on their weirdass inkjet printer - took about an hour per 8-1/2" x 11" page...
Unlike these cheat-o-matic languages in popular use these degraded days, which basically run way too God damn fast for you ever to win, BASIC is a sporting language, plays fair, gives you the competitor at least a chance to keep up or even surge ahead and break the ribbon, with nothing more than a pencil and paper and your own slow brain as a processor.
Yours WDK - WKiernan@concentric.net
Why can't we just define what an assembler is ? It would be much easier. An assembler assembles assembly. Simple. Anything that does not do this is not an assembler.
Now your definition of an "assembler" is "a program that translates assembly language into object code"; you still leave "assembly language" undefined. The task of defining asm precisely is complicated by the virtual machines that exist on several levels:
All your hallucinogen are belong to us.
Will I retire or break 10K?
Common practice where I work is to call programs that convert assembly into machine code assemblers, and programs that convert high level source (C,Fortran) into machine code compilers.
Scheme and Perl advocates would say that C and Fortran aren't much higher level languages than assembly; thus the common joke about C compilers being PDP-11 assemblers. I still haven't seen a hard distinction made between "an assembler with a rich macro language" and "a compiler."
All your hallucinogen are belong to us.
Will I retire or break 10K?
The idea is to try to make a porttable ( to an extent ) assembler so asm written on one Arch can port easily to another.
C source code is pretty close to a portable assembly language, source-compatible across any conforming ANSI C compiler. Jasmin (Java virtual machine assembly) is even binary-compatible across Linux/x86, Solaris/SPARC, Mac/PowerPC, and Windows/x86.
All your hallucinogen are belong to us.
Will I retire or break 10K?
It is a matter of semantics, but compilers typically convert a high level language into assembly which is then assembled into the binary machine code.
Common practice where I work is to call programs that convert assembly into machine code assemblers, and programs that convert high level source (C,Fortran) into machine code compilers. Interpreters are the third way to get text to turn into machine code, although they are usually based on compilers (script->C source->object).
Summary
Assemblers - 1 to 1 conversion of keywords to object code
Compilers - keywords often result in many lines of object code
Interpreters - statements are compiled and run as they are being entered.
Remember, You are unique...just like everyone else.
Java only undergoes pseudo-compilation. Even after it is compiled, it is still only in byte code, which must be interpreted. This wonderful combination of a compiled/interpreted language brought to you by Sun makes for incredibly slow runtime versus purely compiled languages. While it's not required to be knowledgable to post on slashdot, it really should be a prerequisite for reprimanding someone on misinformation.
--- What
How about a java virtual machine written in bash. Would that be slow enought?
No, how about something like a PDP-11. Any other ideas?
This sig intentionally left blank.
Yeah, it's kind of like that Linus guy who wanted to learn about the 386. Just look at all the time he waisted on another version of UN*X.
This sig intentionally left blank.
Anyone that puts a single-quote in a UNIX filename needs to be shot.
Anyone that pluralizes CPU with a single-quote needs to be shot.
(I am referring to the directory named sh.asm/CPU's in the tarball.)
This is not a Fugazi
>So you can write a driver in a HLL huh? umm yes.
;)
Erm, let me rephrase the question...
So you can write a driver in a HLL without relying on libraries or LowLevel calls? (think about it..also asm directives don't count)
>So you can code a routine to a certain byte size in a HLL? if you have to
Maybe, but you've still got section padding which still adds bytes...
>So you can code a routine to execute in a certain number of cycles in a HLL? can you in asm? think about it.
Actually yes. every instruction has a cycle count, and any out of order execution or pipelining can be countered using simple optimizing trix.
>Is it pointless to squeeze the last bit of performance from a routine?
You didn't answer the question....
>i think you are asking the wrong questions. i think you should be asking:
Am I a fag? no
Do I have any idea? plenty. I am a regular contributor to a rather large open-source project (xmame/xmess) so that probably gives me an idea or two
Should I kill myself? Wrong question, because I am on a course of antidepressants at the moment to stop me from thinking about exactly that.
Next....
There's not enough space inthis little box for a diatribe, so here's a few links for x86 assembly language programming:-
www.hugi.de Windows based (linux ver on its way) assembly diskmag with plenty of articles on the advantages and disadvantages of ASM vs HLL
www.x86.org loads of info about x86 programming
www.cfxweb.net Loads of articles on assembly programming and HLL too.
Hope that clears a few things up *g*
Bash (bæsj) means poop in Norwegian!
Here's a standard mirror of the beast, since (as posted earlier), the site has a limit of 60 anonymous connections, and I didn't notice any mirror that wasn't FreeNet based.
HTTP: http://www.bluecherry.net/~rain/shasm.tgz
FTP: ftp://ftp.bluecherry.net/pub/misc/shasm.tgz
Our FTP server has a limit of 15 anonymous users, so I'd highly recommend using the HTTP mirror unless some BOFH firewalled port 80 outbound. (I've seen it happen!).
--
Ben Winslow..........rain@bluecherry.net
bluecherry internet..http://www.bluecherry.net/
We've had intereactive C for a while now, interactive assembler seems a reasonable extension... hmmm interrupt latency is what, 3-4 days?
The guy who wrote this Colorg (Rick) , also maintains cLIeNUX (Client orientated Linux) and was awarded the Efnet #Linux "King of the Geeks" crown a few days ago for SH.ASM. I've had a look at the code.
The idea is to try to make a porttable ( to an extent ) assembler so asm written on one Arch can port easily to another.
The cool thing about this is it only needs Bash. no other external utils.
Tre Geek Cool
At the moment not all the instructions are support and it doesnt do Elf and A.out - Only flat listings
the difference between assemblers and compilers
For the newbies who can't understand what we're talking about:
'Assembler' used to mean both the mnemonic 'language' that coincided with machine code (the actual ones and zeros that hardware understands -- sort of) and the program that turns that language into a form that the linker needs to produce the executable.
'Compiler' is a program used to 1) scan the source code looking for keywords and other constructs in the language in question, substituting 'tokens' and making entries into a symbol table. 2) produce meaningful error messages concerning syntax. 3) parse the result determining the meaning of the program, sending this information to a 3) code generator and optionally to a 4) code optimizer. That's a very simplistic definition and one that's not necessarily 100 percent correct for all programs calling themselves 'compilers'.
The current trend of calling assemblers 'assembler compilers' grates against my sensibilities too.
'Intellectual Properties' are uncontrollable in the wild. To base an economy on them is just stupid.
Well, we used to have lisp machines. So, a self booting bash would just make for a bash machine. All programs would just be bash macros that get called from the command line. All storage would be scalars, arrays, and associative arrays. For persistance, bash would need to modified to save it's state to disk, but that would probably fit on a floppy for most people.
I'm a loser baby, so why don't you kill me.
Someone has had a bad experience of the Admin Horror Stories kind, rm-rf/ and the like?
I've done a little bash programming, and I've also written a compiler (in C), and it would seem to me that writing an assembler would not be especially difficult in bash because the langauge contains very good string manipulation utilities (sed, awk, etc.). As one poster mentioned, assembly maps very well to machine code. Building in support for assembler macros could get tough, though.
Now, if you were to try and write a 3rd generation language compiler (such as Pascal) in bash, you might get into trouble fast. This would require some very extensive control and data structures that bash doesn't support as well as, say, C. I'm not sure bash has multidimensional arrays or pointers, and these make constructing things like symbol tables a lot easier.
Still, I would say this guy knows a lot more about bash than I do, and there is probably something I am missing (since I can't read the source right now).
Good thing the Slashdot editors are calling non-coders "l4m3" in the poll this week, since they're SO clear on the difference between assemblers and compilers....
--
the next crazy step
bash in assembler.
By the way, that would make bash self booting ...
---
recursion, n: see recursion.
RFC1925
...many moons ago, my 3rd year AI prof asked us to hand in a solution to the `Blocks World Problem' in any language we wanted to. (Of course he actually wanted a solution in Lisp, but I had just finished hacking some extra functionality into Emacs and was sick of that language)
;-)
I turned in a solution in ksh. He asked me "Why Ksh??", and I said "It doesn't fork to run functions like the bourne shell." Hee hee! I love given right-wrong answers to profs.
A few weeks later I wrote a normal-math to RPN-math parser in Bourne shell using the Shunting Yard algorithm.
You can do all kinds of things in shell -- for those of you among us who extoll p*rl as the be-all and end-all of programming languages, I say, "Try Shell! If you can't do it in shell, you should be writing it in C, anyhow".
--
Do daemons dream of electric sleep()?
You don't need to build anything on the machine-to-be-h4x0rd if you know the target architecture -- which you must if you're going to write your 31337 buffer overflow 3xpl017 in assembler.
Anything which can generate binary from your telnet connection will do -- I've transfered binaries from one system to another by cutting and pasting them in base64, or escaped octal before. Hell, there are even special t00lz designed for transfering binaries which are often available on the target system.. Lets see... I think they are called "ftp", "rsh", "ssh", and other funny nam3z like that.
Yeesh. You people are idiots. Sysadmins beware? Puh-lease.
No 5cr1pt k1dd13 is going to be writing custom one-offs in assembler on a target box.. after all, the 5cr1pt k1dd1e collective IQ is somewhat near the value the ax register holds after xor ax,ax.
No skilled cracker is going to need this tool to do the deed, although it might be handy to have around.
Next time, think before you speak -- alarmism is not useful. If you weren't posting as an AC, I'd think that you were almost certainly trying to a frist psot karma-whore trick.
--
Do daemons dream of electric sleep()?
Now we just need an assembler written in perl! Everyone knows that will be the more elegant code ;-)
Ahhh...the great dumpster continuum. Many a free computer will be found there. -- sowth (748135)