REGISTER | LOGIN
Breaking News
Comments
Newest First | Oldest First | Threaded View
<<   <   Page 6 / 8   >   >>
betajet
User Rank
Author
Uninitialized variables
betajet   1/8/2014 5:57:26 PM
NO RATINGS
In every Basic I've ever used the interpreter would tell you if you had an uninitialized variable.  In fact, one of my favorite computer pranks was when I was at the remote end of a software demo.  Two very clever guys from a different high school had created a program in Basic that allowed separate time-shared teletype sessions to chat, using shared files as storage.


OK, so they're in the other room and the program is working fine.  We're sending back and forth the usual "HELLO", "HOW ARE YOU?", "FINE THANKS", and other unimaginative messages you can expect from teen-agers who did math instead of literature.  I got a diabolical inspiration and sent the message "UNDEFINED VARIABLE IN LINE 1320".  They panicked, and started giving commands like "LIST" and "RUN", not realizing that the program was still running perfectly.  I dashed into the next room and asked "what happened?" and let them sputter a bit before confessing.

Chesler
User Rank
Author
Re: PROGRAM
Chesler   1/8/2014 5:32:09 PM
NO RATINGS
Wirth's Law: "Software is getting slower faster than hardware is getting faster."

 

I did take a Tic-Tac-Toe (on a cylinder or something funky) I'd written for Data Structures and it was an amazing example of Moore's Law. In 1982 each move took the computer about three hours. In 2005 the same code was running in interactive time (and I learned it was a very boring game, guaranteed win for the first mover.)

 

I don't recall pre-initialized variables, certainly not to 1, so I suspect there are lines missing, given there are no lines 50 or 60, and the GOTO 60.

David Ashton
User Rank
Author
Re: PROGRAM
David Ashton   1/8/2014 4:32:21 PM
NO RATINGS
@Chesler....you could initialise F by saying F=1 or F=N, but unless the machine defaults to initialising variables to 1 your initial program would not work.  But I don't know how that machine behaved....

> "What am I doing debugging/reverse engineering this?"

Well you can see how far you have come since those early days,,,,and a bit of nostalgia is always a good thing I find.

I loved playing with GWBASIC again but I was forever trying to position the cursor with the mouse, or cut and paste....NOT!  But as I remarked above, the power of that little program in 60K is awesome compared to todays's bloated code.  But then would I want to go back to Wordstar or MS-Word DOS versions without WYSIWYG?   I don't think so.....  Then again GWBASIC appears on the screen ready to work about 0.4 second after clicking it.  You never gain anything without also gaining a disadvantage.....

 

Chesler
User Rank
Author
Re: PROGRAM
Chesler   1/8/2014 3:50:08 PM
NO RATINGS
What am I doing debugging/reverse engineering this?
Since N is set to N-1 before the loop, I'm thinking F was initialized to N, not to 1.

I remember being amazed at how quickly the answer came back (relative to 110 baud -- but a state-of-the-art TI-30 of the same vintage has noticable lag coming back with a trig value) so maybe I was trying to be clever and save a multiplication.

 

David Ashton
User Rank
Author
Re: Working!
David Ashton   1/8/2014 2:40:41 PM
NO RATINGS
@Chesler....no problem, I had lots of fun with it.  (If MS had not updated everything I'd still be quite happy with DOS and BASIC and Wordstar :-)

In your original program, if Nwas input as 1, it would have got 1 subtracted from it first, and you would have got an endless loop.  Mine can cope with 1 but not 0 or negative Ns.  

I remember being taught that unconditional jumps like GOTO 60 were a no-no, and to use DO WHILE  or FOR N = x TO y instead.  Good point.

I did a FORTRAN course once and put and endless loop in a program, I got presented with a 2 inch high stack of paper and a very stern talking-to from the computer centre manager when I went to collect my printout.  We all have to start somewhere.....

Chesler
User Rank
Author
Re: Working!
Chesler   1/8/2014 10:32:25 AM
NO RATINGS
Thanks David Ashton.
I think Y-512 may have been my account on the timeshare.
No idea what was supposed to be at lines 40 and 50 (presumably one of them initialized F), or why they didn't save to the tape.
Line 85 :-)  I guess the day before I'd written my first endless loop!

