katster: (Default)
[personal profile] katster
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

Date: 2001-10-16 09:45 pm (UTC)
From: [identity profile] phenyx.livejournal.com
stupid me, forgot to preview...

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.

Date: 2001-10-16 10:41 pm (UTC)
From: [identity profile] shadur.livejournal.com
It'd probably help if he'd be so kind to at least properly close brackets... I concur with Kap on the high=low=t3 bit.

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. ^_^


Date: 2001-10-17 12:42 am (UTC)
From: [identity profile] zorbathut.livejournal.com
It ain't assembly, but it ain't C either. I think it's just confused ;)

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 :)

Note

My main blog is kept at retstak.org. I mirror posts to this Dreamwidth account, so feel free to read and comment either here or there.

November 2020

S M T W T F S
1234 567
891011121314
15161718192021
22232425262728
2930     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 18th, 2026 10:48 am
Powered by Dreamwidth Studios