Hacker News new | past | comments | ask | show | jobs | submit login
Nasm – A cross-platform x86 assembler with an Intel-like syntax (github.com/netwide-assembler)
67 points by maydemir on Jan 27, 2022 | hide | past | favorite | 39 comments



There is also yasm https://github.com/yasm/yasm which has different goals but doesn't seem to be that active anymore.


IIRC yasm was (is?) also compatible with GNU/AT&T syntax. I remember submitting either a bug report or patch years ago related to that.


Would you happen to know the authors of yasm felt the need to completely rewrite nasm? It's always been confusing to me.


Looking at it not very deeply, seems like yasm is more of a library with a command line frontend, and whereas nasm is built like a program.


Thank you, that's a reason at least.


Alsi it has more debugging formats


It seems to me like they're saying the library approach makes it easier to add features. So there would be one example of more features.


I think the main reason is for supporting both AT&T and Intel syntax at the same time.


Another thing to consider is FASM (Flat Assembler): https://flatassembler.net/

If someone can build FASM 1 for 64-bit MacOS, it would be great.


> FASM 1 If you wanted FASM g for arm(apple silicon) or something that might be much more achievable. FASM g was designed to be much more multiplatform.

EDIT: looking it up it looks like someone has done some work for that: http://arm.flatassembler.net/


I switched to FASM when I started playing with MenuetOS [1] years ago. I like FASM, and the community was very helpful then.

I started with 6502 assembly back in the 80s, and assembly for 8-bit micros in the 90s. I left assembly until just 4 years ago, and then I started playing with it again for boot sector games because of Oscar Toledo Gutierrez's book, 'Programming Boot Sector Games', for fun. Now there's, 'More Boot Sector Games'.

I was a Commodore PET 2001, Vic-20, Amiga 1000, Amiga 500, and Apple PowerPC user back in the day (1978 to 1997), but it looks like DOS/Gates has won; here I am spending my free time trying to create games for DOS!

NOTE: Legacy boot mode was taken out of Windows around 2019/2020, so you will need an older computer if you want to boot it off of a USB stick. Or you could just use a DOS emulator.

[1] http://menuetos.net/


> If someone can build FASM 1 for 64-bit MacOS, it would be great.

It's written in 32-bit x86 assembly, so that's unlikely.


It's worth noting that fasm is written in itself, and thus self-assembling.


Fantastic tool for compiling x86 assembly code but I've grown to like GNU gas and its at&t syntax. Which do you prefer?


Intel. I can't bring myself to learn this:

    movl mem_location(%ebx,%ecx,4), %eax
on any architecture where assemblers also support this:

    mov eax, [ebx + ecx*4 + mem_location]


Agreed. I like `mov %src, dst` more than `mov [dst], src`, but GAS's `seg:disp(base, index, scale)` is insanity compared to Intel syntax.


Would you agree that it makes more sense though? I tend to agree with you, I _want_ to write 'mv src, dst', but the other way around has some strong supporting reasons:

- it's closer to the usual pseudo assembly "eax <- ebx"

- it's closer to the mathematical "A = B"

- on a more practical side, it's what was adopter by C standard library "memcpy(dst, src)"

Thinking about it, there are more reasons to favor 'mov dst, src'. I think the culprit (at least for me) is that I cannot "pronounce" it correctly in my head. I have to use some peripheral sentence such as "move in dst the contents of src" instead of the more natural (but backward from the reading perspective) "move src to dst"


Nitpickery, but in the mathematical notation A = B is not an assignment (and is exactly the same as B = A).

Assignment is more clearly written as A := B, but I never saw this as a maths thing, but as a programming convention.


Either works for me, I'm easy. Besides I cut my teeth on m68k and x86, and I do like how it keeps it easy with things like mov.b, mov.w and mov.l - keeps things clear what you're working with.


Does

movl mem(%ebx + %ecx + 4), %ecx

also work? If so that would read better than with the commas.

(Sorry, can't quite recall how to get code snippet markup to work)


Intel, I ported my toy compiler Assembly generation from Intel to AT&T back when it wasn't yet supported on gas, never again.


Intel is much more intuitive than At&t's (if at all)


In case anyone doesn't know, gas supports Intel syntax now.


Last time I read about it, the support was only partial, but I cannot remember the details.


I wrote a robust-ish bootloader and didn't notice anything missing. It's only the macro/prelude code that differs but that does among all assemblers.


Intel. AT&T is immoral.


Why?




As much as I like this, how is Nasm news? Fine. I have not done enough assembly lately, fair enough.

More seriously, is anyone still doing this outside of edge computing and embedded applications? Or… a hobby?


I had to use a bit of assembly recently and chose nasm for it. A client had an older piece of compiled code and wanted to be able to use it on a modern machine. It was written in a propriety language and compiled for a 32bit system. The argument passing conventions used by the compiler were unusual. So I wrote a bit of assembly in nasm to create a stub function callable from C, it was really just moving things into the right registers and some bits to the stack. So nothing really being done in the asm. The hard part was figuring out the calling convention.

Edit: Looking back it turns out that "recently" was 18 months ago.


I'm starting to learn reverse engineering and while doing that I have had to read a bunch of assembly but also write a small amount too. I don't use NASM and am only writing a few instructions at a time, mainly either updating an existing instruction or replacing an instruction with one or more that are the same size


Nasm was news at a time when it would make sense to call an open source project the netwide something.

For this I just remind myself that every year there are people younger than me who are getting their start in these topics and this is their first time hearing about nasm. That's ok.


At my job we use nasm to assemble the x86 entry points for our OS kernel. Any assembler would do the job - someone before me just happened to pick nasm.


I use Nasm to learn assembly, so I can reverse engineer disassembled programs.

You'll see OS kernel developers use it, but those projects are often for educational or recreational purposes.

And it's not news it's 25 years old.


Only as a part of learning OS kernel development, which is another hobby. We mobile app developers practically have no use of assembly code.


People have to develop for computers without an OS. They get paid to do it.


nasm SDK is really scary: tons of tough-to-read perl scripts for code generation. I would stay away from it, but nasm is used in ffmpeg. I prefer to use fasm instead, even though its extremely powerful macro language is an invite for abuse.


I used it for one of my recent projects - good stuff!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: