Shop OBEX P1 Docs P2 Docs Learn Events
Possible bug with AUGS followed by ALTS — Parallax Forums

Possible bug with AUGS followed by ALTS

Here is the suspect code...
                alts	y, ##_TABLE_OPC0		'\ set next S to offset+table addrs
                mov	p, #0-0				'/
_TABLE_OPC0 is a table located in hub ram
y is an index into the table

When y + _TABLE_OPC0 causes an overflow from >$1FF, the overflow is lost.

Here is a sample output where the first hex is the value of "y", the second hex is the hub location of "_TABLE_OPC0", and the third hex is the resultant (sum) "p" value.
=== Cluso's P2v10a Debugger v.105x ===
000000C0+00001508=000015C8  MIN
000000C8+00001508=000015D0  MAX
000000D0+00001508=000015D8  MINS
000000D8+00001508=000015E0  MAXS
000000E0+00001508=000015E8  SUMC
000000E8+00001508=000015F0  SUMNC
000000F0+00001508=000015F8  SUMZ
000000F8+00001508=00001400
00000100+00001508=00001408
00000108+00001508=00001410
00000110+00001508=00001418
Note that when $F8 is added to $1508 the result should be $1600 but is shown as $1400 (ie the $200 carry is lost). It seems that the addition is limiting the size of the addition to 9 bits.

The attached file uses my LMM Serial Debugger code for display purposes on the serial P30/31 port at 115200 baud.

Comments

  • Cluso99 wrote: »
                    alts	y, ##_TABLE_OPC0		'\ set next S to offset+table addrs
                    mov	p, #0-0				'/
    
    The AUGS instruction only applies to the ALTS instruction and not the following MOV instruction.
    The MOV instruction only has a single '#' immediate symbol so will always be limited to 9 bits unless it also has its own AUGS preceeding it.


  • ozpropdevozpropdev Posts: 2,792
    edited 2016-07-06 06:02
    The ALTS instruction should cancel the AUGS mechanism after it's use.
    What seems to be happening is the AUGS is also being applied to the MOV instruction too.
  • cgraceycgracey Posts: 14,134
    ALTS is used to indirectly access cog registers, not hub RAM.

    I actually added a section to the doc file on this. I'm going to go add in the ALTI description now.
  • Cluso99Cluso99 Posts: 18,069
    Thanks Chip.

    I can use this sequence instead...
                    alts	lmm_w, ##_TABLE_CCCC		'\ set next S to offset+table addrs
                    mov	lmm_p, #0-0			'/
    replace with...
    		mov	lmm_p, ##_TABLE_CCCC
    		add	lmm_p, lmm_w
    
    Here is where I use the sequence to decode the condition bits to an "if_xxx" string
                    and     lmm_w, #$0F                     ' extract 'cccc'
    		mul	lmm_w, #12			' cccc offset *12
    
    '                alts	lmm_w, ##_TABLE_CCCC		'\ set next S to offset+table addrs
    '                mov	lmm_p, #0-0			'/
    		mov	lmm_p, ##_TABLE_CCCC
    		add	lmm_p, lmm_w
    
                    mov     lmm_c, #12                      ' set count of chars for the "if" part
    .ifcccc         rdbyte  lmm_x, lmm_p                    ' get the byte from table
                    add     lmm_p, #1                       ' point to next byte
                  CALL   	#_HubTx                         '               	< call: transmit char(s) >
    		djnz	lmm_c, #.ifcccc
    
    I have tables in hub for the various conditions, opcode sets, etc, for decoding instructions in my Lmm Serial Debugger.
Sign In or Register to comment.