etv_term vector

GFA, ASM, STOS, ...

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

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

Re: etv_term vector

Postby mikro » Sun Apr 21, 2019 5:02 pm

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: 1943
Joined: Sat Sep 10, 2005 11:11 am
Location: Kosice, Slovakia
Contact:

Re: etv_term vector

Postby mikro » Sun Apr 21, 2019 5:13 pm

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 Super Hero
Atari Super Hero
Posts: 581
Joined: Sun Aug 03, 2014 5:54 pm

Re: etv_term vector

Postby ThorstenOtto » Sun Apr 21, 2019 8:53 pm

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.


Social Media

     

Return to “Coding”

Who is online

Users browsing this forum: No registered users and 1 guest