Slashdot Mirror


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

126 comments

  1. Re:Let me guess... by Anonymous Coward · · Score: 1

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

  2. Re:Java, or... by Anonymous Coward · · Score: 1
    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?

  3. Hardcore math by Anonymous Coward · · Score: 1

    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.

  4. Actually by Anonymous Coward · · Score: 1

    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.

  5. Re:'Assembler Compiler?' by Anonymous Coward · · Score: 1
    'Assembler' used to mean both the mnemonic 'language'...

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

  6. Re:Cut to the chase by Ranger+Rick · · Score: 1
    It's called "eval".

    :)

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

    --

    WWJD? JWRTFM!!!

  7. Re:time for a time-out by kju · · Score: 1

    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.

  8. Re:shasm by Stormie · · Score: 1

    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.

  9. Re:How about by ydnar · · Score: 1
  10. Re:Java, or... by Chacham · · Score: 1

    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;
  11. Re:'Assembler Compiler?' by Hulver · · Score: 1

    In your dreams (:

  12. Re:Next step by /dev/kev · · Score: 1

    You probably want CFLAGS=-S
    :)

    --
    Quidquid latine dictum sit, altum viditur.
  13. Re:Who cares? by MrKhuel · · Score: 1

    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.

  14. Who cares? by MrKhuel · · Score: 1

    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:

    • assemblers have to scan source looking for keywords, converting them into tokens and making entries into a symbol table. At least, I would consider "mov" and "add" to be keywords of some sort. And labels definitely need some sort of symbol table. Who cares if it can be translated right away without any processing? It's still translating.
    • Assemblers can also produce meaningful error messages too within the domain of what a meaningful error message is for assembly code.
    • Assemblers have to know what you mean when you say "add $r1, $r2, $r3." It's arguably less than knowing what "x = y + z" means, but to that's just because the scope of the assembly and high-level languages differ.
    • Assemblers generate code typically, amazing.
    • Some assemblers even perform optimizations. For example, some MIPS assemblers would rearrange instructions to take advantage of branch delay slots.

    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.

    1. Re:Who cares? by bored · · Score: 1

      I guess I have to reply..

      Machine code is another language

      Its not!!! That's my point MC and assembly are the same thing! Two different representations of the same thing. Define 'programming' in machine code and you will discover that I can argue that what you are really doing is programming in some symbolic representation of 'machine code'. '0x90' is no more machine code than 'nop' but we don't call it that. Think of an assembler more like a text to speech software rather than a babblefish like translator.

      &LT RANT sorry... &GT
      I understand that you can take the definition of compiler to include assemblers. Your argument about definitions changing is bogus. Rarely do we take a broad definition and use it to cover specific instances when we are trying to be specific. Sure definitions get broader. Name something that was part of the definition of an OS in 1980 that isn't currently part of at least one piece of software generally accepted to be an OS! Broad definitions often extend themselves. When I say "EPROM" I don't have to say "ROM EPROM" its assumed and understood that EPROM is a ROM. When I said memory 10 years ago, that meant DRAM, SRAM, assorted XXROM's. Today memory is all that it was in 1991 but we have additional descriptions like SDRAM, RDRAM, DDR, and assorted other 'new' things.

      You have a valid point about jumping people for terminology, but why do we teach grammar? Its because having a standardized method for expressing something aids in understanding. It is far clearer to call it an 'assembler' than a 'assembler compiler' even though it might be correct by the definitions of a compiler. Which as other people pointed out is actually incorrect, an assembler is the 'compiler'. To be correct, in ones terminology it is really an 'assembly compiler'.

      &lt /RANT &GT

    2. Re:Who cares? by bored · · Score: 1

      A compiler takes something in language source and translates it into its equivalent in language target

      This is precisely why its not appropriate to call an assembler a compiler. Its not technically a language translation. Its rather a symbolic conversion. The language is, for the most part, 1:1 between the human readable symbols and the machine readable symbols. Assuming x86, "NOP" is exactly 0x90 all the time and 0x90 is exactly NOP all the time. Early assemblers were simply advanced search and replace engines. Early compilers still had scan, parse, code generation, and in some cases an optimization pass. Sure you can construe an assembler into a compiler but its really a subset of a compiler because many of the compiler requirements aren't really needed with an assembler. If your going to call an assembler a compiler you might just as well call the disassembled dumps from your favorite debugger "decompiled code".

      Calling an assembler a compiler is not acceptable for someone in the trade. Its acceptable for a layperson to not understand the differences just like it is acceptable for them not to completely understand the differences between flash, PROM, EPROM and RAM.

      Now to support another view point. Using your definition of a compiler what is the difference between a compiler and a cross-compiler? There isn't any is there? Well then how do we distinguish the difference. What about java then, which is (as far as I'm aware there still isn't a true java machine that support the whole spec) always a cross compiler or maybe just a tokenizer. Maybe the whole thing has to do with language! You express and idea with the understanding the audience you are expressing it to understands the basic premises of your topic. Now on /. do you expect people to know what an assembler is? How about a compiler? Now why the heck call it an assembler compiler when you could just call it an assembler written in bash.

  15. Re:huh? by Xerithane · · Score: 1
    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.

    --
    Dacels Jewelers can't be trusted.
  16. Who is the author? by jutus · · Score: 1

    Who is the madman that gets credit for this compiler?

  17. Re:Next step by Chmarr · · Score: 1

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

  18. Re:'Assembler Compiler?' by Cee · · Score: 1

    Sorry.. I don't think so..

  19. Not the first one by mwood · · Score: 1

    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?

  20. that's nice... by mat.h · · Score: 1

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

  21. implement BASH itself in a SH script by cmos · · Score: 1

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

  22. Re:time for a time-out by schon · · Score: 1

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

  23. Speaking of asembly by (startx) · · Score: 1

    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!

    1. Re:Speaking of asembly by alehmann · · Score: 1

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

  24. Big Deal by B.B.Wolf · · Score: 1

    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.

  25. Re:You are mistaken, Dumass! - No, you are! by commbat · · Score: 1

    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.
  26. Re:I Guess they beat the Emacs people by J.Random+Hacker · · Score: 1

    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.

  27. Re:Interactive assembler -- already done by redelm · · Score: 1

    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.

  28. Re:PerlOS by shadowspar · · Score: 1

    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]

  29. all right! by operagost · · Score: 1
    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!

    --

    Gamingmuseum.com: Give your 3D accelerator a rest.
  30. Getting SHASM by tuiedm · · Score: 1

    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.
    1. Re:Getting SHASM by hardburn · · Score: 1

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


      ------

      --
      Not a typewriter
  31. Re:Disassembler would be better. by jaakko · · Score: 1

    Superiority, bah. GNU zealot.

  32. Re:'Assembler Compiler?' by alprazolam · · Score: 1

    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.

  33. Re:LOL by alprazolam · · Score: 1

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

  34. borg by bendawg · · Score: 1

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

  35. let's hear it for turing-completeness by ganley · · Score: 1
    I'm reminded of my own Lisp interpreter written in JavaScript.

    Joe Ganley
    ganley.org

  36. C++ Compiler in XSLT by MrBlack · · Score: 1

    I thought a C++ Compiler in XSLT sounded pretty crazy until my brother said he'd thought about writing one, "just for fun".

  37. Go G! by ayf6 · · Score: 1

    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

  38. Re:'Assembler Compiler?' by rmstar · · Score: 1
    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?

  39. Re:Bullshit by alexburke · · Score: 1

    Jesus, you must be a fun guy to work with.

    I know him, and he is.

    --

  40. How about by roman_mir · · Score: 1

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

    1. Re:How about by hardburn · · Score: 1

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


      ------

      --
      Not a typewriter
  41. Re:Slashdotted ftp (Off Topic!) by pallex · · Score: 1

    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!

  42. Re:Slashdotted ftp (Off Topic!) by pallex · · Score: 1

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

  43. Re:hee, hee, hee by Hellburner · · Score: 1

    "For me to bash on!"

  44. Really ugly.... by lotussuper7 · · Score: 1
    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....

    --
    ----- Lotus Super 7 - A real car. :-}
  45. Re:Bullshit by smack64 · · Score: 1

    How can a 5cr1pt k1dd13, with an IQ that large, possibly figure out what the result of `xor ax, ax is?

  46. Re:Slashdotted ftp by hardburn · · Score: 1

    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
  47. Freenet Mirror by hardburn · · Score: 1

    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
  48. Re:huh? by nomadic · · Score: 1

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

  49. Re:Slashdotted ftp (Off Topic!) by TheEye · · Score: 1

    Why then takes this more than ten hours?

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

    Hmmm...

  50. Re:Critic by f5426 · · Score: 1

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

  51. rtfm? by darthdrinker · · Score: 1

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

  52. time for a time-out by jnorden · · Score: 1
    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.

    1. Re:time for a time-out by seann · · Score: 1

      I'm sick of that "just because something can be done doesn't mean that it should be done" Stop using it! It's his life, it's his machine, and his code. I'm sure he gained valuable expirence by making this program-- and it SHOULD of been done

      --
      I'm a big retard who forgot to log out of Slashdot on Mike's computer! LOOK AT ME.
  53. Re:I Guess they beat the Emacs people by drinkypoo · · Score: 1

    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.'"
  54. Re:huh? by drinkypoo · · Score: 1
    sed and awk aren't part of bash.

    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.'"
  55. Re:huh? by drinkypoo · · Score: 1
    I think you're missing the point of the original post, though; nobody's arguing that bash is meant to stand alone; I think you may have jumped into the argument a few posts too late. If you write a compiler using bash, and do string manipulation through sed and awk, then you haven't written a compiler just using bash. You've used bash AND sed AND awk. We're talking about semantics here, not practical programming.

    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.'"
  56. Re:huh? by drinkypoo · · Score: 1
    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

    --
    "You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
  57. Re:Critic by de+Selby · · Score: 1

    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.

  58. Re:Slashdotted ftp (Off Topic!) by lucius · · Score: 1

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

    Weird

  59. Re:'Assembler Compiler?' by billcopc · · Score: 1

    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
  60. My SETI@Home client compiled for the VIC-20 by tenzig_112 · · Score: 1
    The compiled binary was so large, it took up two sixty minute cassettes.

    yeah, i'm l337!

  61. Link in article ? by RedLaggedTeut · · Score: 1

    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.
  62. Disassembler would be better. by BlowCat · · Score: 1
    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.

    1. Re:Disassembler would be better. by BlowCat · · Score: 1

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

  63. Just promise me one thing: by AFCArchvile · · Score: 1

    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
  64. Crazy or just mis-understood? by James+Foster · · Score: 1

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

  65. Re:Didn't get the idea fist. But then! (Maybe not) by julesh · · Score: 1
    There are many assemblers out there. Some 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?

  66. Re:LOL by FreeMath · · Score: 1

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

    --
    This sig intentionally left blank.
  67. Oucha ... by jamiguet · · Score: 1
    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?

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

    --

    Where is my mind?

  68. Re:Critic by ConsumedByTV · · Score: 1

    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
  69. oh my god. by Pheersum · · Score: 1

    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.

  70. Re:Critic by Kurt_Rambone · · Score: 1

    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?

  71. Re:Critic by Kurt_Rambone · · Score: 1

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

  72. Re:Bullshit by mallsop · · Score: 1

    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.
  73. Re:LOL by MeltyMan · · Score: 1

    sh2p!!!!!!! try it :)

    --
    "Ummmm..." ...The programmer's "Om."
  74. Slashdotted ftp by ooze · · Score: 1

    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.
  75. Re:Didn't get the idea fist. But then! (Maybe not) by ooze · · Score: 1

    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.
  76. Didn't get the idea fist. But then! by ooze · · Score: 1

    "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.
  77. Re:Slashdotted ftp (Off Topic!) by ooze · · Score: 1

    Yep, me. From Germany.

    --
    Just because I can imagine doing a hippopotamus, doesn't mean I'd like to do it.
  78. I Guess they beat the Emacs people by robert-porter · · Score: 1

    But then again there kinda busy workning on emacsWM.

  79. Why not ? by lemarsu · · Score: 1

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

  80. Re:Depends on definition of "high-level" by _tiny_8_ · · Score: 1

    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.

  81. Re:Java, or... by Anonymous Coward · · Score: 2

    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.

  82. huh? by Zach+Baker · · Score: 2
    sed and awk aren't part of bash.

    1. Re:huh? by kaisyain · · Score: 2

      What do pipes have to do with anything?

      The assembler was written entirely in bash. It uses no external utilities. It does not use sed or awk or perl or python or ed or anything else. The post I was replying to was an idiot that got modded as insightful by other idiots.

    2. Re:huh? by nomadic · · Score: 2

      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.

      I think you're missing the point of the original post, though; nobody's arguing that bash is meant to stand alone; I think you may have jumped into the argument a few posts too late. If you write a compiler using bash, and do string manipulation through sed and awk, then you haven't written a compiler just using bash. You've used bash AND sed AND awk. We're talking about semantics here, not practical programming.
      --

    3. Re:huh? by nomadic · · Score: 2

      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.

      Alright; the post that started all these threads said that the bash language contains good string manipulation utilities in the form of sed and awk. Someone pointed out that these were not part of bash. You said UNIX apps weren't meant to run as stand-alones. Nobody disputed this; we're just saying that from a strictly technical point bash, sed, and awk are all different programs, not that they should be run alone.
      --

  83. Re:'Assembler Compiler?' by Hulver · · Score: 2

    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.

  84. Re:Arrrrgh! by paul.dunne · · Score: 2
    > Anyone that puts a single-quote in a UNIX filename needs to be shot.

    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.

  85. Re:Strange... by mcc · · Score: 2
    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 -_-

  86. Re:LOL by mcc · · Score: 2
    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.. :)

  87. huh? by kaisyain · · Score: 2

    sed and awk aren't part of bash.

  88. Re:Java, or... by humphrm · · Score: 2

    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
  89. Re:Some People. by hugg · · Score: 2

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

  90. Re:'Assembler Compiler?' by mistered · · Score: 2
    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 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.
  91. Cut to the chase by lildogie · · Score: 2

    Clearly the ultimate would be bash in bash.

  92. Re:Slashdotted ftp (Off Topic!) by Snard · · Score: 2

    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
  93. efficiency, fairness by anonymous+cowerd · · Score: 2

    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

  94. But you still leave "assembly language" undefined by yerricde · · Score: 2

    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 are belong to us.
    --
    Will I retire or break 10K?
  95. Depends on definition of "high-level" by yerricde · · Score: 2

    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?
  96. Portable asm has been done by yerricde · · Score: 2

    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?
  97. Re:'Assembler Compiler?' by saider · · Score: 2

    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.
  98. Re:Java, or... by Marc2k · · Score: 2

    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
  99. Java, or... by FreeMath · · Score: 2

    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.
  100. Re:Critic by FreeMath · · Score: 2

    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.
  101. Arrrrgh! by sparcv9 · · Score: 2

    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 .sig
  102. Re:Critic by Kurt_Rambone · · Score: 2

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

  103. Re:Critic by Kurt_Rambone · · Score: 2

    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*

  104. hee, hee, hee by Anonymous Coward · · Score: 3

    Bash (bæsj) means poop in Norwegian!

  105. A standard mirror... by Rain · · Score: 3

    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/

  106. Interactive assembler by coreman · · Score: 3

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

  107. shasm by _Gnubie_ · · Score: 3

    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

  108. Re:'Assembler Compiler?' by commbat · · Score: 3

    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.
  109. Re:Next step by UberLame · · Score: 3

    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.
  110. Let me guess... by Soft · · Score: 3

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

  111. Assembler vs. compiler by eap · · Score: 4

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

  112. 'Assembler Compiler?' by emerson · · Score: 5

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


    --

  113. Next step by geirt · · Score: 5

    the next crazy step

    bash in assembler.

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

    ---
    recursion, n: see recursion.

    --

    RFC1925
  114. Strange, stupid things to do with common tools by multipartmixed · · Score: 5

    ...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()?
  115. Bullshit by multipartmixed · · Score: 5

    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()?
  116. LOL by jawtheshark · · Score: 5

    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)