Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

assembly language on Mac OS X

I just purchased two books. The first is called "Write Great Code -- Volume 1: Understanding the Machine". It is not about assembly language in specific, just about understanding how computers work on a low level. The other is called "Assembly Language: Step-by-Step" by Jeff Duntemann. I've only read the introduction. It teaches assembly language for Intel-based computers (that's me!), but it also says that it's for DOS and Linux. However, I believe that the reason it says this is because it teaches using the NASM assembler, which, at the time this second edition of the book was published, was only available for DOS and Linux. However, they now have a Mac OS X version of NASM, and I've download it. So, here are my questions:

1.) Given the information I just gave about this book, I want to make sure that the information and code in it will apply to Mac OS X. It certainly sounds like it will, and I understand that there may be minor differences, but I just want to make sure that I'm in the right ballpark here by using this book.

2.) Since it teaches NASM, I'm assuming that NASM was the right assembler for me to download. I also just wanted to check and see if there's any other tools I should be downloading. The book mentions a NASM-IDE, but says that it's for DOS only. Is there anything else like this (or anything else at all) that I should obtain?

3.) Does NASM need to be installed? I went to the NASM website and downloaded the newest version (2.08rc1) for Mac OS X, and it unzipped in my Downloads folder. I've opened the folder and it's a bunch of files that I can't recognize (no install or app files in other words -- just files like rdf2bin, rdf2com, idrdf, and so forth). Is there anything else I need to do? Should I move this folder somewhere? What else do I need to do to get started here? Where would I write my code? How would I run the code? As of right now I have no idea where to go from here, and as you can tell I know nothing about how all this works. Maybe the book will tell me more when I get to the first code sample in the book, but it doesn't look like it, so I just wanted to ask for any information that anyone has time to give about anything relating to getting starting with assembly language and NASM on Mac OS X.

Thanks in advance for any help. I'd love to hear any input or recommendations on this subject, since it's something I really know nothing about, but you gotta start somewhere!

MacBook, Mac OS X (10.5.8)

Posted on Oct 15, 2009 4:38 AM

Reply
9 replies

Oct 15, 2009 5:16 AM in response to Tron55555

Okay, so I found a site to guide me through the installation of NASM on Mac OS X, and it said that 2.08rc1 is a "release candidate" (thus the "rc" part -- yeah, I'm not too sharp), and that I should have downloaded the newest version that didn't have "rc" in it, so I went back and downloaded 2.07. Unlike with 2.08rc1, there wasn't a folder on the website for a Mac OS X version, just DOS and Linux and Win32 and whatnot, but the site that was guiding me said to download the file called nasm-2.07.tar.bz2 (or something like that), so that's what I did. It then gave me instructions for configuring and installing NASM via the terminal, and it worked great! I've compiled and installed NASM, so I've gotten that far, but the rest of my questions in the previous post still apply. For example, I still want to make sure the book I bought will be applicable to assembly language on Mac OS X. Also, I'd like to know if there is anything else (like the NASM-IDE I mentioned in the above post) that I should download. And, finally, I still don't know where to go from here to get started with coding assembly language (I mean, for example, I think I read in my book that you write the code in a text editor -- is that right? How's that work?). Any further input on any of this or anything from the previous post above would be greatly appreciated. Thanks!

Oct 16, 2009 12:38 AM in response to etresoft

Awesome -- thanks for that, et. I would always prefer to do things from Xcode, so that's good to know -- hadn't even thought to check that. Also, thanks for the link, Tom -- I think it will be helpful. I guess that answers most my questions -- just a few things left I'd like to ask about:

Does anyone have any recommendation as far as using Xcode vs. NASM for assembly? For example, is one more appropriate for learning assembly? Or, for example, it might be a good idea to learn NASM for the sake of its use on other platforms down the line. Anything like that?

I guess that's it. If anyone has any further input, I'll be glad to hear it -- otherwise, thanks for your replies, and I'll wait a little then close this out.

Oct 16, 2009 8:22 AM in response to Tron55555

I say use the one you are most comfortable with and that you are most successful with. Personally, I would prefer to have this ability in Xcode. If you do get it running in Xcode, send me a copy of a sample project so I can create a template from it.

If you ever do get a chance to really use assembly in a real environment, it would probably be on some embedded platform with a proprietary development environment or an environment that "everyone else" is using. So I don't think it really matters.

Correction, I think Xcode would be best. Get something running in NASM and then port it to Xcode. You will learn more about both assembly and Xcode in the process and there is nothing wrong with that.

Oct 17, 2009 3:39 AM in response to etresoft

I say use the one you are most comfortable with and that you are most successful with. Personally, I would prefer to have this ability in Xcode. If you do get it running in Xcode, send me a copy of a sample project so I can create a template from it.


Okay -- I'll do that.

Correction, I think Xcode would be best. Get something running in NASM and then port it to Xcode. You will learn more about both assembly and Xcode in the process and there is nothing wrong with that.


How would I port it to Xcode? I think I need to understand a little more about assembly language before I get into this too much, but are talking about just writing a program in NASM and then copying the code into Xcode, or something else? I checked the man pages for GCC and I found out it uses the .s or .S file type for assembly code. Would I just open Xcode and start an empty project and then create a .s file? Any advice?

Oct 17, 2009 1:19 PM in response to Tron55555

Tron55555 wrote:
How would I port it to Xcode?


Via trail and error.

I think I need to understand a little more about assembly language before I get into this too much


Why? Jump in. You won't anything.

are talking about just writing a program in NASM and then copying the code into Xcode


Yes, more or less. You will have to identify those things that are NASM-specific and change them to what Xcode wants.

Would I just open Xcode and start an empty project and then create a .s file?


Maybe start with a basic C command line tool. Then implement a function in assembly and add an assembly file and call that function from C. Getting linked to the OS runtime support code to build a runnable application is the hardest part about assembly. And really, you don't ever have to do that. Let C do the heavy lifting for now.

Oct 18, 2009 12:26 AM in response to etresoft

medels -- great links. I've bookmarked all of them, so thank you.

etresoft wrote:
Yes, more or less. You will have to identify those things that are NASM-specific and change them to what Xcode wants.


Yeah okay -- that makes sense.

Maybe start with a basic C command line tool. Then implement a function in assembly and add an assembly file and call that function from C. Getting linked to the OS runtime support code to build a runnable application is the hardest part about assembly. And really, you don't ever have to do that. Let C do the heavy lifting for now.


Alright, I'm looking forward to giving this a go. I'll let you know how it goes when I do. Thanks again.

assembly language on Mac OS X

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.