RISC OS Open
A fast and easily customised operating system for ARM devices
ROOL
Home | News | Downloads | Bugs | Bounties | Forum | Documents | Photos | Contact us
Account

Previous|Next

  • Tickets
  • » Ticket #504

Ticket #504 (Open)Thu Feb 11 02:02:20 UTC 2021

DDE30 C Compiler considers local variable not accessed by inline assembler BL

Reported by: Timothy Baldwin (184) Severity: Normal
Part: RISC OS: C/C++ toolchain Release:
Milestone: Status Open

Details by Timothy Baldwin (184):

Consider this program which erroneously prints “FAIL”:
<code><pre>#include <stdio.h>

void set_x(int *x) {
*x = 1;
}

int test(void) {
int x = 0;
__asm {
MOV r0, &x
BL set_x, {r0}, {}, {r0-r3, ip, lr, psr}
}
return x;
}

int main(void) {
int x = test();
puts(x ? “OK” : “FAIL”);
return !x;
}</pre></code>

The function test compiles to:
<code><pre>test
STMDB sp!,{v1,lr}
SUB sp,sp,#4
MOV a1,sp
BL set_x
MOV a1,#0
ADD sp,sp,#4
LDMIA sp!,{v1,pc}</pre></code>

Which although it allocates storage for the local variable and passes it’s address to set_x neither initialises the memory nor reads it. In the practical problem I was trying to call a non-APCS routine.

GCC would require “memory” specifying in the clobber list, but for ROOL C no requirement nor method is documented. Arrays or structs appear to work.

  • Comment on, or change status of, this ticket

Previous|Next

Search tickets

Social

Follow us on and

ROOL Store

Buy RISC OS Open merchandise here, including SD cards for Raspberry Pi and more.

Donate! Why?

Help ROOL make things happen – please consider donating!

RISC OS IPR

RISC OS is an Open Source operating system owned by RISC OS Developments Ltd and licensed primarily under the Apache 2.0 license.

Options

  • Tickets
  • New ticket
  • Milestones
  • Subversion: Changesets
  • Subversion: Browse
  • CVS: Revisions
  • CVS: Browse
  • Search

RSS feeds Rss

  • Tickets
  • Everything!
  • More feeds...
Site design © RISC OS Open Limited 2018 except where indicated
The RISC OS Open Collaboa theme is distantly based on the Collaboa default layout

Valid XHTML 1.0  |  Valid CSS

Powered by Collaboa
This site runs on Rails

Hosted by Arachsys