Assembly For My Mac

Jordan
Unregistered
 
Post: #1
As strange as it may seem to some, I am interested in learing some assembly language for my iBook G4. The documentation provided with XCode is difficult for someone who knows next to nothing about assembly language and processor terminology.

I just bought an excellent book called: THE DEFINITIVE GUIDE TO HOW COMPUTERS DO MATH, FEATURING THE VIRTUAL DIY CALCULATOR. I have to say it is on the top three list of best written computer programming books I've come across, but I'm memorizing functions for a virtual computer, instead of investing time with the computer I love.

Where can I find a good beginner book on Assembly for the Mac?
Quote this message in a reply
Moderator
Posts: 3,570
Joined: 2003.06
Post: #2
Learning assembly on the PPC isn't a very popular endeavor and there aren't many books on it. Optimizing PowerPC Code by Gary Kacmarcik is still the only one I know of besides some online resources. You can also download the Motorola and IBM PowerPC manuals. Assembly programming on the Mac is mostly a waste of time nowadays if you ask me unless you're really pushing the limits of your curiosity. With the newer Macs coming out with Intel processors soon there is even more reason NOT to learn PPC assembly now. That said, here's a good link:

http://www.lightsoft.co.uk/Fantasm/Begin...egin1.html
Quote this message in a reply
Founder
Posts: 1,138
Joined: 2002.04
Post: #3
>With the newer Macs coming out with Intel processors soon there is even more reason >NOT to learn PPC assembly now
That is what crossed my mind as well.

BTW, Fantasm (PPC assemler) was open sourced long ago but I don't think it made it to modern Mac OS X version.
http://www.lightsoft.co.uk/Fantasm/fant.html

>Learning assembly on the PPC isn't a very popular endeavor
Actually, I think would be true for desktop machines that use PPC, while the embedded market surely has a need for PPC coders, since PPC chips are in many many devices. (Well, last time I read.) You might want to look at Motorola or IBM's PPC pages for added info.

BTW, I was wondering if the learning curve would be a bit easier by learning ASM on an 8-bit emulator, for a chip like the 6809. Smile Maybe even Z80 or whatever those old arcade machines once used. Smile

Cheers,

Carlos A. Camacho,
Founder
iDevGames
Quote this message in a reply
Moderator
Posts: 3,570
Joined: 2003.06
Post: #4
Carlos Camacho Wrote:...the embedded market surely has a need for PPC coders, since PPC chips are in many many devices. (Well, last time I read.)
That's a good point. The same could be said for learning assembly for other microcontrollers like the popular pic or maybe even some usb microcontrollers. Probably more than a trivial task to do that from the confines of a Mac though since most electronics interfacing hardware and programming software is made for WinTel.
Quote this message in a reply
Member
Posts: 260
Joined: 2005.05
Post: #5
Carlos Camacho Wrote:BTW, I was wondering if the learning curve would be a bit easier by learning ASM on an 8-bit emulator, for a chip like the 6809. Smile Maybe even Z80 or whatever those old arcade machines once used. Smile
I say yes. I used to program a lot in 6809 (entire games) and 68000 assembler (optimized blitters), and even touched upon Z80. 6809 was nice and easy. Z80 was far worse. 68000 quite OK.

A few years ago, I tried learning PPC assembler, because I wanted to write my own code generator. It was like a brick wall in comparison. It was obvious to me that 6809 and 68000 were designed to be human programmable on low level, while the PPC is ment to be optimized by machine and programmed in a higher-level language.

