"poke" and "peek"
hitsware
Posts: 156
What is the nearest way to do this in PBasic ?
(refering back to the Basic on a Vic 20 )
??????
(refering back to the Basic on a Vic 20 )
??????
Comments
1) The program memory in an EEPROM. It can be read with a READ statement and written with a WRITE statement.
2) The data memory (for variables). This can be accessed directly using various variable names like W0 through W12 for word access or B0 through B25 for byte access. You can also access this or parts of this as a word array, byte array, nibble (4-bit) array, or an array of individual bits. See the PBasic manual for details.
3) Scratchpad RAM is available on all Stamp models except the BS1 and BS2. This is an area on the order of 64 or 128 bytes that's accessible with the GET and PUT statements.
for x =0 to 3
print x' debug ?
next x
I believe you would see what's possible if you were to read the sections of the manual I suggested.
From GWBasic:
10 for x=0 to 3
20 ? x
30 next x
I read the items in the BS ref. man., I have a similar product, RevEd, that's manual warns of "Special Function Registers" reserved for interperter and controller functions, that if altered, could adversely affect the IC by using the PEEK and POKE commands.
Are these SFR's acessible in the BS ? Just want to be sure to avoid them.
The SFRs are not accessable from PBasic. As far as you're concerned, they don't exist. The nice thing about the Stamp is that you can't get it into a "weird" state through programming that you can't get out of. If you have some minimal protective series resistors on the I/O pins (like 220 ohm), it's really hard to destroy the device, at least with +5V or lower exposure. All bets are off if you've got +12V or higher lying around or if you shuffle your feet around on your rug in the dry winter and poke your finger on an I/O pin. This is really great in an educational environment. It certainly works for many customers, including a number with significant industrial control products.
The flip side of this is that you can't use all the capability of the underlying hardware (SX or PIC) should you want to. On the other hand, Parallax does market the Javalin Stamp, various incarnations of the SX processor, and the Propeller, all of which are faster, more capable, more complex than the BS1 or BS2 series Stamps.
Post Edited (Mike Green) : 4/12/2007 4:20:44 AM GMT
Such "registers" exist, but as long as you stay away from the following data name constructs, you shouldn't have any problems:
Wn - As in W0, W1, W2, through W12
Bn· - As in B0, B1, B2, through B12
Moreover, you should be aware of the PBASIC Reserved Word list as found in Appendix B of the PBASIC Reference Manual. W0-W12 are mentioned therein.
Regards,
Bruce Bates
Post Edited (Bruce Bates) : 4/12/2007 8:20:50 AM GMT
I can make them work using your previous (thank you [noparse]:)[/noparse])
example, but (because I have used QBasic so long ?)·can't get
a real grip on what's happening with PBasic in creating arrays.
I have the manual but still don't quite get it.
There seems to be some paradyme shift between these 2 Basics ?
Again(QBasic):
for x=0 to 3
read n(x)
next x
data 1,2,3,4
for x=0 to 3
print·n(x)
next x
'prints:
1
2
3
4
Declaring the variables is no problem nor is DEBUG vs. "print"
I guess it will come to me.............. Just got my PWMPAL [noparse]:)[/noparse]
·
The BS2 has 26 bytes (26 BYTES) of memory -- actually, this is "register" memory. It also has 2,000 bytes of eeprom, which is both where your DATA values are stored, and where your 'tokenized' code is stored. Those are all the resources your programs have access to.
In a way, the VIC20 was more powerful. For one thing, it put out video that went to your screen. And you could plug in a cartridge that had a PROM in it, and I believe it had 22 KBytes of RAM, AND you could 'peek' and 'poke' registers on the sound generator, keyboard interface, and video interface chips.
However, you couldn't mount the VIC20 in a 24-pin socket and have it do anything useful, which the BS2 can.
Now, on the BS2, an 'array' is two or more 'register' memory locations. Also, you can address that memory as BITS, NIBBLES (4 bits), BYTE (8 bits) or WORD (16 bits).
Note that most people use the EEPROM ONLY for program storage. You can only write to each location a million times -- which is a lot if you're programming it once every 5 minutes, but isn't a lot if you WRITE to it under program control. 'READ'ing from it is free, though, so you're probably still in good shape.
I figure ((with a PWMPAL and a BS2)for sound generation)
I can do what the VIC20 did.
3 seperate freerunning 'squarewave oscillators'
(even a little bit of 'wave shaping'[noparse]:)[/noparse])
Enough left over pins to drive Vactrols.
The 'powerfullness' of the VIC20 and the C64 and
the 1rst IBMPC was that they booted up in BASIC
sans OS ....... IMO [noparse]:)[/noparse]
like a BIOS
It would be neat to have a piggyback (like the PWMPAL)
with a (ps2)keyboard in and vga out and and enough
memory and whatever else it takes to make the
whole thing run standalone. [noparse]:)[/noparse]
Adding all that to a lowly BS2 is WAY over-gilding the lily.
However, look into what Andre LaMoth is doing with the SX processor -- that may be more what you're looking for.
> is doing with the SX processor --
>that may be more what you're looking for.
The 'Hydra?' ?
NO!
His older model maybe ? [noparse]:)[/noparse]
(the $129 one (IIRC) ????
I.E. boots up in basic and runs standalone?
1) ps2 keyboard
2) ntsc monitor
3) ???? storage of programs (like the cassette with the VIC20)
4) the Basic would be on a cartridge ?
If you really want to program a Commodore computer - suggest you start with one of the portable Commodore 64 systems such as the DTV/Hummer galaxy22.dyndns.org/dtv/
Looks like the "Commodore 64" is only a game gizmo.
The PC platform makes a MUCH better game system computer. Try REALbasic if you want a nice IDE basic for doing games with.
If you want a programmable game machine, using a PC platform or the LaMothe platform are it. If you want to teach with a simple basic, download QBasic and run it on a PC.
The Propeller can function like a VIC20 with a PS/2 keyboard, NTSC monitor, SD card for PC compatible program storage and a simple Basic in EEPROM (known as FemtoBasic). All you need is a Demo Board, Protoboard with the Accessories Kit, or Hydra along with a breakout board for the SD card and a couple of wires from the breakout board to some I/O pins. You need to load the Basic interpreter once into EEPROM, then the whole thing is standalone. The current FemtoBasic is integer only and is more limited than the VIC20 Basic. It's more like PBasic in its abilities ... cost you under $100 for all the pieces.
My main 'thing' is algorhithmic music. (finding the equation for the 'lost chord' [noparse]:)[/noparse] )
The VIC20 was a little too limited in waveshapes (and frequencies), but I liked the simplicity. (set the note(s) and fire external envelopes).
I have been using a PC with QBasic and an OPL3 and this works very well, but the necessary commands are sort of tedious. (the Hydra synth looks good from this aspect)
Here's an example of one of my pieces done on a PC with Zel (a midi language):
http://home.comcast.net/~mnjmiller/koto.mid
Mike,
The Propeller is what got me started here. But I would need Win2k to load the Basic onto the EEPROM right. I do not at this time want to change OS (Win98) The pc I use in my lab (studio) is in fact dos only which makes the Stamps attractive. Also it would appear that the waveshapes need to be mapped and PWM'd out? I went through that with an Amiga and that was tedious also. Too much time spent on getting the sound is time away from getting the music. I could perhaps use the PWM (in FemtoBasic?) the same way I plan to with the PWMPAL (simply to set a frequency and assemitry of an (un)squarewave)
Geez the possibilities are endless [noparse]:)[/noparse]
Forrest,
Thanks. I'll look again, I must have missed something.
Here's another site that shows more hacks on this unit www.bigmech.com/misc/minic64/