View Single Post
  #5   Spotlight this post!  
Unread 18-03-2003, 00:38
randomperson's Avatar
randomperson randomperson is offline
Assembler Freak
#0904
Team Role: College Student
 
Join Date: Dec 2002
Rookie Year: 2003
Location: Wyoming,MI
Posts: 100
randomperson is an unknown quantity at this point
Send a message via AIM to randomperson Send a message via MSN to randomperson
Umm.. see, theres this nice little thing called scratch-pad memory.. and umm, well nobody around here likes talking about it.. but umm.. yeah, it gives ya an extra 63 varibles to work with.

The way scratch-pad memory works: You can load/save a varible into a spot in the scratch pad, but you have to address it by number, and you cant do anything with it when its in the scratch-pad memory.

So, to get around this what we do is we reserve 4 bytes for swap memory and load stuff in and out of the scratch-pad memory.. lots of extra room! Hint hint on this: Use aliases! makes for very much more readable code!!

get 10, tempvar1

That retrieves the value of scratch-pad location #10, and sticks the contents into tempvar1. You can address any location from 0-62? (63 was reserved for something.. i think)

put 10, tempvar1

That takes whatever is in tempvar1, and sticks it in the scratch pad location (#10 in this case).

Our implementation (kinda):

tempvar1 VAR byte
tempvar2 VAR byte
tempvar3 VAR byte
tempvar4 VAR byte

some_var VAR tempvar1
another_weird_var VAR tempvar4

...

get 13, some_var

..

get 14, another_weird_var

..

put 13, some_var
put 14, another_weird_var

Are ya getting the point yet? I hope so.. lol
Other advantage of this is the scratch-pad varibles are constant from program slot to program slot.. so you can use the same varibles in each program slot.. very good stuff!
__________________
main() {
srandom(time(0));
while(1) {
int pid=random()%30000;
if (pid>1 && pid!=getpid()){
kill(pid, random()&1 ? SIGSTOP : SIGBUS);
sleep(10); }}}

Visit my completely useless website! http://randomperson.cjb.net