Taste varies, but I'd say that you will have a much better time with 6809 or 68000. Go for 68000, pick up an old 68k Mac, find some assembler, or C compiler that supports inline assebly, and have fun! (Or if you like, run the 68k programs on a PPC Mac, even under Classic under OSX. After all, 68k emulation is built-in.) Brian Barnes wrote his first games in 68000 assembler, so he might have a comment on this.
Quote this message in a reply
Member
Posts: 370
Joined: 2002.04
Post: #6
I've had good results using Microchip's PIC line of chips. Easy assembler, many good resources. Only drawback is that you're likely going to have to use a Windows or Linux machine to program it. I think it cost me less than a hundred to get going...
I got free samples from Microchip (you can order something like eight or nine, and they even ship it for free). I picked up a $10 Olimex (http://www.olimex.com/) programmer (PIC-PG1B, if my memory serves right) and some stuff from my local electronics store. You're going to need a bit of a crash course in electronics if you use the bare PIC, though... might be better to invest in a development board (too expensive for cheap 'ol me...)

Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
Quote this message in a reply
Member
Posts: 198
Joined: 2005.01
Post: #7
Dreamcast has an SH-4, which is fun to code for in assembly. The only equipment you'll need is a ~$30 used DC and a ~$15 "coders' cable" from Lik Sang. Homebrew software works on a Mac, and there's plenty of examples (and it's very easy to see quick results, with e.g. drawing in the frame buffer).

Cryptic Allusion Games / Cryptic Allusion, LLC
http://www.cagames.com/
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #8
I was trying to learn assembly but Its not really meant to be, people dont like it because its far less portable.
gcc file.c -S -o file.s
gives you the assembly code for a c file, and you can gcc the .s file and get a binary that run, but coding that stuff, its not really somthing I think is possible.

also you could always write an assembly interpreter in c, Ninja

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Member
Posts: 198
Joined: 2005.01
Post: #9
unknown Wrote:but coding that stuff, its not really somthing I think is possible.

...

Would your head explode if I told you I've written whole graphics/music demos in Intel assembly? Smile Or that OS/2 (the IBM OS) has vast tracts of Intel assembly in it? Blink

Cryptic Allusion Games / Cryptic Allusion, LLC
http://www.cagames.com/
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #10
My head asplode!!

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #11
It was ten years ago, but I wrote an IR remote control input system in asm for a prototype digital set top box running a 68000. Not very much, mind you, just enough to capture the input and forward it to my own C routines. I must have written 10, 20 kloc of C for that box, however.
Quote this message in a reply
Member
Posts: 21
Joined: 2003.01
Post: #12
http://timestocome.com/personal/mac.html has some good examples and links.

I have two small programs I wrote on my website @ http://cs.usm.maine.edu/~aubut . I think one is a comp vs comp tic tac toe simulator that uses altivec to check all 8 winning board states in just a couple of instructions.

I like PPC assembly language a lot better then CISC based instruction sets that have only a few registers like the stack pointer, accumulator, etc. I also like the MIPS Arch which is also a RISC based based instruction set. Look for the Mach-O File Format that is on Apple's Dev Site some place. It details which registers are used for what.

I think there is more altivec assembly code out there then anything. There is a cool command line app that comes with the Dev tools or CHUD Tools called Sim G4/G5 that shows you exactly how the machine is executing the code cycle by cycle. You will have to know about execution pipelines and superscalar execution to understand the output. http://www.simdtech.org/home has a nice e-mail list archive where I got my start doing altivec assembly. I got the instruction set manuals for both the PPC and Altivec Instruction Sets for free from Motorola (IBM may have it too) on their site if you wanted to pick that up. I'm not sure if they still do that. Intel stopped when I requested some updated manuals and they just sent me a CD.
Quote this message in a reply
zKing
Unregistered
 
Post: #13
Back when I was in the video game biz I wrote a lot of code for Game Gear and Game Boy... all of it Z80 asm. One title was a port from a Genesis release, so we got all the 68000 code to work from. It was fun (for the most part) and I think I'm a better developer from having served time "where the tires meet the road", but there's less and less of a reason to do it anymore unless you are in a very specialized embedded field.

I've been doing mobile devices for about five years now and even the small low level devices have C compilers (usually GCC of course.) Good powerful chips w/a C compiler are cheap. Although I did hear a rumor that due to all the electronics in cars, dishwashers, etc. the Z80 still outsells the Intel desktop chips by an order of magnitude if not more. But who wants a job programming a dishwasher?

*No offense intended to any dishwasher programmers on this board.* Wink
Quote this message in a reply
Member
Posts: 70
Joined: 2002.07
Post: #14
Ingemar Wrote:Brian Barnes wrote his first games in 68000 assembler, so he might have a comment on this.

Scruffy and Scruffy ][ were written completely in 68K assembly ... and not only that, but the actual graphics were in assembled text files as series of bytes (I actually had pascal code that would convert graphics to text files that I'd run through the assembler.)

I jumped right from coding games in 6502 to 68K, so I didn't even know about nice features like the resource manager. I was hard-core anti anything but drawing directly to the screen. The graphics on both scruffy games are actually compiled into the code resource.

I obviously stopped doing that Smile

[>] Brian
Quote this message in a reply
Jones
Unregistered
 
Post: #15
Excuse my noobieness, but am I correct in assuming that assembly is the "art" or "task" of writing base code for a machine? Something that won't need an operating system, or be dependant on frameworks?

For example, you would start an Operating System from scrath using assembly programming, right?
Quote this message in a reply
Post Reply