So, I'm new to the 65C02 scene, and I'm writing some procedures in assembly.
When a procedure has both a signed integer and unsigned integer version, is it idiomatic in the 65C02 or X16 communities to prefer one over the other in naming?
One procedure I'm writing is itop_8 (8-bit integer to petscii). Should I prefer for example itop_8 and sitop_8, or itop_8 and uitop_8? Should I label both of them?
Thoughts?
signed vs unsigned naming conventions
Re: signed vs unsigned naming conventions
This is going to vary from person to person.
My personal notation is "u8" for unsigned byte, "s8" for signed byte, and then u16, s16, etc, so something like "itop_u8", "itop_s8".
My personal notation is "u8" for unsigned byte, "s8" for signed byte, and then u16, s16, etc, so something like "itop_u8", "itop_s8".
Re: signed vs unsigned naming conventions
Generally speaking, the industry seems to expect signed numbers as "normal" and unsigned as the exception.
Consider C++, the cornerstone of the software industry: the standard int type is a signed, 16-bit or 32-bit number (depending on your CPU's word size.) You have to explicitly ask for it if you want an unsigned int.
In c#: int is signed, and you have to use the uint type if you want unsigned.
In Java: int is signed, and you have to use special functions to do unsigned math.
Based on these examples, I'd suggest: itop_8 for signed numbers and uitop_8 for unsigned.
As a side note: are you rolling your own algorithm for that, or are you using Butterfield's solution that leverages decimal mode?
Consider C++, the cornerstone of the software industry: the standard int type is a signed, 16-bit or 32-bit number (depending on your CPU's word size.) You have to explicitly ask for it if you want an unsigned int.
In c#: int is signed, and you have to use the uint type if you want unsigned.
In Java: int is signed, and you have to use special functions to do unsigned math.
Based on these examples, I'd suggest: itop_8 for signed numbers and uitop_8 for unsigned.
As a side note: are you rolling your own algorithm for that, or are you using Butterfield's solution that leverages decimal mode?
Re: signed vs unsigned naming conventions
I'm using my own, but I figured I'd use decimal mode too. I haven't seen his, but mine is likely extremely similar.
I like to try my own hand at doing something before checking google to see what the widely accepted algorithm is. It's much more fun that way. I find once I look at a problem one way, it is harder to think about it in a completely different way. Not impossible, but harder.
Because this is all written in assembly language I think I might go with labeling both.
Having a lot of fun learning 6502 assembly and the CX16! It's a great system to explore and have fun with.
Thank you both for the help.
I like to try my own hand at doing something before checking google to see what the widely accepted algorithm is. It's much more fun that way. I find once I look at a problem one way, it is harder to think about it in a completely different way. Not impossible, but harder.
Because this is all written in assembly language I think I might go with labeling both.
Having a lot of fun learning 6502 assembly and the CX16! It's a great system to explore and have fun with.
Thank you both for the help.