I'll try to keep the preamble short.
Yes, this is essentially "help me with my college homework", but I am super stuck on this (we're on hour 10, here).
Objective - write an assembly program that takes a character as input and outputs that character as uppercase.
I have reviewed the textbook, emailed my professor (response pending, but I'm like a dog with a bone - I can't leave this homework alone until it's done), and tried every possible permutation that I can think of. This example is almost identical to an example included in the pep/8 help (fig 6.34 I think? Whichever one is the boolean translation example) except that the characters are stored in #1cs instead of #2d.
Anyways, the core of the issue is that any time I try to access ch2 within the uprcse function, the program grabs the return address off the stack instead. From what I can tell I'm doing this the same as the examples are, and unfortunately it's impossible to find good online resources of the pep/8 (thanks, Python, for calling your standards pep8...) so I am limited in how furiously I can google.
Please view my code below and feel free to run it through your own pep8 and tell me what the heck I am doing wrong.
Please don't feel the need to do the stack overflow thing and point out every tiny flaw in my code - I know this could branch differently within the uprcse function. I mean, you can give little corrections if that's how you get your kicks / karma but... eh.
BR main
;
;******* char uppercase(char ch)
retVal: .EQUATE 2 ;returned value #1c
ch2: .EQUATE 1 ;formal parameter #1c
uprcse: LDBYTEA ch2,sx ;if ((ch >= 'a')
if: CPA 'a',i
BRLT else
LDBYTEA ch2,s ; && (a <= 'z'))
CPA 'z',i
BRGT else
then: LDBYTEA ch2,s ; return changed
SUBA 'a',i
ADDA 'A',i
STBYTEA retVal,s
RET0
else: LDBYTEA ch2,d ; return unchanged
STBYTEA retVal,s
RET0
;******* main ()
ch: .EQUATE 0 ;local variable #1c
main: SUBSP 1,i ;allocate #ch
STRO msg0,d ;cout << "Enter character, Zack" << endl
CHARI ch,s ;cin >> ch
LDBYTEA ch,s
STBYTEA -2,s ;store the value of age
SUBSP 2,i ;push #retVal #ch2
CALL uprcse ;ch = (uppercase(ch)
ADDSP 2,i ;pop #ch2 #retVal
LDBYTEA -1,s ;load retVal
STBYTEA ch,s
CHARO ch,s ;cout << ch << endl
CHARO '\n',i
ADDSP 1,i ;deallocate #ch
STOP
msg0: .ASCII "Enter character\n\x00"
.END