Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

uaecasher

macrumors 65816
Original poster
Jan 29, 2009
1,289
0
Stillwater, OK
Hello

I'm thinking of learning assembly and i was wondering is the assembly language in pc same as in a mac, and can anyone recommend me a book to start with. if there is a difference what is it

I'm new in programing so be easy on me :) thank you
 

Flynnstone

macrumors 65816
Feb 25, 2003
1,438
96
Cold beer land
Please don't take this as being rude. I only mean to help.

There is no such thing as "learning assembly"!

Assembly language is specific to particular processors.
PPC assembler doesn't work on an Intel processors. (Rosetta is crutch).
Imagine doing a big app in assembler for the PowerPC, then Apple offers Macs with Intel processors. It could happen ;) All the assembler code is close to useless.

The argument that assembler is faster is essentially wrong. Programmers are notorious for mistaking the code hot spots. Most often a better algorithm is a better solution. But with assembler it is likely too late, because so much has been invested.

So don't plan on making an app in assembler! Use C or something.

I think learning x86 is close to useless.

Now assembler coding can be fun. Start easy with a Microchip Pic or Freescale microcontrollers. Or Arm could be useful.
 

micsaund

macrumors 6502
May 31, 2004
364
0
Colorado, USA
I think learning x86 is close to useless.

Now assembler coding can be fun. Start easy with a Microchip Pic or Freescale microcontrollers. Or Arm could be useful.

Not to mention that x86 is so complicated with the modern OS interactions/etc. That's what's kept me from doing anything in x86 Winbloze-land, even though I grew-up doing 6502/etc. assembly.

I will second learning ARM or PIC. Both, especially the PIC, are small enough instruction sets that you can wrap your brain around it entirely and actually begin to take advantage of the hardware/etc. rather than just scraping the surface.

The PIC MPLAB software is free and integrated nicely with a simulator, so you could get programming without even owning a chip/programmer.

Mike
 

Cromulent

macrumors 604
Oct 2, 2006
6,817
1,102
The Land of Hope and Glory
Hello

I'm thinking of learning assembly and i was wondering is the assembly language in pc same as in a mac, and can anyone recommend me a book to start with. if there is a difference what is it

I'm new in programing so be easy on me :) thank you

The ABI is different between Mac OS X and Windows even though they use the same CPUs. Best bet is to read the FreeBSD Assembly resources. Although be warned, documentation is sparse.
 

Muncher

macrumors 65816
Apr 19, 2007
1,465
0
California
Please don't take this as being rude. I only mean to help.

There is no such thing as "learning assembly"!

Assembly language is specific to particular processors.
PPC assembler doesn't work on an Intel processors. (Rosetta is crutch).
Imagine doing a big app in assembler for the PowerPC, then Apple offers Macs with Intel processors. It could happen ;) All the assembler code is close to useless.

The argument that assembler is faster is essentially wrong. Programmers are notorious for mistaking the code hot spots. Most often a better algorithm is a better solution. But with assembler it is likely too late, because so much has been invested.

So don't plan on making an app in assembler! Use C or something.

I think learning x86 is close to useless.

Now assembler coding can be fun. Start easy with a Microchip Pic or Freescale microcontrollers. Or Arm could be useful.

Not to mention that x86 is so complicated with the modern OS interactions/etc. That's what's kept me from doing anything in x86 Winbloze-land, even though I grew-up doing 6502/etc. assembly.

I will second learning ARM or PIC. Both, especially the PIC, are small enough instruction sets that you can wrap your brain around it entirely and actually begin to take advantage of the hardware/etc. rather than just scraping the surface.

The PIC MPLAB software is free and integrated nicely with a simulator, so you could get programming without even owning a chip/programmer.

Mike

The first assembly language I learned was for the PICs too. It's really simple, but it can be kinda frustrating. Look here if you feel like trying that out.
 

ChrisA

macrumors G5
Jan 5, 2006
12,922
2,180
Redondo Beach, California
Please don't take this as being rude. I only mean to help.

There is no such thing as "learning assembly"!

Assembly language is specific to particular processors.
PPC assembler doesn't work on an Intel processors. (Rosetta is crutch).
Imagine doing a big app in assembler for the PowerPC, then Apple offers Macs with Intel processors. It could happen ;) All the assembler code is close to useless.

The argument that assembler is faster is essentially wrong. Programmers are notorious for mistaking the code hot spots. Most often a better algorithm is a better solution. But with assembler it is likely too late, because so much has been invested.

So don't plan on making an app in assembler! Use C or something.

I think learning x86 is close to useless.

Now assembler coding can be fun. Start easy with a Microchip Pic or Freescale microcontrollers. Or Arm could be useful.


Mostly you are right. You'd be nuts to write a big app in assembly. However it can be very useful to use asembly in some small areas of your code.

Sometimes you have to deal with hardware Be it an obscure register in the CPU or chipset or some special hardware device you bought or even built. And then you might have an inner loop that needs to run faster or with very predictable timing. I've used assembly in small amounts for all of these reasons. Some times it is the only way to access a specific machine instruction you want. The last time I needed assembly was to drive custom hardware. It was a camera and I was writing the code to stabilize the image on the sensor and move the image data through the a/D and into a disk file.

But mostly you don't need it much any more on PCs.

I have used assembly a lot on micro-controllers. These are little $2 computers that have maybe 1K or RAM.
 

