Beta

×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Assembler Compiler In Bash

michael posted more than 13 years ago | from the bass-ackwards dept.

It's funny.  Laugh. 126

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."

cancel ×

126 comments

Sorry! There are no comments related to the filter you selected.

Re:Let me guess... (1)

Anonymous Coward | more than 13 years ago | (#430814)

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).

Re:Java, or... (1)

Anonymous Coward | more than 13 years ago | (#430815)

Damn, troll, learn something before you post. Java is not slow. It takes longer for Java programs TO COMPILE, but once compiled, theres no real difference.

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?

Hardcore math (1)

Anonymous Coward | more than 13 years ago | (#430816)

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.

Actually (1)

Anonymous Coward | more than 13 years ago | (#430817)

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.

Re:'Assembler Compiler?' (1)

Anonymous Coward | more than 13 years ago | (#430818)

'Assembler' used to mean both the mnemonic 'language'...

The mnemonic language is better known as assembly, while the word assembler indicates the translator.

Re:Cut to the chase (1)

Ranger Rick (197) | more than 13 years ago | (#430819)

It's called "eval".

:)

1st Law Of Networking: Loose ends are bad, termination is good.

Re:time for a time-out (1)

kju (327) | more than 13 years ago | (#430820)

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.

Re:shasm (1)

Stormie (708) | more than 13 years ago | (#430821)

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.

Re:Java, or... (1)

Chacham (981) | more than 13 years ago | (#430823)

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;

Re:'Assembler Compiler?' (1)

Hulver (5850) | more than 13 years ago | (#430824)

In your dreams (:

Re:Next step (1)

/dev/kev (9760) | more than 13 years ago | (#430825)

You probably want CFLAGS=-S
:)

Re:huh? (1)

Xerithane (13482) | more than 13 years ago | (#430828)

No, you really couldn't. That would be a shell script that runs gcc.

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.

Who is the author? (1)

jutus (14595) | more than 13 years ago | (#430829)

Who is the madman that gets credit for this compiler?

Re:Next step (1)

Chmarr (18662) | more than 13 years ago | (#430830)

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... :)

Re:'Assembler Compiler?' (1)

Cee (22717) | more than 13 years ago | (#430831)

Sorry.. I don't think so..

Not the first one (1)

mwood (25379) | more than 13 years ago | (#430832)

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?

Re:time for a time-out (1)

schon (31600) | more than 13 years ago | (#430835)

for i in `seq 1 1000`; do
echo "Shell-script is not an effective tool for complex programming tasks."
done

Speaking of asembly (1)

(startx) (37027) | more than 13 years ago | (#430836)

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!

Big Deal (1)

B.B.Wolf (42548) | more than 13 years ago | (#430839)

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.

Re:Speaking of asembly (1)

alehmann (50545) | more than 13 years ago | (#430840)

zcc includes 'as', a good assembler with a linker and all. Search for it on google.

Re:You are mistaken, Dumass! - No, you are! (1)

commbat (50622) | more than 13 years ago | (#430841)

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.

Re:I Guess they beat the Emacs people (1)

J.Random Hacker (51634) | more than 13 years ago | (#430842)

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.

Re:Interactive assembler -- already done (1)

redelm (54142) | more than 13 years ago | (#430843)

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.

Re:PerlOS (1)

shadowspar (59136) | more than 13 years ago | (#430844)

IIRC I had heard that there is someone, somewhere, merrily hacking away writing PerlOS (complete with device drivers, of course.)

all right! (1)

operagost (62405) | more than 13 years ago | (#430845)

Now I have a use for the two VICs in my hall closet! I figure I can burn through a sample in about 5.6 years!

You've truly inspired me. I think I'm going to write an OS in QBasic now!

Getting SHASM (1)

tuiedm (67883) | more than 13 years ago | (#430846)

Replace the ftp with http and all is well.. Seems they aren't allowing anonymous ftps any longer or something.
Ed.

Re:Disassembler would be better. (1)

jaakko (69953) | more than 13 years ago | (#430847)

Superiority, bah. GNU zealot.

Re:'Assembler Compiler?' (1)

alprazolam (71653) | more than 13 years ago | (#430848)

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.

Re:LOL (1)

alprazolam (71653) | more than 13 years ago | (#430849)

he was confused, it was really ascii art, he just thought it was perl code.

borg (1)

bendawg (72695) | more than 13 years ago | (#430850)

This Bash of Borg. Resistance is futile. You will be assembilated.
(Sorry--Couldn't resist)

Go G! (1)

ayf6 (112477) | more than 13 years ago | (#430853)

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

Re:'Assembler Compiler?' (1)

rmstar (114746) | more than 13 years ago | (#430854)

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....

[...]

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?

How about (1)

roman_mir (125474) | more than 13 years ago | (#430856)

Object Oriented Assembler (OOA that is.) Come up with that, and you're all set for the trip to a nut house.

Re:Slashdotted ftp (Off Topic!) (1)

pallex (126468) | more than 13 years ago | (#430857)

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!

Re:Slashdotted ftp (Off Topic!) (1)

pallex (126468) | more than 13 years ago | (#430858)

Talking of slashdotted, i couldnt get into SlashDot yesterday from 09.00 -> about 17.00 uk time - anyone else have this prob?

Re:hee, hee, hee (1)

Hellburner (127182) | more than 13 years ago | (#430859)

"For me to bash on!"

Really ugly.... (1)

lotussuper7 (134496) | more than 13 years ago | (#430860)

Well, cool. I always like hacks like that.

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....

Re:Getting SHASM (1)

hardburn (141468) | more than 13 years ago | (#430862)

Nope, just slashdotted. Maximum of 60 anoyn connections. I've provided a mirror on Freenet [freenetproject.org] ; see another post.


------

Re:Slashdotted ftp (1)

hardburn (141468) | more than 13 years ago | (#430863)

I have provided this mirror on Freenet [freenetproject.org] :

KSK@/slashdot/mirror/shasm.TGZ [freenet]

The direct CHK is CHK@CZMmKmFfPIBICsilSsDybTofi1oOAwE,cNNb4iRSoRGynx ANzqhByQ [freenet]

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 [freenetproject.org] and download and install Freenet. Then request the key.


------

Freenet Mirror (1)

hardburn (141468) | more than 13 years ago | (#430864)

I have provided this mirror on Freenet [freenetproject.org] :

KSK@/slashdot/mirror/shasm.TGZ [freenet]

The direct CHK is CHK@CZMmKmFfPIBICsilSsDybTofi1oOAwE,cNNb4iRSoRGynx ANzqhByQ [freenet]

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 [freenetproject.org] and download and install Freenet. Then request the key.


------

Re:How about (1)

hardburn (141468) | more than 13 years ago | (#430865)

Amiga Virtual ASM is, if you can really call it "assembly". In any case, OO is really something better left for high-level work.


------

Re:huh? (1)

nomadic (141991) | more than 13 years ago | (#430866)

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...
--

Re:Slashdotted ftp (Off Topic!) (1)

TheEye (142492) | more than 13 years ago | (#430867)

Why then takes this more than ten hours?

My suggestion was a compromised server, since
the trace stopped dead somewhere in the states.

Hmmm...

Re:Critic (1)

f5426 (144654) | more than 13 years ago | (#430868)

> 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

rtfm? (1)

darthdrinker (150713) | more than 13 years ago | (#430869)

WTF is bash? errrr... oke mum, i'll be down in a minute!

time for a time-out (1)

jnorden (152055) | more than 13 years ago | (#430870)

Its been said millions of times - just because something can be done doesn't mean that it should be done.

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.

Re:I Guess they beat the Emacs people (1)

drinkypoo (153816) | more than 13 years ago | (#430871)

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

Re:huh? (1)

drinkypoo (153816) | more than 13 years ago | (#430874)

sed and awk aren't part of bash.

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

Re:Critic (1)

de Selby (167520) | more than 13 years ago | (#430875)

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.

Re:Slashdotted ftp (Off Topic!) (1)

lucius (189447) | more than 13 years ago | (#430876)

Me too, from Australia. Got k5 and rootprompt fine though.

Weird

My SETI@Home client compiled for the VIC-20 (1)

tenzig_112 (213387) | more than 13 years ago | (#430878)

The compiled binary was so large, it took up two sixty minute cassettes.

yeah, i'm l337! [ridiculopathy.com]

Link in article ? (1)

RedLaggedTeut (216304) | more than 13 years ago | (#430879)

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 :-)

Disassembler would be better. (1)

BlowCat (216402) | more than 13 years ago | (#430880)

GNU utilities can deal with binary zeros in the input, as opposed to the traditional UNIX utilities.

A disassembler in bash (or in gawk) would demonstrate the superiority of GNU software.

Re:Disassembler would be better. (1)

BlowCat (216402) | more than 13 years ago | (#430881)

Well, write just "od" in ksh or in any non-GNU shell of your choice. Or in any non-GNU awk.

Just promise me one thing: (1)

AFCArchvile (221494) | more than 13 years ago | (#430882)

Promise that you won't program a video codec or a web browser in bash.

Crazy or just mis-understood? (1)

James Foster (226728) | more than 13 years ago | (#430883)

Genius is often mis-understood.
Then again, maybe both? ;]

Re:Didn't get the idea fist. But then! (Maybe not) (1)

julesh (229690) | more than 13 years ago | (#430884)

There are many assemblers out there. Some [web-sites.co.uk] come with ANSI C source code. There are ANSI C compilers available for at least as many platforms as BASH runs, as BASH requires an ANSI C compiler in order to compile... therefore an ANSI C assembler is more portable (?!)

So... why?

Re:LOL (1)

FreeMath (230584) | more than 13 years ago | (#430885)

The only question is: Which way do we do it?

Oucha ... (1)

jamiguet (232071) | more than 13 years ago | (#430886)

Was it actually required to generate automatic assembly code for some kind of self modifying program or something of the sort? Or is it just an overkill being bored? I can see this kind of stuff usefull if you do embeded stuff and have scripts to generate code but then it wont be x86 or would it?

-------------------------------------

Re:Critic (1)

ConsumedByTV (243497) | more than 13 years ago | (#430887)

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!

Re:Critic (1)

Kurt_Rambone (257219) | more than 13 years ago | (#430889)

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?

Re:Critic (1)

Kurt_Rambone (257219) | more than 13 years ago | (#430890)

>> 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....

Slashdotted ftp (1)

ooze (307871) | more than 13 years ago | (#430894)

Is even worse than slashtotted http. Never,never, do this again, or provide mirrors. Is there a mirror anywhere?

Didn't get the idea fist. But then! (1)

ooze (307871) | more than 13 years ago | (#430896)

"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.

Re:Slashdotted ftp (Off Topic!) (1)

ooze (307871) | more than 13 years ago | (#430897)

Yep, me. From Germany.

I Guess they beat the Emacs people (1)

robert-porter (309405) | more than 13 years ago | (#430898)

But then again there kinda busy workning on emacsWM.

Why not ? (1)

lemarsu (316337) | more than 13 years ago | (#430899)

I even made an assembler for 6502 in Basic.
Yeah, but that was looooong ago on a PET Commodore !

Re:Depends on definition of "high-level" (1)

_tiny_8_ (316425) | more than 13 years ago | (#430900)

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.

Re:Java, or... (2)

Anonymous Coward | more than 13 years ago | (#430901)

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.

Re:'Assembler Compiler?' (2)

Hulver (5850) | more than 13 years ago | (#430903)

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.

Re:Strange... (2)

mcc (14761) | more than 13 years ago | (#430905)

As of this posting neither netscape 4/windows nt or wget/slackware were able to connect, with or without email address passwords.

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 -_-

Re:LOL (2)

mcc (14761) | more than 13 years ago | (#430906)

As a perl -e oneliner :)

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.. :)

huh? (2)

kaisyain (15013) | more than 13 years ago | (#430908)

sed and awk aren't part of bash.

Re:Some People. (2)

hugg (22953) | more than 13 years ago | (#430910)

Just think what would have happened if Linus decided to go for a walk instead of hack!!! Flood. Famine.

Re:'Assembler Compiler?' (2)

mistered (28404) | more than 13 years ago | (#430911)

Assembly language is pretty much a straight one for one conversion into machine code

Indeed, on some processors the assembler does even more including expanding one assembly instruction into multiple machine instructions. On a MIPS [mips.com] for example there's even a register reserved for the assembler ( at - assembler temporary) to use when expanding instructions.

Cut to the chase (2)

lildogie (54998) | more than 13 years ago | (#430912)

Clearly the ultimate would be bash in bash.

Re:Slashdotted ftp (Off Topic!) (2)

Snard (61584) | more than 13 years ago | (#430913)

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...

But you still leave "assembly language" undefined (2)

yerricde (125198) | more than 13 years ago | (#430915)

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:

  • The macroinstruction support in more powerful assemblers distorts the "one asm instruction, one binary instruction" aspect of the commonly accepted definition of asm. The MIPS asm specification specifies a large number of "pseudoinstructions," that is, short macros that use MIPS register 0. A rich macro system in an assembler could possibly make MIPS look like PowerPC look like ix86 look like Sparc look like Alpha look like XScale look like ARM look like even good ol' Z80 and 6502.
  • One word: Java.
  • How do we know it isn't possible to create a machine that runs C bytecode in hardware? It's already been done for Forth.

All your hallucinogen [pineight.com] are belong to us.

Depends on definition of "high-level" (2)

yerricde (125198) | more than 13 years ago | (#430916)

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 [pineight.com] are belong to us.

Portable asm has been done (2)

yerricde (125198) | more than 13 years ago | (#430917)

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 [nyu.edu] (Java virtual machine assembly) is even binary-compatible across Linux/x86, Solaris/SPARC, Mac/PowerPC, and Windows/x86.


All your hallucinogen [pineight.com] are belong to us.

Re:'Assembler Compiler?' (2)

saider (177166) | more than 13 years ago | (#430920)

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.



Re:Java, or... (2)

Marc2k (221814) | more than 13 years ago | (#430921)

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.

Java, or... (2)

FreeMath (230584) | more than 13 years ago | (#430922)

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?

Re:Critic (2)

FreeMath (230584) | more than 13 years ago | (#430923)

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.

Re:Critic (2)

Kurt_Rambone (257219) | more than 13 years ago | (#430925)

>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....

Re:Critic (2)

Kurt_Rambone (257219) | more than 13 years ago | (#430926)

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 [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 [x86.org] loads of info about x86 programming

www.cfxweb.net [cfxweb.net] Loads of articles on assembly programming and HLL too.

Hope that clears a few things up *g*

hee, hee, hee (3)

Anonymous Coward | more than 13 years ago | (#430927)

Bash (bæsj) means poop in Norwegian!

A standard mirror... (3)

Rain (5189) | more than 13 years ago | (#430928)

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 [everything2.com] based.

HTTP: http://www.bluecherry.net/~rain/shasm.tgz [bluecherry.net]
FTP: ftp://ftp.bluecherry.net/pub/misc/shasm.tgz [bluecherry.net]


Our FTP server has a limit of 15 anonymous users, so I'd highly recommend using the HTTP mirror unless some BOFH [everything2.com] firewalled port 80 outbound. (I've seen it happen!).

--
Ben Winslow..........rain@bluecherry.net
bluecherry internet..http://www.bluecherry.net/

Interactive assembler (3)

coreman (8656) | more than 13 years ago | (#430929)

We've had intereactive C for a while now, interactive assembler seems a reasonable extension... hmmm interrupt latency is what, 3-4 days?

shasm (3)

_Gnubie_ (14485) | more than 13 years ago | (#430930)

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

Re:'Assembler Compiler?' (3)

commbat (50622) | more than 13 years ago | (#430931)

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.

Re:Next step (3)

UberLame (249268) | more than 13 years ago | (#430932)

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.

Let me guess... (3)

Soft (266615) | more than 13 years ago | (#430933)

Someone has had a bad experience of the Admin Horror Stories [hunter.com] kind, rm-rf/ and the like?

Assembler vs. compiler (4)

eap (91469) | more than 13 years ago | (#430934)

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).

'Assembler Compiler?' (5)

emerson (419) | more than 13 years ago | (#430935)

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....


--

Next step (5)

geirt (55254) | more than 13 years ago | (#430936)

the next crazy step

bash in assembler.

By the way, that would make bash self booting ...

---
recursion, n: see recursion.

Strange, stupid things to do with common tools (5)

multipartmixed (163409) | more than 13 years ago | (#430937)

...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".

--

Bullshit (5)

multipartmixed (163409) | more than 13 years ago | (#430938)

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.

--

LOL (5)

jawtheshark (198669) | more than 13 years ago | (#430939)

Now we just need an assembler written in perl! Everyone knows that will be the more elegant code ;-)
Load More Comments
Slashdot Login

Need an Account?

Forgot your password?
or Connect with...

Don't worry, we never post anything without your permission.

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>