Greetings,
I know this is totally OT and I will delete it promptly if deemed innapropriate. However, I also know there are many code gurus and smart fellows that frequent this forum and that this is THE place to get a definitive answer.
I am currently involved in a home study course for my A.A.S degree in electronics. I am just finishing a module on the 68HC11 microcontroller. All programming up to this point has been assembly and machine code. But, at the very end, they stuck in a VERY brief intro to C programming and added a few questions in the exam concerning C programs for the 68HC11. I am having a problem with one very simple question. The question reads:
"Write a small program that will multiply the character variables X and Y if Y>X; otherwise it will perform an integer divide, X/Y."
My concern is that if I declare X and Y as "char" data types, the compiler will only RMB 1 for each. In this case, I think the IDIV instruction wont work properly because it fetches a 16 bit dividend and divisor. In either case I think I should declare Z (product or quotient) as "int" data type because bothe the MUL and IDIV instructions produce a 16 bit result. I am not sure how to handle this. Any help would be appreciated.
This is not cheating since this exam is open book and I am allowed to use "any resource" available.
Ken