#166127 - Ploe - Fri Jan 30, 2009 6:43 pm
Call me Ploe. I've been dabbling with high level languages for years. I'm well versed in good old Visual BASIC, so I'm completely foreign to the concept of programming anything in ASM. I've recently come into some spare time, and for something to do I'd really like to start playing around with ASM. However most tutorials on the internet assume you have some sort of background in working with ASM before. Where would a complete beginner head?
The reason I have picked the Gameboy Advance is because I really like the machine, and from what I've gathered the ARM architecture is used in most electronic devices. Please direct me, if you would, to any resources aimed at someone on my level.
#166128 - Dwedit - Fri Jan 30, 2009 8:35 pm
Calling gcc with the -S option generates ASM code that you can look at. Not the best or most readable code, but it's asm code. Don't forget to optimize with the -O2 option, optimized code is more readable.
But I think the best way is to find someone else's ASM code, then modify it.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."
#166131 - elyk1212 - Fri Jan 30, 2009 10:33 pm
Hey Ploe, ... during my undergrad, I learned all my ASM in CSE225 using this great tool/emulator:
http://www.easy68k.com/
It is easy to use and very easy to inspect register/memory values. Nothing beats an emulator you can get your hands dirty with.
You are going to want to become intimately familiar with memory and what a "stack" and a "heap" really is, how they grow and how to use them during function calls (and when not to use them). Sometimes you pass parameters using registers only...etc. Knowing this, and binary operations (and boolean algebra in general), are key to being a good ASM programmer, and really a good embedded systems programmer (IMO).
However, after you learn some ASM, you may want to become familiar with what GCC "really" does and what the calling conventions are using that tool (since you'll prob be using this for GBA, and it's a good practice to become a little familiar to what "magic" compilers are really doing).
That can be done by "Calling gcc with the -S option" as suggested.
#166165 - Ploe - Sat Jan 31, 2009 11:43 pm
Thanks elyk. I've got the emulator open and I'm currently looking at the Hello World example on their website. I'm very excited. I'll have to grab a cup of tea and get my code face on. Cheers very much!
Dwedit, will I have used some of your software in the past? Your handle sounds familiar.
Edit: Yes, Goomba Color. Thanks for allowing me to pack light. Because of you I don't need to haul both my GBA SP and DS on journeys.
#166173 - alien8r33d - Sun Feb 01, 2009 11:52 am
Hi Ploe,
I've been programming in assembler since 1980/81. During this timespan, I've programmed just about everything there is apart from the hoover and the dog's bowl and I'll tell you this, you need a good assembler. I use Goldroad for the GBA. It's free and by god it works.
I have written several projects in 100% Arm asm for the GBA and would be happy to help if you have any questions.
I am currently converting Alien Breed in ASM. It is currently about 85% complete.
#166245 - elyk1212 - Tue Feb 03, 2009 6:22 am
"100% ASM"? Do you find yourself sometimes checking with gcc to see some tricks? Sometimes I find the compiler will know many tricks, I may not have thought of to speed up coherency etc (granted less experience, I was born in 1980, :P ). Or, perhaps you're just doing all ASM for fun (or your lang of choice)... and it DOES sound like some fun.
Just wondering, since I hear most people speak volumes of the old adage "premature optimization is evil"... or what not (mentioning that a mix of C and optimized bottleneck, asm code is their proposed solution).
#166252 - alien8r33d - Tue Feb 03, 2009 12:12 pm
Never used gcc but I would'nt be opposed to doing so I suppose. Assembler is my prefered language and, though I say so myself, I do have a knack for it. Always have had.
With asm, you have to program in a modular fashion. I mean split a function into modules, program each module and then link all modules, debug (if required) and optimize the code. I always remember reading an article in a computer games mag back in the 80s, the author had just landed a job at a software house. His first task was to write a screen scrolling routine as part of a project the team was working on. He said he spent hours working on the routine, within the spec given to him, until he thought it was perfect. Both as fast and compact as it could be. When he was asked about his progress, he handed over his source code for inspection but instead of getting the adulation he expected, the project manager just said "Great, ta". The lesson he learned from this was this, and I quote (well roughly anyway), "When it comes to coding (in ASM), as long as it works, it's good code."
That's not to say that I am happy writing shoddy code. Far from it. I take pride in producing fast compact code but, as you well know, there are many ways of coding a given routine in asm and you could spend hours optomizing/re-coding it and still not be entirely happy with the result.
#166253 - alien8r33d - Tue Feb 03, 2009 12:14 pm
Never used gcc but I would'nt be opposed to doing so I suppose. Assembler is my prefered language and, though I say so myself, I do have a knack for it. Always have had.
With asm, you have to program in a modular fashion. I mean split a function into modules, program each module and then link all modules, debug (if required) and optimize the code. I always remember reading an article in a computer games mag back in the 80s, the author had just landed a job at a software house. His first task was to write a screen scrolling routine as part of a project the team was working on. He said he spent hours working on the routine, within the spec given to him, until he thought it was perfect. Both as fast and compact as it could be. When he was asked about his progress, he handed over his source code for inspection but instead of getting the adulation he expected, the project manager just said "Great, ta". The lesson he learned from this was this, and I quote (well roughly anyway), "When it comes to coding (in ASM), as long as it works, it's good code."
That's not to say that I am happy writing shoddy code. Far from it. I take pride in producing fast compact code but, as you well know, there are many ways of coding a given routine in asm and you could spend hours optomizing/re-coding it and still not be entirely happy with the result.
#166348 - Miked0801 - Thu Feb 05, 2009 6:16 pm
I'm an assembly hack myself, but I have come to love stl containers and smart pointer and everything else yummy about C++. It's just so nice to not have to worry about linked lists and such anymore when coding - especially and the machine level.
Yep, the code is larger/slower than what we could code by hand, but it gets done so much faster and anyone can support it - not just asm hacks.
#166656 - elyk1212 - Fri Feb 13, 2009 3:58 am
Yeah, I like some higher level goodies like those as well. Portability is a nice treat.
BTW, stl containers aren't implemented in devkitarm, are they? If so I have never used them.
Linked lists are trivial to implement, but it's nice to not have to worry about testing every little thing, and the coherency of vector and stl containers are quite nice. They are actually more efficient (in many cases) than hand coded linked lists due to non contiguous memory spaces you'd use in naive implementations. Ok... you could write your own malloc for the heap to keep things contig... but anyhow... :)
#166657 - Dwedit - Fri Feb 13, 2009 4:34 am
Memory Contiguity only matters on systems with cache. This excludes the GBA.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."
#166659 - elyk1212 - Fri Feb 13, 2009 6:46 am
Yeah, I suppose there isn't a memory hierarchy on that guy (thanks for reminding me, I need to look at hardware docs again), so in GBA case, that doesn't matter too much how you do lists etc, I spose. (maybe on PSP or something, it would be useful?). But I don't think stl works on GBA, so I guess it's moot.
Or does it and I am missing something? I am under the naive impression that stl libs would bloat the binaries something awful.... so my guess is no.
#166721 - Miked0801 - Sun Feb 15, 2009 11:16 pm
We use STL on the DS without huge bloat. It all depends on how you use them :)
#166728 - elyk1212 - Mon Feb 16, 2009 2:51 am
Ah, cool. Haven't gotten to DS playing yet. I wondered about STL on there.
I just got one of the old phat style buggers so I'll have to give it a shot one day, when I have a moment.