mikroPascal 6.03 beta 3

Discuss about beta versions of mikroPascal compiler.
Author
Message
User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

#16 Post by zristic » 29 Jun 2007 14:24

yo2lio wrote:I didit the same too and I have saw some diferences betwen them. Small diference ...
That is important, even if it is small. Can you share your findings with us?

yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

#17 Post by yo2lio » 29 Jun 2007 17:21

Hi Zoran,

I fond the "bug" !!! Hmmm ..... It's not a bug !!??

Code: Select all

program test;

var sum : longint;

begin
  sum := sum shr 16;
end.
MikroPascal 6.002 :

Code: Select all

$0000	$EF04	F000			GOTO	_main
$0008	$	_main:
;test.ppas,3 :: 			var sum : longint;
;test.ppas,6 :: 			sum := sum shr 16;
$0008	$C017	F015			MOVFF	_sum+2, _sum
$000C	$C018	F016			MOVFF	_sum+3, _sum+1
$0010	$6A17	    			CLRF	_sum+2, 0
$0012	$6A18	    			CLRF	_sum+3, 0
$0014	$	test_L_0:
;test.ppas,7 :: 			end.
$0014	$D7FF	    			BRA	$
MikroPascal 6.003 Beta :

Code: Select all

; ----------------------------------------------
$0000	$EF04	F000			GOTO	_main
$0008	$	_main:
;test.ppas,5 :: 			begin
;test.ppas,6 :: 			sum := sum shr 16;
$0008	$C017	F015			MOVFF	_sum+2, _sum
$000C	$C018	F016			MOVFF	_sum+3, _sum+1
$0010	$0E00	    			MOVLW	0
$0012	$BE18	    			BTFSC	_sum+3, 7, 0
$0014	$0EFF	    			MOVLW	255
$0016	$6E18	    			MOVWF	_sum+3, 0
$0018	$	test_L_0:
;test.ppas,7 :: 			end.
$0018	$D7FF	    			BRA	$
OK ..... From help :

SHR bitwise shift right; moves the bits to the right, discards the far right bit and if unsigned assigns 0 to the left most bit, otherwise sign extends !

In my UDP Bootloader program, I use this line in PIC18F66J60_CRCCalculate function :

Code: Select all

if sum  > $0000FFFF then sum := (sum and $0000FFFF) + sum shr 16;
sum is declared longint !!!

Work around :

Code: Select all

if sum  > $0000FFFF then sum := (sum and $0000FFFF) + ((sum shr 16) and $0000FFFF);
I think that adding the CARDINAL TYPE (like in DELPHY unsigned 32 bit) would be a great idea . Don't you think ?

Best regards, Florin Medrea.

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

#18 Post by janni » 29 Jun 2007 17:47

This
yo2lio wrote:MikroPascal 6.003 Beta :

Code: Select all

; ----------------------------------------------
$0000	$EF04	F000			GOTO	_main
$0008	$	_main:
;test.ppas,5 :: 			begin
;test.ppas,6 :: 			sum := sum shr 16;
$0008	$C017	F015			MOVFF	_sum+2, _sum
$000C	$C018	F016			MOVFF	_sum+3, _sum+1
$0010	$0E00	    			MOVLW	0
$0012	$BE18	    			BTFSC	_sum+3, 7, 0
$0014	$0EFF	    			MOVLW	255
$0016	$6E18	    			MOVWF	_sum+3, 0
$0018	$	test_L_0:
;test.ppas,7 :: 			end.
$0018	$D7FF	    			BRA	$
does not really make sense with sum+2 byte skipped. Let's assume that sum=-983039 (FF F1 00 01) - after the shr it should equal -15 (FF FF FF F1) while with the above code we get -917519 (FF F1 FF F1) :roll: .
I think that adding the CARDINAL TYPE (like in DELPHY unsigned 32 bit) would be a great idea . Don't you think ?
mE planned to introduce longword type - I wonder what happend to these plans?

yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

#19 Post by yo2lio » 29 Jun 2007 17:50

Thanks Janni !

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

#20 Post by janni » 29 Jun 2007 17:59

The problem is only with x shr 16 - for other number of shifts it works fine. I only wonder how many user's programs will be affected with the change from treating rotated longint as longword to treating it as integer value :( . Not that it shouldn't be so, but it would be better to introduce longword first.

Another bug found in mB by xor, and confirmed by jpc in mP:
- inc & dec instructions cannot be used with pointers as producing undesirable effects.

Post Reply

Return to “mikroPascal Beta testing”