Shop OBEX P1 Docs P2 Docs Learn Events
Pnut bug with REP and AUGS — Parallax Forums

Pnut bug with REP and AUGS

Hi Chip
I've encountered a bug in Pnut that icorrectly encodes the REP instruction block length when the immediate value is > 9 bits. (AUGS applied)
Here's the sample code source
		orgh	$12000
		org

		rep	@rblk1,#511
		add	myreg1,myreg2 wz
	if_z	sub	myreg1,myreg2 wc
	if_nc	xor	myreg1,myreg2 wz,wc
rblk1
		rep	@rblk2,##512		'<-- Repeat block length +1 error
		add	myreg1,myreg2 wz
	if_z	sub	myreg1,myreg2 wc
	if_nc	xor	myreg1,myreg2 wz,wc
rblk2
		mov	myreg3,##512
		rep	@rblk3,myreg3
		add	myreg1,myreg2 wz
	if_z	sub	myreg1,myreg2 wc
	if_nc	xor	myreg1,myreg2 wz,wc
rblk3
Here's is my disassembly of Pnut's output
Propeller 2 - Disassembler V1.02 - Ozpropdev 2015
-------------------------------------------------
12000: $FCDC05FF %1111_1100110_111_000000010_111111111                 REP     #$2,#INB
12004: $F10A0302 %1111_0001000_010_100000001_100000010                 ADD     $101,$102 WZ
12008: $A1920302 %1010_0001100_100_100000001_100000010           IF_Z  SUB     $101,$102  WC
1200C: $357A0302 %0011_0101011_110_100000001_100000010          IF_NC  XOR     $101,$102 WZ, WC
12010: $FF000001 %1111_1111000_000_000000000_000000001                 AUGS    #$1 (##200)
12014: $FCDC0600 %1111_1100110_111_000000011_000000000                 REP     #$3,#$0     '<-- should be REP #$2,@#0
12018: $F10A0302 %1111_0001000_010_100000001_100000010                 ADD     $101,$102 WZ
1201C: $A1920302 %1010_0001100_100_100000001_100000010           IF_Z  SUB     $101,$102  WC
12020: $357A0302 %0011_0101011_110_100000001_100000010          IF_NC  XOR     $101,$102 WZ, WC
12024: $FF000001 %1111_1111000_000_000000000_000000001                 AUGS    #$1 (##200)
12028: $F6060600 %1111_0110000_001_100000011_000000000                 MOV     $103,#$0
1202C: $FCD80503 %1111_1100110_110_000000010_100000011                 REP     #$2,$103
12030: $F10A0302 %1111_0001000_010_100000001_100000010                 ADD     $101,$102 WZ
12034: $A1920302 %1010_0001100_100_100000001_100000010           IF_Z  SUB     $101,$102  WC
12038: $357A0302 %0011_0101011_110_100000001_100000010          IF_NC  XOR     $101,$102 WZ, WC
Cheers
Brian

Comments

Sign In or Register to comment.