Here is a solution that works if we know we can access up to three bytes of 
memory after the last length field. That is, if we can always use Load to get 
the length field from memory:

L     R1,(,R14)          R1  = Integer plus trailing junk
LHI   R15,4
S     R15,0(,Rn)         R15 = 4-length
SLL   R15,3              R15 = (4-length)*8
*                        Length 0 => 32
*                        Length 1 => 24
*                        Length 2 => 16
*                        Length 3 =>  8
*                        Length 4 =>  0
SRL   R1,(,R15)          R1  = Integer 
ST    R1,Local_integer

Task 2) is also taken care of: a zero-length length fields results in a zero 
integer (but not -1).
Task 3) is easily implemented: replace the SRL by an SRA.
Taks 4) wouldn't be that hard either: use Grande instructions.

Fred!

Reply via email to