etv_term vector

GFA, ASM, STOS, ...

Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team

mikro
Hardware Guru
Hardware Guru
Posts: 2177
Joined: Sat Sep 10, 2005 11:11 am
Location: Kosice, Slovakia
Contact:

Re: etv_term vector

Post by mikro »

ThorstenOtto wrote:BTW your example my_trap1_c_handler for the gemdos trap only works by accident. If you would do anything useful there, and the compiler chooses to save some registers to the stack first, you cannot just call the old vector, because the original saved parameters to that function are at the wrong offset.
What parameters? It's a void function, by definition.
It would also not work when compiled without optimization, because then the call to oldvec is done by a jsr.
Oh really. So instead of jmp old_vec + RTS in old_vec I would have jsr old_vec + RTS in old_vec + RTS in my_trap1_c_handler. Care to explain how this wouldn't work?

EDIT: Got this, too. ;) I guess you meant that if the system trap vector is called by JSR it would return with RTE what is wrong, of course. The updated code fixes this as well so thanks for spotting this!
Last edited by mikro on Sun Apr 21, 2019 5:20 pm, edited 2 times in total.

mikro
Hardware Guru
Hardware Guru
Posts: 2177
Joined: Sat Sep 10, 2005 11:11 am
Location: Kosice, Slovakia
Contact:

Re: etv_term vector

Post by mikro »

mikro wrote:
ThorstenOtto wrote:BTW your example my_trap1_c_handler for the gemdos trap only works by accident. If you would do anything useful there, and the compiler chooses to save some registers to the stack first, you cannot just call the old vector, because the original saved parameters to that function are at the wrong offset.
What parameters? It's a void function, by definition.
OK, now it hit me -- you mean trap call parameters. Even if this wasn't the purpose of this code sample (imagine VBL or IKBD handler as a better use case), it is still good practice to make it as bullet proof as possible, so fixed.

ThorstenOtto
Atari God
Atari God
Posts: 1096
Joined: Sun Aug 03, 2014 5:54 pm

Re: etv_term vector

Post by ThorstenOtto »

mikro wrote: OK, now it hit me -- you mean trap call parameters.
Yes, exactly. If it was called from supervisor mode (like the desktop does for example), then they are on the current stack.

Post Reply

Return to “Coding”