What's the best way to learn Smali (and how/when to use Dalvik VM opcodes)?
UPDATE: As I promised yesterday, I added some more links to the list.
Ufff. Not much documentation around! Best advice? Decompile, and read, and tweak, and see how it did, and start the cycle again and again. But you did not ask for that advice, right? ;)
Now, there are a few places out there that wil lhelp a little bit:
http://androidcracking.blogspot.com/search/label/smali This is the best one. I even asked the guy a question and he answered very quickly, so go and take a look.
http://pallergabor.uw.hu/androidblog/dalvik_opcodes.html Very comprehensive table - good reference!
http://webchat.freenode.net/?channels=smali I never tried it, but it's on the google code page of the baksmali author ( http://code.google.com/p/smali/ )
http://forum.xda-developers.com/showthread.php?t=777707 Lastly, this is a post I made some time ago describing some hacks to the Captivate camera. You can follow the diffs in there as I comment a little bit on what each .diff file is doing. The good stuff starts at the post #20.
http://www.slideshare.net/paller/understanding-the-dalvik-bytecode-with-the-dedexer-tool Interesting slide show with some basic concepts. Good way to start.
http://sites.google.com/site/haynesmathew/home/projects/dalvik-notes Even more low level than the typical .smali. A reference for later, but a good read.
http://jasmin.sourceforge.net/guide.html Smali syntax is based on Jasmin, so this gives good concepts.
http://groups.google.com/group/apktool?pli=1 Some discussions there are worth reading through. Also a good place to search for when you're stuck in something.
And last, but not least, the most helpful trick I used: start coding very basic classes and methods in java, compile them and then baksmali your own code. You know exactly what it does, so it will be a lot easier to follow.
Good luck!
I continue to be surprised that folks don't use the official Dalvik format documents as a primary reference. On older releases, the Dalvik docs are in the Android source under dalvik/docs. The particular file you'll want to look at is called dalvik-bytecode.html. A few releases back the bytecode definition became part of the android.com developer docs:
dalvik-bytecode.html on source.android.com
As an additional convenience, I occasionally mirror these docs on my personal website. In this case:
dalvik-bytecode.html on milk.com
I do have a couple of wiki pages on the smali site with some information:
http://code.google.com/p/smali/wiki/Registers
http://code.google.com/p/smali/wiki/TypesMethodsAndFields
And there are examples of smali code that use every opcode in the integration tests for smali/baksmali:
smali integration tests