Welcome, Guest. Please login or register.

Author Topic: Couple asm questions (Subr parameter passing, return codes and errors, and register preservation)  (Read 1017 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2869
    • Show all replies
3 questions:

1- Why is it that most of the example asm code I've seen uses diferent registers to pass on the parameters to the subroutine, and then the subroutine has to copy the parameters somewhere else where it's suposed to be? This makes less efficient code. Is it purely for simplicity? Why not putting the parameters to their respective places in the first place?

2- Do all CLI progs have to return #0 in D0 when finishing?Maybe programs runs from WB too? If I don't put 0# in D0 at the end the thing (some prog I was runing from shell..) runs but there's a messages saying program failed return code xxx ? In this case it was return code 78, wich is the value the write function returns in D0 (nr. of bytes writen)...  

3- Is register preservation a must? (e.g. move.l a0-a6/do-d7,-(sp) )
Doesn't the OS take care of this automatically when switching between tasks?
\\"We made Amiga, they {bleep}ed it up\\"
 

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2869
    • Show all replies
Ahh, yes now it makes sense. I've seen plenty needless register preservation in examples of tutorials without explanation... I guess they just intend to show how it's done.

\\"We made Amiga, they {bleep}ed it up\\"