On Wednesday 31 July 2002 01:09 pm, Aaron wrote:
People think assemblers are hard? I always imagined that it'd be a lot easier to write an assembler than a compiler. I'm a biologist, not a computer scientist or elec engineer, but I always thought that you don't do more than superficial optimization within an assembler, but simply translate human-readable opcodes, like translating "returnTop" in SqVM assembly to the byte 7C.
It can be more complicated than just translating opcodes.
For instance, you could do register/RAM allocation (overlaying function temps, for instance); on the PIC you have to deal with a banked program space as well as a banked RAM/register space. So you have to be able to stretch instructions for the extra bytes needed for extended jumps/calls or RAM references. Which may cause other jumps to have to become extended jumps.
A clever assembler could try to arrange all the RAM used by a particular function to be on the same RAM page, and all the functions called to be in the same ROM page.