View Single Post
  #2   Spotlight this post!  
Unread 29-11-2002, 14:03
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
I'll se what I can do:

1) Two's complement: Two's complement is a way of representing negative numbers in binary. It comes from the way processors work and generally makes life very easy as it allows you to just add two numbers and ignore their signs. For example:
The two's complement of -1 (in eight bits) is: 11111111. Adding 1 yields 100000000. However, because we are only dealing with eight-bit numbers, that leading 1 is chopped off and you get 0, as it should be. Likewise, adding -1 and -1 gives 111111110. Drop the leading one and you get 11111110, which is -2. To convert a positive number to its negative, invert all the bits and add 1. The only thing you really need this for is to realize that the Stamp processors will interpret -1 as 65000 something.

2) Short answer: no, the processor only has 26 bytes worth of registers. Long answer: see answer to question 3.

3) Put will place a value in scratchpad. The scratchpad is basically a 64-byte block of memory where you can store stuff you aren't using at that particular moment. For example, if you want to store two bytes of data between loops, but you only have enough space for one variable, you could "put" these two values on scratchpad and retrieve them when you need them, one at a time. Note that you must do a "get" to fetch the value you put on scratchpad into a variable so you can use it in calculations.

4)EEPROM is where your program is stored, but you can also put data there. However, it is very slow to Read/write (the eeeprom equivalents of get/put) and writing to an individual location more than 1000000 times could cause that location to go bad. A lot of people use eeprom to store large tables of data as it is 2048 bytes. Also take a look at the "data" command if you are interested in doing this and the normal lookup/lookdown doesn't meet your needs.

5) ~ will compute the bitwise-not of a number, meaning each individual bit will be inverted. You shouldn't use it unless this is what you want. Instead, do something like: "if not (p1_x = 127)..." ALWAYS use parenthesis with "not" as you could get some very unexpected results otherwise.

<shameless plug>
If you haven't already, try download RoboEmu, either for Windows or Linux. It supports everything mentioned above and will let you play with all these commands without the need for an actual RC/OI at your house.
</shameless plug>
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php