SET Parameter Problem

Report any suspected bugs that you find
Post Reply
gray
Posts: 115
Joined: Tue Feb 12, 2019 2:59 am
Location: Mauritius

SET Parameter Problem

Post by gray » Sun Mar 17, 2024 11:39 am

Test code (Astrobe v9.1 for Cortex-M0):

Code: Select all

MODULE M;

  PROCEDURE p(s: SET);
  END p;

  PROCEDURE run;
    VAR k: INTEGER;
  BEGIN
    p({k});
    p({13})
  END run;

END M.
Partial assembly code:

Code: Select all

  PROCEDURE run;
    VAR k: INTEGER;
  BEGIN
.    12     0CH  0B500H          push     { lr }
.    14     0EH  0B081H          sub      sp,#4
    p({k});
.    16    010H  09800H          ldr      r0,[sp]
.    18    012H  02101H          movs     r1,#1
.    20    014H  04081H          lsls     r1,r0
.    22    016H  0F7FFFFF5H      bl.w     -22 -> 4
.    26    01AH  0E000H          b        0 -> 30
.    28  <LineNo: 8>
    p({13})
.    30    01EH  02001H          movs     r0,#1
.    32    020H  00340H          lsls     r0,r0,#13
  END run;
.    34    022H  0F7FFFFEFH      bl.w     -34 -> 4
.    38    026H  0E000H          b        0 -> 42
.    40  <LineNo: 10>
.    42    02AH  0B001H          add      sp,#4
.    44    02CH  0BD00H          pop      { pc }
.    46    02EH  046C0H          nop
For the first call of 'p', parameter 's' is passed in register R1 in lieu of R0.

The immediate version works (second call of 'p').

cfbsoftware
Site Admin
Posts: 497
Joined: Fri Dec 31, 2010 12:30 pm
Contact:

Re: SET Parameter Problem

Post by cfbsoftware » Tue Mar 19, 2024 2:02 am

Thank you for your report. The problem will be addressed in the next maintenance release. In the meantime a workaround is to assign the set to a local variable before passing it as a parameter. See the attached test program which should display the string "OK".

Replacing the local variable assignment

Code: Select all

s := {k};
Check(s, k)
with

Code: Select all

Check({k}, k)

should result in an exception until the problem is fixed.
Attachments
Sets2.zip
(388 Bytes) Downloaded 19 times

Post Reply