Thoughts on Rails

Riding the Train of Thought

Learning Programming

leave a comment »


While chatting at #emacs on freenode today, somebody mentioned this link to me http://mitpress.mit.edu/sicp/

Well, it's not like I have'nt been to that page before, but this time I took it seriously and am reading through the book. Need to finish as much as possible (in 24 hours) and then again catch up with Mathematics.

Now something regarding SmaCK (yeah the same old link… http://data.freeshell.org/projects/smack/)

I have included a indirect addressing hack in the Python version of the emulator. (It exists in the C version too, but the methods of using 'pointers' are bit akward in it so it's negligible.)

But it has come to my notice, that it is possible to use indirect addressing in an even more hackish way by modifying your programs in the runtime!! Lisp hackers, please don't laugh, it's something new for me.

So suppose you wish to use memory like an array and traverse the array… how do you do it?

First, set up the loop (at least in your head…)
Second, have a variable, say at momory location location 101 that holds the 'index' (0, 1, 2, 3, …)
For every instance, load the location 101 into accumulator. (1101)
Add the base memory location to it (Ex: 30500)
Now the accumulator has '500' + the index …

NOW comes the hacking part 😀

You take the opcode of the instruction you really want to perform on that location (say output… 8) and add 1000 to it, forming 8000. Note: do this at design time… and let the accumulator alone – it's holding the memory location already.

Add this '8000' to the accumulator (Ex: 308000) and then store the content in a special place. (2xxx)

Secret: this special place (xxx) is the address of the very next instruction in your program.

I'm excited about this discovery and am going to write a program that uses this idea while the download completes…


$ fortune
By doing just a little every day, you can gradually let the task
completely overwhelm you.
$

Advertisements

Written by hiway

August 1, 2004 at 8:54 am

Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: