On 01/18/2017 12:34 PM, Brian Schenkenberger via vcf-midatlantic wrote:
William Dudley via vcf-midatlantic writes:
IMHO, the difficult bit with assembly language is that you have to keep track of all the "book keeping" needed by your algorithm. If you need 10 variables, and array of 100 integers, and pointers to subroutines, then you have to keep track of all this stuff yourself. This means that you have to start planning on paper long before you write your first opcode. Of course, it also means that you have to be familiar with the machine architecture, how many registers it has, how much stack, etc, so that you can figure out WHERE you are going to store all the stuff you need.
First, that's one of the reasons that assemblers accept human assigned names for routines and fixed data location -- so you don't have to keep track of a routine or data pointer. Local data? Carve up the stack. Arrays? Machines with indexing make this much simpler that those without.
Of course know thy (CPU) limitations. The 6502 has a stack that's stuck on Page 0 and only has 256 bytes. I don't remember the rest of the 6502's idiosyncrasies but there are a few. If one keeps the push and pull of variables on/off the stack short and avoid recursion one can pretty much deal with mild to moderate complex JSRs. The assembler is more work than a high level language but I've never really found it too bad. Of course I have done anything as complex as networking in assembler.
... If you really want a challenge, try writting assembly on a machine that doesn't possess branch instructions and executes multiple operations at one time! ;)
Or CPUs that execute both halves of a condition (that one just hurts my brain). I think the Microchip PIC32s are bringing multicore to the embedded world so I might see more 'weirdness' now. Of course I'm seeing more high level languages in my embedded stuff (MicroPython, Lua, etc.) -- Linux Home Automation Neil Cherry ncherry@linuxha.com http://www.linuxha.com/ Main site http://linuxha.blogspot.com/ My HA Blog Author of: Linux Smart Homes For Dummies