That is important, even if it is small. Can you share your findings with us?yo2lio wrote:I didit the same too and I have saw some diferences betwen them. Small diference ...
mikroPascal 6.03 beta 3
Hi Zoran,
I fond the "bug" !!! Hmmm ..... It's not a bug !!??
MikroPascal 6.002 :
MikroPascal 6.003 Beta :
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 :
sum is declared longint !!!
Work around :
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.
I fond the "bug" !!! Hmmm ..... It's not a bug !!??
Code: Select all
program test;
var sum : longint;
begin
sum := sum shr 16;
end.
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 $
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 $
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;
Work around :
Code: Select all
if sum > $0000FFFF then sum := (sum and $0000FFFF) + ((sum shr 16) and $0000FFFF);
Best regards, Florin Medrea.
This
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) .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 $
mE planned to introduce longword type - I wonder what happend to these plans?I think that adding the CARDINAL TYPE (like in DELPHY unsigned 32 bit) would be a great idea . Don't you think ?
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.
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.