Monday, April 9th, 2007

JSASM: For when you need a x86 assembler in JavaScript

Category: JavaScript, Library

<>p>This is definitely in the double-check department.

JSASM is an x86 assembler written in less than 1000 lines of JavaScript.

This sample version has 80+ opcode variations. My current version has 727 opcode variations (7000+ lines 411kb document for desktops only) created through an automation, and I am slowly verifing opcodes and correcting where nesseary (and yes, there is a lot of nessecity). As is, JSASM can create simple, operable, com files, but the opcode results should be verrified before executing any file.

JSASM will eventually include defines, labels, subroutines, macros, etc. along with utility operations (open, saveas…).

Note this is a view of a very raw work – right now JSASM is very strict, inneficient, and with no built in operational help if you want to jump you’ll need to count bytes and specify target memory locations.
If you want to use this script please let us know.

An interesting experiment. Can anyone think of practical uses?

JSASM

Posted by Dion Almaer at 9:55 am
22 Comments

++++-
4.1 rating from 34 votes

22 Comments »

Comments feed TrackBack URI

Count bytes? Oh man, that reminds me of writing 6502 assembler in high school. I’d write the code out in long hand on paper, then hand-assemble it and type in hex at the Apple Monitor.

Comment by don hosek — April 9, 2007

That’s about the most useless 10k of scripting I’ve ever seen :D But I guess it’s all okay if you put in under the ‘Why? Because we can!’ label :D

Comment by SchizoDuckie — April 9, 2007

To the author: since it’s so clever of you to produce something that’s useless but cool already, you can just take a little step further by “ajaxifying” it more. What I mean is instead of forcing users to click on the “Assemble” button, just intercept each key stroke or just simply the “Enter” keystroke (end-of-line) and ran the assembler at that point.

Now, I am not suggesting that’s going to change people’s opinion about its uselessness (is that even a word?), but since this is about Ajax, and you’re already 90% there, you’re might just as well.

Comment by Kevin Hoang Le — April 9, 2007

it might come very handy for security related projects

Comment by pdp — April 9, 2007

I wish I had that much free time on my hands

Comment by Brad Harris — April 9, 2007

this would have been great in my computer architecture class last semester…i can see a good educational niche for this

Comment by ryan — April 9, 2007

The comment in the demo to the effect that ‘saving requires wscript’ is probably a clue to the purpose of this apparently ‘useless’ effort. :) The author is probably running the assembler through some kind of batch process on the desktop, outside of a browser. If the output of this process were to be an executable, then we’d have a program that was coded with assembler language, but ‘assembled’ using JavaScript. You’d have to admit that would be incredibly interesting, since the assembler would be easy to extend and customise, could be made very modular, and would probably be quite easy to understand, for programmers learning about such applications.

All speculation, of course, and hopefully the author will clarify sometime soon.

Regards,

Mark

Comment by Mark Birbeck — April 9, 2007

Hm… this has an obvious practical use: imagine you had a library with all opcodes of all processors… one could write ASM for x86 and a server could attempt writing the MAC counterpart for it. This would be very handy for certain parts of driver development, namely those parts that only access CPU and memory. Taking this bit further: one could have a lib of ASM snippets others could use for their own programming – I´d like a webservice like that.

Another possible use would be, that you can let the server simulate a CPU and run the program… x86 executables tested on a linux server… also one could use it to reengineer old code where only the .exe file exists and source code is lost.

This is very very cool.

Comment by Frank Thuerigen — April 9, 2007

… I’m speechless.

Uses: Web-based Assembler Education?

Comment by mdm-adph — April 9, 2007

“Can anyone think of practical uses?”

Yes, you can use it to learn x86 assembler without risking the hosing of your PC. It’s a terrific sandbox.

Comment by Joe Grossberg — April 9, 2007

I agree with mdm-adph & Joe Grossberg. This is the first that came to mind when I saw it. Seems pretty awesome.

Comment by Andy — April 9, 2007

I took a class last semester where we had to use a Java ASM so I can see a use for this in the academic world regarding the fundamentals of computer science.

Comment by Tharnid — April 9, 2007

And I thought April 1st was only one day long. :)

Comment by Nadav — April 10, 2007

:) so crazy I like it.

Comment by Mathieu 'p01' Henri — April 10, 2007

it might come very handy for secure

Comment by dankos — April 10, 2007

Like Why’s interactive Ruby shell.
http://tryruby.hobix.com/

PCs used to come with programming languages (ie BASIC) built in or shipped with the system, that’s how I and many other people here learned to program in the first place. In 2007, a modern windows install comes with gigs of bundled apps, but the tiny BASIC interpreter, which could be 50KB or less, doesn’t make the cut. For this reason, I’m glad to see these Ajaxy compilers making programming languages accessible to the masses again and hopefully they will flourish and yes I’m serious!!!

Comment by Michael Mahemoff — April 10, 2007

Hum, speaking about the masses, isn’t JavaScript 1 billion times more accessible and simple to learn than Assembly ? Every computer comes with a browser and a simple text editor. Although you still have debug.com ( that let you fiddle a bit with 80×86 assembly ) on Windows boxes, I’m not sure there is such thing on Mac OS, Linux, and other alternative OS.

Comment by Mathieu 'p01' Henri — April 10, 2007

The best part was the included vbs to save locally to the desktop in IE

Comment by drex — April 10, 2007

I got you all beat. My time-of-day web service is going to make me rich!!! :)

Comment by Michael — April 10, 2007

More proof that JavaScript is a nice doorway to other languages. Also see: http://vistasmalltalk.wordpress.com/2007/04/09/accessing-actionscript-from-lisp/ – LISP and Smalltalk in ActionScript.

Comment by Patrick Mueller — April 10, 2007

Maybe it could be used for a spellchecker. The author apparently needs one, “…correcting where nesseary (and yes, there is a lot of nessecity)”.

Comment by Chris Hiester — April 11, 2007

Mathieu, yeah I don’t think ASM is a good choice for new programmers. Just that having an ASM platform in the browser is an easy way to get started learning about it.

To learn JS, you don’t need a text editor either, just point to a website with a JS scratchpad. JS is probably an okay language for new programmers, though others are better IMO.

Comment by Michael Mahemoff — April 11, 2007

Leave a comment

You must be logged in to post a comment.