Cromulent

macrumors 604
Oct 2, 2006
6,817
1,102
The Land of Hope and Glory
The first assembly language I learned was for the PICs too. It's really simple, but it can be kinda frustrating. Look here if you feel like trying that out.

I'm still trying to get my AVR Butterfly working :mad:. Seems like more hassle than it is worth on the Mac and I hate booting into Windows because I lose access to my e-mail and iTunes library.

If I thought a PIC worked well out of the box on the Mac I would snap one up in an instant.

As for the thread in question as I stated earlier the documentation on this is abysmal. Apple provide the odd document describing the Mac OS X ABI, but at the time I was looking they only provided the 32bit Intel ABI and not the updated 64bit ABI. The only other useful information I got was from FreeBSD dev sites and a little help from one of the NASM devs to get stuff assembling correctly using the mach-o binary format.

After about a week of frenzied Googling and reading the Intel CPU reference manuals (which by the way if you ever try and print will take about a week) I ended up with basically bugger all information. I'll probably look into again but I decided to learn assembly properly using micro controllers and then when I had a solid grasp of that I assumed it would be easier to make the jump up to 32 / 64 bit Intel ASM programming.
 

Cromulent

macrumors 604
Oct 2, 2006
6,817
1,102
The Land of Hope and Glory
well guys I don't want to learn assembly for making programs, I'm interested in reverse engineering

That's even harder. Disassembling applications does not leave you with easy to understand assembly.

You would still need to have a pretty good grasp of assembly anyway so basically at this point in time the advice is still applicable.
 

gnasher729

Suspended
Nov 25, 2005
17,980
5,566
well guys I don't want to learn assembly for making programs, I'm interested in reverse engineering

Write some small functions in XCode, and "Show Assembly Code" from the Build menu to see what the compiler does. Better do this in a Release build, not debug. And go to http://www.intel.com and look for their processor manuals.
 

LtRammstein

macrumors 6502a
Jun 20, 2006
570
0
Denver, CO
Find a language, like Motorola Freescale's assembly, and just learn it. It's the only way you can understand how assembly works.
 

hiddenpremise

macrumors regular
Assembly is a low level language and dates back to the 50's. Is there any particular reason that you want to learn it? If you are new to programming and want to learn to develop applications for the mac, check out any of the threads here about Objective-C. It is fairly easy to learn the basics and get started writing your own apps. If you don't want to try a C language, maybe try a scripting language like PHP or javascript to cut your teeth.
 

gnasher729

Suspended
Nov 25, 2005
17,980
5,566
Assembly is a low level language and dates back to the 50's. Is there any particular reason that you want to learn it? If you are new to programming and want to learn to develop applications for the mac, check out any of the threads here about Objective-C. It is fairly easy to learn the basics and get started writing your own apps. If you don't want to try a C language, maybe try a scripting language like PHP or javascript to cut your teeth.

For actual programming, assembly language is rather pointless except for very, very few special cases (if you write compilers or virtual machines, or you implement posix threads on a new machine, you better know assembler). On the other hand, if you like to know how things work, or if you read about new Nehalem processors and instead of believing Intel's marketing guys, you want to find out yourself, then knowing assembler is useful.
 

AUFan

macrumors newbie
Feb 2, 2008
27
0
I'm currently working on some assembly stuff and if you want to /need to learn IA-32 assembly, I've found this guy's book to be pretty good: http://kipirvine.com/asm/ It's one of the most straightforward programming textbooks I've read.
 

Muncher

macrumors 65816
Apr 19, 2007
1,465
0
California
For actual programming, assembly language is rather pointless except for very, very few special cases (if you write compilers or virtual machines, or you implement posix threads on a new machine, you better know assembler). On the other hand, if you like to know how things work, or if you read about new Nehalem processors and instead of believing Intel's marketing guys, you want to find out yourself, then knowing assembler is useful.

I wouldn't say pointless. Difficult for sure, and not for beginners, but useful if you need a small program. Besides, it's always good to know what's going on beneath all the shiny metal :D.

I'm still trying to get my AVR Butterfly working :mad:. Seems like more hassle than it is worth on the Mac and I hate booting into Windows because I lose access to my e-mail and iTunes library.

If I thought a PIC worked well out of the box on the Mac I would snap one up in an instant.

As for the thread in question as I stated earlier the documentation on this is abysmal. Apple provide the odd document describing the Mac OS X ABI, but at the time I was looking they only provided the 32bit Intel ABI and not the updated 64bit ABI. The only other useful information I got was from FreeBSD dev sites and a little help from one of the NASM devs to get stuff assembling correctly using the mach-o binary format.

After about a week of frenzied Googling and reading the Intel CPU reference manuals (which by the way if you ever try and print will take about a week) I ended up with basically bugger all information. I'll probably look into again but I decided to learn assembly properly using micro controllers and then when I had a solid grasp of that I assumed it would be easier to make the jump up to 32 / 64 bit Intel ASM programming.

Same, I would program more for the PIC if it was easier.

I tried looking at the Mach-o header format once; it was extremely confusing to me. I did get some useful info from here.

I did find one interesting project as I was googling around to find stuff about intel ASM: MenuetOS. It's an operating system coded entirely in assembler; if it's still an active project, I may try to learn assembler through it sometime.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.