[fpc-devel] succ(byte)

Carsten Bager carsten at beas.dk
Thu Sep 26 16:21:54 CEST 2013


Here is output from the 2.4.5 Compiler and the 2.62 compiler. of the following program 
compiled the same way.

It has always been possible to eliminate runtime checking when incrementing a byte/word in 
this way (if one wants the byte to roll over).
This is not possible with the 2.6.2 compiler. Is there a reason for this.

Carsten


program test_arm9;

Var
  b:byte;
begin
  b:=byte(succ(b));
end.



Free Pascal Compiler version 2.4.5 [2012/06/19] for arm
# [6] b:=byte(succ(b));
        ldr     r0,.Lj5
        ldrb    r0,[r0]
        add     r0,r0,#1
        and     r0,r0,#255
        ldr     r1,.Lj5
        strb    r0,[r1]
        .stabn 68,0,7,.Ll3 - main



Free Pascal Compiler version 2.6.2 [2013/07/16] for arm
# [6] b:=byte(succ(b));
        ldr     r0,.Lj5
        ldrb    r0,[r0]
        adds    r1,r0,#1
        bcc     .Lj6
        bl      FPC_OVERFLOW
.Lj6:
        mov     r0,r1
        add     r0,r0,#0
        cmp     r0,#255
        bls     .Lj7
        bl      FPC_RANGEERROR
.Lj7:
        and     r0,r1,#255
        ldr     r1,.Lj5
        strb    r0,[r1]
        .stabn 68,0,7,_$TEST_ARM9$_Ll3 - main



More information about the fpc-devel mailing list