Slashdot Mirror


x86 Assembler JWASM Hits Stable Release

Odoital writes "January 2010 is an exciting month for x86 assembly language developers. Software developer Andreas Grech, better known to the x86 assembly language community and the rest of the world by his handle "japheth," has released another version of JWASM — a steadily growing fork of the Open Watcom (WASM) assembler. The main benefit of JWASM, arguably, is the nearly full support of Microsoft's Macro Assembler (MASM) syntax. As those in the assembly language community may already know, Microsoft's desire to continually support the development of MASM has been dwindling over the years — if only measurable by a decreasing lack of interest, updates and bug fixes — and thus the future of MASM remains uncertain. While Intel-style syntax x86 assemblers such as NASM have been around for a while, JWASM opens up a new possibility to those familiar with MASM-style syntax to develop in the domains (i.e. other than Windows) in which assemblers such as NASM currently thrive. JWASM is a welcomed tool that supplements the entire x86 assembly language community and will hopefully, in time, generate new low-level interests and solutions."

39 of 209 comments (clear)

  1. Just for some perspective... by tjstork · · Score: 5, Interesting

    To know how abandoned MASM really is... try and make an assembler project in 64 bit under Visual Studio 2008. It's not even supported out of the box - like, they never actually tested the configuration.

    But, for all that, I prefer YASM as the assembler. Still, congrats to the OpenWatcom port.. NICE WORK. It's always good to have more hands in an area that so many people see as dead.

    --
    This is my sig.
    1. Re:Just for some perspective... by onionman · · Score: 3, Informative

      I'm also a big YASM fan. YASM can generate object files for Windows, OS X, and Linux. That, combined with its macro features, let you write a single x86 file that can be used on all three platforms.

      I'll certainly take a look at JWASM, though!

  2. xor my heart by RabidOverYou · · Score: 4, Interesting

    I loved saying in an interview "I see you have x86 assembler on your resume". The color drains from the kid's face, I give 'em a snippet:

    cwd
    xor ax,dx
    sub ax,dx

    It's nothing rocket, just some fun with 2s-complement.

    -- Rabid

    1. Re:xor my heart by mparker762 · · Score: 2, Informative

      No, that snippet compares AL and DX, leaving AX with 1's everywhere except the first different bit, which will hold a 0.

      Ex:
      AL= 00001101
      DX= 00000010 00011001

      CWD just puts a 0 in AH
      AX= 00000000 00001101
      DX= 00000010 00011001

      XOR ax,dx computes ax ^= dx
      AX=00000010 00010100
      DX unchanged

      SUB ax,dx computes ax -= dx
      AX=1111111111111011
      DX unchanged

      The XOR swap algorithm to swap ax and dx is:
      xor ax,dx
      xor dx,ax
      xor ax,dx

    2. Re:xor my heart by onionman · · Score: 3, Informative

      I believe it sets dx to the MSb of ax and ends up leaving ax unchanged.

      oops! I guess I'm getting my AT&T syntax and my Intel syntax confused. If it's Intel syntax, then:

      cdw ;; copy MSb of ax to all bits of dx
      xor ax, dx ;; if MSb of ax was 1 then flip bits of ax, otherwise, no effect
      sub ax, dx ;; if MSb was originally 1, this will add 1 to the flipped bits. otherwise, no effect

      So, assuming Intel syntax, this computes to absolute value of ax and sets all the bits of dx to be the sign bit

    3. Re:xor my heart by Rockoon · · Score: 2, Informative

      cwd isnt obscure.. well, it wasnt in the 16-bit days.

      The modern equivalent in 32-bit mode is cdq ..

      These is absolutely necessary instruction when performing division, because on the x86 line division takes a double wide numerator from dx:ax in 16-bit, or edx:eax in 32-bit.

      --
      "His name was James Damore."
    4. Re:xor my heart by TheRaven64 · · Score: 2, Interesting

      Do you hire people who need to know obscure bits of x86 asm often, or is this just a way of catching people who exaggerate on their CVs?

      --
      I am TheRaven on Soylent News
    5. Re:xor my heart by P-Nuts · · Score: 2, Informative

      Don't think that's quite right. As I said in my other reply, I had to look up CWD in the Instruction Set Reference:

      The CWD instruction copies the sign (bit 15) of the value in the AX register into every bit position in the DX register.

      So this means if AX was originally positive, nothing happens, and if AX was originally negative the XOR flips the bits of AX, then the SUB subtracts minus one from it (which is the same as adding one). This is the same as the two's complement unary minus operation. So the snippet computes the absolute value of AX, and stores the result in AX.

    6. Re:xor my heart by clone53421 · · Score: 2, Informative

      the absolute value of your original AX

      Come to think of it, that’s just in AX. DX contains the sign of AX.

      I.e. it’s this, in terms of pseudo-code:
      DX = sign(AX)
      AX = abs(AX)

      --
      Alexander Peter Kristopeit bought his basement from his mommy for one dollar.
    7. Re:xor my heart by RicktheBrick · · Score: 2, Interesting

      In the year 1973 I was employed by a company called Cascade Data. It was located in Cascade Michigan which was close to Grand Rapids. I was a computer programmer at the time. They manufactured computers that started with 16k bytes of magnetic core memory and could be double to 32k. They had a 5 Megabyte hard drive but most used a tape drive for storage. Input was from a typewriter like device as one would type in on a keyboard and the output was on paper. I wrote programs in both RPG and assembly languages. The computer was an eight bit processor so the registers were eight bits. This meant that the maximum number that a register could hold was 255. Just adding two numbers was fun since one would have to do add the least significant byte of one to its least significant byte of the other and than check for overflow and continue with the next byte. There were no multiply or divide instruction. To multiple 19 times 20 one would add 19 to a register 20 times. To divide 200 by 20 one would subtract 20 from 200 until one got a zero or negative number. It was not that much fun to program in assembly language but your program always took about half the memory that a RPG program did and with only 16k bytes of memory on some system, some programs just needed to be written in assembly. Unfortunately for me the company did not last very long as I was employed for only 6 months. The country fell into another recession and I got tired of looking for work so I went into the military. Today a 64 bit register will hold a number of 1.84 X 10 raised to the 19th power or at least 18 significant bytes so even the national debt would fit into one register. So it must be a little bit easier to program today than it was in 1973. After, I was asked to modify a existing program by one of their customers. They gave me two big boxes of computer cards and a printout of the program. I had to find the place where I wanted to modify the program and remove and replace the cards I needed to. Unfortunately two of the cards got interchanged and some time was spent troubleshooting it to locate the problem. I can only laugh when I think about it and how much easier it is today.

    8. Re:xor my heart by elnyka · · Score: 2, Insightful

      ... plus a person willing to put "Assembly" in the resumes should be aware that it implies dexterity with binary arithmetic, bitwise ops, 2-s complements and all of that good shit.

  3. Japheth's Other Projects! by Anonymous Coward · · Score: 2, Informative

    Japheth has a number of rather interesting projects that extend the functionality of DOS.

    JEMM, which is his EMM386 replacement: http://www.japheth.de/Jemm.html
    HX DOS Extender, which adds Win32 PE & basic API support to DOS to allow the execution of a whole array of apps: http://www.japheth.de/HX.html

    1. Re:Japheth's Other Projects! by glwtta · · Score: 5, Funny

      Japheth has a number of rather interesting projects that extend the functionality of DOS.

      Awesome, I'm always on the lookout for cool stuff like this to keep my DOS workstation cutting edge.

      --
      sic transit gloria mundi
  4. Who needs JWASM? by Colin+Smith · · Score: 2, Funny

    We have Java!

     

    --
    Deleted
  5. An exciting month for who? by Anonymous Coward · · Score: 5, Funny

    January 2010 is an exciting month for x86 assembly language developers.

    I'm sure the two of them will be pleased.

    1. Re:An exciting month for who? by Chapter80 · · Score: 2, Funny

      The first thing I'm going to do with this new assembler is to write a C compiler, and then write Python in C, and then I can get down to work...

  6. Programming from the Ground Up by omar.sahal · · Score: 3, Informative
    Or you could use gcc

    Programming from the Ground Up

    I highly recommend working through this book even if you'll never program assembly again... you'll be a vastly better programmer. -- Joel Spolsky, JoelOnSoftware.com

  7. I'll ask it by jgtg32a · · Score: 2, Interesting

    What's the difference between all of these different Assemblers? Aren't they all just x86, AMD64, or IA32

    1. Re:I'll ask it by TheRaven64 · · Score: 4, Informative

      The big difference is the syntax. Microsoft's assembler uses Intel syntax, while the GNU assembler uses AT&T syntax. The order of operands is different, the syntax for the different addressing modes is different, and instructions have operand size suffixes in AT&T syntax. Beyond that, there are differences in the types and flexibility of the macro system. GNU assembler, for example, uses the C preprocessor for macros, which sucks for C and is even worse for anything else. Other assemblers have complex macro languages.

      --
      I am TheRaven on Soylent News
  8. Watcom, I cry for thee. by Anonymous Coward · · Score: 5, Interesting

    I still weep slightly when I think of Watcom and their products. They were, by far, among the best out there in the 1980s and early 1990s. I mean, they made Borland's offerings look like garbage, and Borland was pretty damn good at that time, too.

    Their assembler and C and C++ compilers were fucking amazing. Nobody generated faster code than them. I remember once moving some code from Microsoft's C++ compiler to Borland C++, and getting a 5 times speedup. Then we moved it from Borland C++ to Watcom C++, and got an additional 8 times speed improvement! We were totally blown away. Their code generator was just that much better than that of much larger competitors.

    Watcom SQL was another gem. So much faster than the competition, but also so much easier to use and develop for. It's good to know that Sybase has kept this product alive and well.

    To see such a small shop create some high-quality products is truly a testament to the fantastic talent that they had working there. It saddened me greatly to see them consumed by Powersoft, and then Sybase.

  9. Hey that's great by Weaselmancer · · Score: 4, Funny

    Let's write some nVidia drivers in Java!

    --
    Weaselmancer
    rediculous.
  10. why? by Lord+Ender · · Score: 3, Interesting

    What is primary use of assembly these days? I thought C gave you the same level of control, but with portability and much-improved readability.

    And to give you an idea of where this question is coming from, the last app I wrote was a web app runs in JRuby, using DataMapper to free me from dealing with SQL and Sinatra to free me from dealing with HTTP/CGI. It runs on the Google App Engine cloud. My world is so high-level, with so many layers of virtualization and encapsulation, that I can barely see assembly way down there at the bottom of the stack...

    --
    A slashdotter who didn't build his own computer is like a Jedi who didn't build his own lightsaber.
    1. Re:why? by Anonymous Coward · · Score: 4, Insightful

      And this is precisely why Facebook requires 30,000 servers.

    2. Re:why? by Anonymous Coward · · Score: 4, Informative

      Not quite. There are always situations when writing an operating system where you need assembly. For example, impelmenting the actual 'guts' of a context switch requires fine tuned control over what is in each register.

      (C programs tend to assume the stack is available. But in the middle of a context switch, it might not. Assembly gives that level of control).

    3. Re:why? by TheRaven64 · · Score: 4, Informative

      Bits of the C standard library too. You can't implement setjmp() or longjmp() in C, while they're pretty trivial in assembly. Various other functions (e.g. most of math.h) will probably be faster with some inline assembly too, although these days compilers tend to provide built in versions of these functions that you can call and have them replaced with a single instruction.

      --
      I am TheRaven on Soylent News
    4. Re:why? by mick232 · · Score: 2, Informative

      And this is precisely why Facebook requires 30,000 servers.

      They might need 30.000 servers, but at least they don't need 30.000 programmers and another 30.000 testers.

  11. Re:And how does it differ ? by EvanED · · Score: 5, Informative

    And how does its syntax differs from NASM and AT&T ?

    Intel syntax doesn't feel like it was designed by a sadist.

    More seriously, this site link covers some differences. Among the things I like much more about Intel syntax: there's no need to add a ton of visual noise with what-should-be-extraneous $ and % symbols, and things like memory indirection is much easier to learn. Compare "[ebx+ecx*4h-20h]" to "-0x20(%ebx,%ecx,0x4)"; the former almost tells you what it does even if you're not at all familiar with the syntax, the latter definitely doesn't.

    The main benefit that AT&T syntax has is that they "hungarian notation" their instructions: movb works on 1 byte, movw on 2 bytes, movl on 4. Most of the time this is extra visual noise (I don't need the 'l' to tell me that 'mov eax, ebx' works on 4 bytes), but it does make memory dereferences more concise. With Intel syntax you'll get a lot of 'dword ptr' stuff lying around to tell how much should be brought in from memory.

  12. Re:And how does it differ ? by EvanED · · Score: 2, Informative

    To answer your other question about benefits, most of the benefit comes from your toolchain. If you're using a toolchain that is designed to work with AT&T syntax, like GCC, then no, there's no benefit. If you want to interoperate with MSVC, there's a ton of benefit. (In particular, if you want to use inline asm in a MSVC program, it uses Intel syntax.)

  13. Wikiwars by SarekOfVulcan · · Score: 5, Informative

    Be warned -- JWASM's Wikipedia article was nominated for deletion, as it was thought that notability was not sufficiently asserted. The flame war there might spill over here as well. :-(

    1. Re:Wikiwars by Just+Some+Guy · · Score: 5, Insightful

      Be warned -- JWASM's Wikipedia article was nominated for deletion

      And that right there's why I won't donate a penny to that project. Honestly, WTF? That article's source is about 13KB long. At $100/TB, it costs about 1/7800th of a penny to store. "But what if it clutters up the site!", say the Deletionists. Apparently there's an alternate front page to Wikipedia that lists every single article and it's critical that it be kept tidy and short.

      Actually, I take that back: can I send Wikipedia a penny and sponsor a few thousand articles of my choosing, starting with this one?

      --
      Dewey, what part of this looks like authorities should be involved?
    2. Re:Wikiwars by stupido · · Score: 2, Interesting

      "Deleted" articles don't get deleted from the Wikipedia database at all. They just get hidden from the public. An administrator can undelete them at any time. So, there's no monetary saving involved. Arguably, plain spam should be removed from the site, but JWASM is obviously not that. It is even discussed in Fog Agner's book, which normally meets the requirements for a Wikipedia article. See my post above. I can't be bothered to read the insanely long deletion discussion to see why that's not enough for them. What's more funny is that they now argue that having a Slashdot story doesn't matter because popularity is not the same as "notability". Go figure.

    3. Re:Wikiwars by BikeHelmet · · Score: 4, Interesting

      Articles about old hardware often get deleted too. Socket A motherboards and stuff. I've seen articles on older cellphone SoCs and their companies vanish as well. Apparently never getting large and then finally going out of business means you don't deserve to be noted in history.

    4. Re:Wikiwars by Just+Some+Guy · · Score: 3, Insightful

      we wouldn't want an article on every person ever lived

      Why? Say that's 10 billion people, and each article is 10KB. That comes out to 100TB and a modest database to reference it all. In 2010 technology, I could afford to buy and run that hardware out of my basement if I really wanted to. Keep in mind that hosting 10G articles is a lot different from serving that many.

      As long as it doesn't bog down the search engine, is there any practical reason to care? Especially when instead of 10G articles, we're talking about something on the order of 1 million.

      --
      Dewey, what part of this looks like authorities should be involved?
  14. LLVM by eulernet · · Score: 2, Informative

    Frankly, optimizing assembly code is a PITA, since there are so much different flavors.
    For example, AMD and Intel processors have different types of optimization.

    If I were to code in assembly nowadays, I'd prefer to use something like LLVM: http://llvm.org/ which should be able to generate good optimized code for any kind of processors, without the hassle of maintaining one routine per processor.

    In some very extreme cases (like coding a RC5 decoder or multiprecision routines), it's still useful to use assembler, but in most other cases, I'm sure that LLVM is able to generate code much better than you could achieve manually in the same amount of time.

  15. That's good news by bl8n8r · · Score: 2, Interesting

    pusha
    msg db 'Because I kinda like assembly.$'
    mov ax, seg msg
    mov ds, ax
    mov ah, 9
    int 21h
    popa
    mov ax, 4c00h
    int 21h
    nop

    --
    boycott slashdot February 10th - 17th check out: altSlashdot.org
    1. Re:That's good news by clone53421 · · Score: 3, Insightful

      You forgot to jump around your message, or put it at the end, or use segments to tell the assembler to do that automatically.

      --
      Alexander Peter Kristopeit bought his basement from his mommy for one dollar.
  16. IDA Pro by mpsmps · · Score: 2, Interesting

    It's far from cheap (let alone free) and it's not an assembler, but IDA Pro is indispensible for anyone who needs to develop, analyze, or debug code in assembler. It can't assemble code for you but it does everything else ( http://www.hex-rays.com/idapro/pix/idalarge.gif) you've thought of and many you haven't.

  17. not needed for MMX anymore by stevenj · · Score: 3, Insightful

    You can use compiler builtins for SIMD these days (fairly standardized across Intel, GNU, etc. compilers). (And don't complain about portability if you are using hand-coded SIMD....you have to be using #ifdefs or something anyway.)

    Aside from using specialized instructions that are usually accessible from C anyway via builtins, it's not like x86 assembly has much relationship anymore to what actually happens in the hardware; you can't even control the real registers anymore (most CPUs have many more physical registers than are exposed in the instruction set, and rename on the fly).

    Besides, most useful optimizations are much higher-level than that (besides the obvious question of algorithm choices, performance is typically dominated by memory access and you are better off focusing on locality than instruction-level efficiency).

    --
    If a thing is not diminished by being shared, it is not rightly owned if it is only owned & not shared. S. Augustine
  18. jello stacking by epine · · Score: 3, Interesting

    I never got a five times speedup over Microsoft, but we consistently got 30% reduction in code size, which on a 640KB machine is not to be sneezed at. A big part of that was the excellent register calling conventions and pragma support.

    The reality is that Watcom C++ was crushed by Microsoft Visual C++ which had a slick interface lashed onto appalling C++ language support. This was an era when anything slapped in a box was saleable software.

    People forget that before eyeballs displaced profit, fatuousness displaced quality. It didn't matter very much if the feature worked as advertised. Software users, like deluded sports fans, believed that hope springs eternal. Maybe it would work in the next version? Sadly, programmers fell for the hype just as often as the end consumers. RIP Watcom.

    The day Watcom packed it in—effectively about a version before their last release—I knew that quality had lost the race for many years to come. I didn't have it in me for a career in jello stacking, so I went off for a while to do my own thing. These days, quality is back on the table, for jobs that no longer exist. But if they did, it would be good times again.

    Bill Watterson really knew what he was doing when he drew all those snowmen in the first half of the 1990s.