On Wed, 17 Jun 2015 01:54:49 -0400, Fred van der Windt <[email protected]> wrote:
>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. Two comments/questions: (1) How did you accomplish task 2? It was, specifically, to derive a non-zero value for a missing (0-length) field in order to distinguish it from a supplied field with a value of 0. That is, a numeric field with a length of 0 (no data returned) was to be treated differently from a numeric field with a length of 1 and a value of 0. (2) Unfortunately, you can not assume that you can access up to 3 bytes of memory beyond the length field. That is certainly true if the length field is non-zero. However, if the length field is zero, and it is the last field in the returned data, it is possible that you will program check if you try to look beyond it. -- Walt
