My instructor gave us pseudocode to help with the writing of our program. Unfortunately, my instructor writes pseudocode in C, which is a language I mostly don't get. Anybody feel up to translating the parts I have pointers to?
buff: space 13
t3=a0
t9=0
t8=10
if (t3<0) then {t9=1, t3=-t3}
a0=&buff
a1=a0+12
mem(a1)=0 <-- this line
do{
high, low = t3 <-- and what the heck he's doing with this do statement?
t0=high
t3 = low
a1 = a1-1
t0 = t0+48
mem(a1) = t0}
while (t3>0)
if (t9=1) {a1=a1-1; mem(a1)="-"
while (a1 > a0)
{a1 = a1 -1
mem(a1)=" "
out << buff
return
no subject
Date: 2001-10-16 09:45 pm (UTC)Er... okay, I thought I knew C, but now *I*'m confused. And from the looks of it (out>>buff), he's using C++ conventions.
mem(a1)=0 is ... assigning a value to a function call? I'm pretty sure that doesn't work.
Neither does mem(a1)=" ", which would be assigning a string constant (!) to a function call (!!).
...
as for `high, low = t3`... I'm *guessing* he means this:
high = low = t3;
because high, low = t3 will (IIRC) do nothing to high and assign t3 to low. IIRC.
But ... he's got me confused, because those two lines at least don't make sense to me.
no subject
Date: 2001-10-16 10:41 pm (UTC)What I'm thinking he's trying to do at mem(a1)=0 is somethine along the lines of mem[a1]=0 or maybe free(a1), as in zeroing the memory block at a1.
And for the record, I'm betting this is assembly pseudocode, not C. Not that an untrained eye would see the difference. ^_^
no subject
Date: 2001-10-17 12:42 am (UTC)However, I'm guessing mem(a1) is a dereference - something along the lines of *a1 in C, or (I think?) [a1] in ASM. I could be wrong on that second one, I barely know ASM. only enough to recognize it.
but a0 and a1 are clearly memory addresses, because of a0=&buff. So mem(a1) must be a dereference. a1=a1-1 would be "move a1 back a space".
I think high and low are variable names, and he's setting them both to t3 in that spot. No, I don't get it either. But, wait, t3 appears to be a memory address also, because of t3=a0.
Bah. It's the occasionally double-purpose syntax of C, with the typeunsafety of ASM! lovely. (sarcasm, sarcasm.)
out << buff is definitely an output statement, and mem( whatever ) is definitely a dereference, and I have no idea what this does 'cause the guy (or girl) doesn't seem to close his (or her) curlybraces. Kill them all. Death and destruction.
Sorry I can't be more helpful, but maybe this'll be something :)