tags:

views:

277

answers:

5

I am on a Mac with Snow Leopard (10.6.3). I hear that the assembly language I work with has to be valid with the chipset that you use. I am completely new to this I have a basic background in C and Objective-C programming and an almost strong background in PHP. I have always wanted to see what assembly is all about.

The tutorial I'll be looking at is by VTC [link].

What I want to know is: are the tutorials that I'm about to do compatible with the assembly version on the Mac that I have?

Sorry I am completely new to this language although I do recall studying some of it way, way back in the day. I do have xcode and what I'm wondering is what kind of document would I open in xcode to work with assembly and does the Mac have a built in hex editor (when it comes time to needing it)?

thanks

A: 

An assembly language is instruction architecture specific. Chips are an instantiation of an instruction architecture.

In my opinion, you are best served by getting TextWrangler and directly compiling with gcc.

The file extension you are looking for is .s.

Paul Nathan
Earlz
Paul Nathan
@Paul by "less used" I mean "less written by hand" the `GNU as` syntax was optimized and designed to be generated by the compiler. This is also why `GNU as` has notoriously horrible error handling and detection. It is use to perfect code from GCC. This alone is a reason why I don't recommend it for a beginner
Earlz
Paul Nathan
Earlz
@Earlz:Those "many people" you're talking about must be insane.
slacker
+5  A: 

The assembly language you use is not dependent on your OS but rather your CPU's instruction set. Judging by your Mac version, I'd say you are using an Intel processor - so you would want to learn x86 or amd64 assembly.

George Edison
Personally, I find x86 to be easier. Plus there is a lot more info about x86 at this point than amd64
Earlz
This is a bit misleading--the language is by CPU, but the system calls are different across platforms, so tutorials for Linux won't work for Mac, for instance (and Mac system calls are not very well-documented).
eman
True - but consider this: Mac OSX is Unix-based.
George Edison
@George Edison: Yes, it's Unix-based, but very different from Linux (it may be similar to BSD, but I'm not sure). Having tried to follow various Linux tutorials on a Mac, it can be very frustrating, since even the most basic calls aren't the same. Also, Apple tends to heavily discourage using system calls directly, so there's no real documentation on them. It's probably easier to install a Linux VM and learn x86 assembly through that.
eman
Agreed. Certainly Mac isn't the optimal platform for assembly learning.
George Edison
A: 

Assembly, for any processor, will be more or less the same in concept. However, the complexity varies between processors. From what I see in your site, you'd be doing x86 assembler, (x86 being the instruction set all consumer-line Intel processors use, which recent Macs and all PCs use) which can turn out to be fairly complex, but not overwhelming if you learn by steps.

XCode works with plain text files, I believe. Hex Fiend for your hex editing needs, if you come across them.

Do keep in mind, Assembly is extremely low-level. No ifs, whiles, or in fact any control loop save for "do operation and GOTO if results in (not) zero/equal" (unless your assembler provides them as syntactic sugar, which kind of beats the purpose, in my opinion). PHP knowledge will be at most tangentially useful. You C knowledge should serve you well, though.

Kyte
You can get `ifs` and `whiles` by using macros.
George Edison
Indeed. "[...] as syntactic sugar, which kind of beats the purpose, in my opinion."
Kyte
A: 

A good way to pick up assembly is to get yourself an embedded device to play with.

TI has some nice, inexpensive devkits to play with. I've poked around with the Chronos kit ($50) which has digital watch with a programmable MSP430 microcontroller with a wireless link to your computer. It's pretty sweet.

Update: I forgot to mention the Arduino. It's a pretty nifty open platform with tons of interesting peripherals and projects online.

daotoad
A: 

The linked tutorials look like they use NASM, which is included with Macs. However, system calls are usually different on different platforms (they're very different between Mac and Linux), and without seeing the tutorials, it's hard to know whether they'll target different platforms (I'd guess not, though). A better bet might be to install SPIM and to learn MIPS assembly, which is more straightforward than x86 anyways.

eman