"Hello, world" in Assembly.
asm.sourceforge.net
asm.sourceforge.net
This is no longer the case. While int 0x80 still works, this is not how well behaved binaries should syscall on Linux.
The proper way is to call a magic address on a magic page in own process space, which contains the proper code to do the system call. It will execute int 0x80 on CPUs that don't support sysenter/sysexit and sysenter on those that do.
The page (vdso) is inserted in all processes' address space by the kernel. Although its address is probably fixed, the proper way to find it is to examine the ELF auxilliary vector, which in turn is passed by the kernel via the initial process stack.
http://news.ycombinator.com/item?id=1662430
Yeah, I am jealous.
This is one of my favorite communities, but it's not exceptional in that regard.
That said, I like your link.
If I seriously want to learn about compilation, I'll just Google site:news.ycombinator.com compiler books, and grab the top recommendations.
Goodluck!
I wonder if spending some of your karma to the post would help. Though, I see no dearth of hackers here with a ton of karma, so it would have to be substantial "price" to make that worthwhile.
Mach-O is mach microkernel object format.
http://en.wikipedia.org/wiki/Mach-O
In general, BSD assembler tends to be pretty stack heavy for cultural/engineering reasons. I don't think it ultimately matters all that much if you're fiddling around on your personal machine.
I'm not sure I follow?
That's it. Simple. Now you can launch the hello program by entering ./hello. Look at the binary size -- surprised?
Without being able to compile the executable myself, is the binary surprisingly large or small? A few months ago, someone posted this article:
http://blog.ksplice.com/2010/03/libc-free-world/
Which leads me to believe that the executable is surprisingly large given the content. Am I understanding that correctly?
osx-box:dev esa$ nasm -f macho hello.asm && ld -e _start -o hello hello.o
osx-box:dev esa$ ls -lh hello*
-rwxr-xr-x 1 esa staff 8.1K Sep 5 22:43 hello
-rw-r--r-- 1 esa staff 721B Sep 5 22:39 hello.asm
-rw-r--r-- 1 esa staff 389B Sep 5 22:43 hello.oThe rest of int80h is also interesting, but is FreeBSD oriented. The site presents its own Hello World - http://www.int80h.org/bsdasm/#first-program
Edit: previously submitted - http://news.ycombinator.com/item?id=68056
http://labs.hoffmanlabs.com/node/1435
And if you're so inclined, there are (free) OpenVMS licenses for hobbyists, US$30 CD media kits, and (free) VAX hardware emulators for most any OS platform.
This is not the article I would use to learn about Linux, operating systems, or assembly (although it's more accurate to say you learn "an ISA" instead of "assembly").
[edit: clarification]
(I have a very strong personal preference for the Intel syntax.)
The comment about the lack of delimiters was not a value judgement; I was just pointing out one of the obvious signs that the article wasn't using AT&T syntax. I think that having to stick $ on immediate operands is particularly annoying, for instance.
I used to get tripped up by 'ln -s' all the time, until I realized that if I thought about 'cp src dst' but with 'cp' replaced 'cp' with 'ln -s' it suddenly made sense.
Likewise Intel assembly's mov statement and its similarity with assignment statements that barrkel mentioned.
Whether something seems intuitive or not depends on the analogy you prefer, or even your choice of words. E.g. look at 2D coordinates for a terminal character cell: if you think of them in terms of (x, y), you will find that order intuitive, but if you think (row, col), you'll find the opposite order intuitive.
i guess more remarkably, there is no timeliness to this article.
We're covering Hello World in my software dev. class on wednesday.