betajet
User Rank
Author
Re: Working!
betajet   1/8/2014 9:39:11 AM
NO RATINGS
Now you just need to punch the updated program onto paper tape and you're done!

David Ashton
User Rank
Author
Working!
David Ashton   1/7/2014 11:22:33 PM
How about that!  You can still get good old GWbasic from here

http://gwbasic.webs.com/download.htm

or here, which has manuals as well

http://www.gw-basic.com/downloads.html

Pretty good value for 60K (yes K not M) of program!!

I got the program working -  as I thought, I had to initialise F and get the line numbers right for the jumps, but then it does work:

10  REM INPUT N, OUTPUT N!

20  PRINT "INPUT THE NUMBER THAT YOU WANT THE FACTORIAL OF"

30  INPUT N

35  F=1

70  IF N=1 THEN 100

80  F=F*N

85  N=N-1

90  GOTO 70

100  PRINT F

110  END

It only works up to N=30-something then it overflows.

Thanks guys, have not had this much fun in years!

 

David Ashton
User Rank
Author
PROGRAM
David Ashton   1/7/2014 10:36:42 PM
I decoded the whole thing (no, not too much time on my hands, just a boring job) and got

10  REM INPUT N ; OUUTPUT N! BY Y-512

20  PRINT "INPUT THE NUMBER THAT YOU WANT THE FACTORIAL OF"

30  INPUT N

40  N=N-1

70  IF N=1 THEN 100

80  F=F*N

90  GOTO 60

100  PRINT F

110  END

I can see how it is supposed to work but a couple of things here
  • in line 80 variable F is not initialised, maybe that machine initialised unknown variables to 1?
  • line 90 jumps back to line 60 which does not exist, probably should be line 40

If the above is true then it should work, multiply N by itself N times.

I don't have a BASIC machine to run it on, does anyone?

betajet
User Rank
Author
Re: scanner?
betajet   1/7/2014 1:38:36 PM
Oooh!  Even parity!  (More to come)

First line looks like:

10  REM INPUT N ; OUUTPUT N! BY Y-512

A good reference for an ASCII table and paper tape format is the DEC PDP-11 Peripherals Handbook, which is actually available at bitsavers.trailing-edge.com.  It's 28 MB, but all gold :-)

Page B-4 has an ASCII table in octal, which is the easiest way to decode paper tape.

Page B-5 shows how the bits are punched onto paper tape.  Bit 7 (MSb) is even parity on your tape, so ignore it.

Edit: You can also find a good example of paper tape and an ASCII table at Wikipedia.  However, Wikipedia's table is better suited for decoding hexadecimal.

 

<<   <   Page 6 / 8   >   >>


Like Us on Facebook
EE Life
Frankenstein's Fix, Teardowns, Sideshows, Design Contests, Reader Content & More
Martin Rowe

Test Tool Finds Ethernet Wiring Errors
Martin Rowe
Post a comment
When my house was renovated several years ago, I had the electrician install network outlets in numerous places, then run the LAN cables to a wiring closet. But he didn't document the ends ...

Martin Rowe

Local Electronics Store Supplies Engineers and Hobbyists
Martin Rowe
5 comments
Rochester, N.Y. — Tucked away in this western New York city known for its optics is Goldcrest Electronics, a local store that's supplied businesses and individuals with electronic ...

Martin Rowe

How to Transform a Technology University (Book Review)
Martin Rowe
1 Comment
The Presiding Genius of the Place by Alison Chisolm. WPI, Worcester, Mass., 234 pp., 2016. Engineers love to discuss, and often criticize, engineering education. They often claim ...

Max Maxfield

Aloha from EEWeb
Max Maxfield
Post a comment
Just a few minutes ago as I pen these words, I posted this blog about this month's Cartoon Punchline Competition over on EEWeb.com.