Shop OBEX P1 Docs P2 Docs Learn Events
Funny Finding: Single Instruction Inline Assemblies for XBYTE — Parallax Forums

Funny Finding: Single Instruction Inline Assemblies for XBYTE

Kind of funny finding:
While experimenting with my little XBYTE machine and PASM, I discovered, that single instructions as inline assemblies make sense. The reasons are, that P2's instruction set is very rich and that in 32 bit there can be 9bit operands as well. For example you can code "ret shl tos,#2" (register tos=tos*4). To read the instruction from HUB RAM the streamer is still used, so that is fast.

So we start with a special XBYTE code "mexec", which loads the next long into a cog register and jumps to it there. It must contain "ret" to resume the xbyte machine.
Execution time for the instruction seems to be only 16 cycles.

 i_mexec                rflong data     ' get the instruction must contain _ret_
                        jmp #data 

I love simple things! :-)
Have fun, Christof

Sign In or Register to comment.