Absolute Files and the Stack Pointer
Graeme (8815) 106 posts |
I am writing an assembly program and have discovered an issue that I don’t think I have ever seen before. Getting the BASIC set up, the assembly has one line of code which is MOV PC,R14 and this works fine. If I call it from BASIC, save it to a Utility file or an Absolute file. As soon as I change this to use the stack pointer – so STMFD R13!,{R14}:LDMFD R13!,{PC}, I get an error if it is saved as an Absolute file. It works fine if the code is called from BASIC or it is a Utility. What I can see is that on entry to an Absolute file the stack pointer is missing. Well, set to &80000000. Is that normal? Am I supposed to create my own stack for an Absolute file? Or am I doing something wrong? |
Rick Murray (539) 13840 posts |
Yes, with an Absolute file you are supposed to manage your own resources. As the stack grows downwards, a usual think to do is to call https://www.riscosopen.org/wiki/documentation/show/OS_GetEnv |
Graeme (8815) 106 posts |
Thank you! That works perfect. Two lines of code put at the start of the program: SWI OS_GetEnv R13,R1 and I have a stack pointer! I always thought that R13 was passed to Absolute files and I am sure I’ve made plenty in the past that worked. I wonder how I’ve saved them in the past? Too long ago to remember exactly what I did. |
Chris Evans (457) 1614 posts |
Might they have been ‘Transients’? I’m probably talking rubbish but many moons ago I wrote a few ‘Transients’ they IIRC don’t need to manage their own resources (or maybe I just didn’t need to have a stack!) |
Rick Murray (539) 13840 posts |
Transients, or Utility, have R13 already set up. That’s because they are supposed to be small transient utilities (clue in the name ;) ) so their entry conditions and how they operate are tightly defined. Absolute (applications) have much less of a defined state as the program is supposed to manage its own runtime environment. Stacks, environment handlers, etc etc. |