In my ongoing quest to understand the possibilities (and possible limitations) of parrot, here's another one. ;-)
How close a mapping can there be between regular (x86 in this example) assembly (as generated by c-compilation) and pasm?
I can't figure out if the stack ops can approximate this kind of thing.
The major difference between PASM and some $arch assembly (especially CISC like) is, that PASM is register oriented, while e.g. x86 is very much stack oriented. And of course PASM is much more highlevel.
Issues I don't understand are inline in the assembly.
subl $8, %esp ; Is there a stack pointer to move?
Not directly. Instead PASM has the concept of register frames. A typical subroutine entry is a "saveall" which copies the current 4*32 register frame away, and thus allows the sub to globber all registers. At the end of the subroutine, the original registers get restored by "restoreall".
movl $5, -4(%ebp) ; Is there any analogue to bit/byte sized offsets?
No
incl (%eax) ; can you modify an element on the stack in place?
No. x86 uses the stack frame for locals, PASM typically uses a fresh register frame, and just works on registers.
The PASM analogy of your C example would be something like:
saveall
set I0, 5
inc I0
restoreall
ret
which is a much more a direct representation of C code then generated x86 assembly.
-Tupshin
leo