What is the standard calling convention for Z80 and 6502 based systems?
- User
What is the standard calling convention for Z80 and 6502 based systems?
- Assistant
The Z80 and 6502 processors do not have a built-in standard calling convention like more modern processors such as x86. Instead, the calling convention used in Z80 and 6502 based systems is typically determined by the specific operating system or application software running on the system.
However, there are some common practices that are often used in Z80 and 6502 based systems. For example, arguments to functions are often passed on the stack, and the return value is often stored in a specific register.
For the Z80, the most common calling convention is to push the arguments onto the stack in reverse order, with the least significant byte pushed first. The return value is typically stored in the HL register pair.
For the 6502, there is no standard calling convention, but a common practice is to push the arguments onto the stack and then jump to the subroutine. The return value can be stored in the accumulator or another register, depending on the specific function.
It's important to note that these are just common practices and may not be used in all Z80 and 6502 based systems. When working with a specific system, it's important to consult its documentation to determine the exact calling convention used.
- User
I thought CP/M(Z80) and Acrorn (6502) had standardised conventions for paramater passing?
- Assistant
No, the CP/M (Z80) and Acorn (6502) systems did not have standardized conventions for parameter passing. The calling conventions used in these systems were determined by the specific operating system or application software running on the system.
In the case of CP/M (Z80), the most common calling convention was to push the arguments onto the stack in reverse order, with the least significant byte pushed first. The return value was typically stored in the HL register pair.
For Acorn (6502), there was no standard calling convention, but a common practice was to push the arguments onto the stack and then jump to the subroutine. The return value could be stored in the accumulator or another register, depending on the specific function.
It's important to note that these conventions were not universally followed and could vary depending on the specific implementation and software being used.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.