Frage

Bei der Einleitungsanordnung in GCC muss ich regelmäßig leere ASM-Blöcke hinzufügen, um Variablen in früheren Blöcken lebendig zu halten, zum Beispiel: generasacodicetagpre.

Ein anderes Beispiel für eine komisch generasacodicetagpre.

Ich denke, es hat mit der Tatsache zu tun, dass es so viele Register verwendet.Gibt es etwas, was ich hier fehlt, oder ist die Registerallokation, die nur wirklich Buggy mit der GCC-Inline-Baugruppe ist?

War es hilfreich?

Lösung

What you're missing is that GCC's optimiser will assume that the only side-effect of an asm block is to change the output operands. If those operands are not subsequently used, it may assume that the asm block in unnecessary and can be deleted.

e.g. in your first example, if borrow is not subsequently used, it is free to assume that there is no point in including the asm block at all, because its only side-effect is to update a variable that is never used again. And in the second example, if hi and carry are not used again after the code you've shown, it will probably infer that it can delete pretty much everything!

You can tell GCC that your inline assembly blocks should not be deleted by writing asm volatile(...) instead of just asm(...).

For more detail about this, see http://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html (about half-way down the page).

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top