Welcome to GameHourz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Better concept for a mini cpu: Load instructions from the ..

 
   Game Forums (Home) -> Core War RSS
Next:  AlternativeBootProgramForThreadsV1 (Could scale b..  
Author Message
Skybuck Flying

External


Since: May 25, 2006
Posts: 295



(Msg. 1) Posted: Tue Dec 11, 2007 12:54 am
Post subject: Better concept for a mini cpu: Load instructions from the instruction pointer into the minicpu, like an instruction register, and execute it there ;)
Archived from groups: rec>games>corewar (more info?)

Hello,

The first minicpu I tried had many drawbacks... but maybe also some
adventages... but for a moving warrior the minicpu is unusuable... because
the real instruction pointer always moves forward by 1, and the warrior
moves forward by 1 so this cancels out each other... and the warrior will
always execute the same instruction over and over again... this could be
nice... but it would also be nice if a moving warrior can have a mini cpu
embedded so that it can even have normal program flow while it moves !

And for that to work it must have a good functioning cpu ! =D

However writing a fully functionaly cpu might require lot's of working and
maybe even lot's of instructions... but for those that dare to write one
here are some little hints to help you out, here goes:

1. Consider the program to be executed to be main memory.
2. Consider the minicpu to have it's own local memory.

3. The minicpu should load instructions from main memory, into it's local
memory.
4. The minicpu should execute the instruction located inside it's local
memory.

Thus some easy concepts:

The minicpu should have:

1. An instruction pointer which it can increment, decrement, add, subtract.
2. An instruction register where instructions from main memory, via the
instruction pointer, will be loaded to.
3. The cpu should execute the instruction which is loaded inside the
instruction register.

There are more difficulties to overcome:

The cpu should not execute jump statements. Instead the cpu should add the
jump parameter to the instruction pointer.

And then there are other problems like addressing modes.

In short it might be quite a task to write a good functioning mini cpu
inside redcode ! Smile

Sigh.. I might try to write a minicpu myself... if anyone already wrote
one... please share that will save me some time Wink

There go folks ! Some hints for ya ! =D

Bye,
Skybuck.

 >> Stay informed about: Better concept for a mini cpu: Load instructions from the .. 
Back to top
Login to vote
Skybuck Flying

External


Since: May 25, 2006
Posts: 295



(Msg. 2) Posted: Tue Dec 11, 2007 1:09 am
Post subject: Crazy alternative idea for a MiniCPU, serial-threaded. [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Then again... maybe the minicpu will never working inside a moving warrior,
if and only if the minicpu needs to execute compares and jumps...

Because if it needs to execute compares or jumps then ofcourse the threads
which would execute the cpu in serial-threaded fashion... would start
executing elsewhere and would never return to their true position ?!

This could be a problem !

So maybe I need to try a totally different cpu with that crazy idea of mine:

A couple of threads:

1. Thread 1 stores the instruction at the instruction pointer.
2. Thread 2 splits off execution to the instruction pointer
3. Thread 3 bombs the instruction at the instruction pointer
(To bomb is to try and kill splitted off processes.)
4. Thread 4 restores the execution at the instruction pointer.
5. Thread 5 increments the instruction pointer.
(Something like that)

6. Programs could modify the instruction pointer directly instead of using
jumps and such.

Only problem which remains is with jumps and spl's and compares and such
which jump somewhere else...
Those instructions will never get bombed ?! so they will keep executing ?!
hmmmmmmm.

Maybe three other threads can be used which store and bomb the indirect
locations

like:

Thread 1b stores the indirect instruction from the instruction pointer.
Thread 2b bombs the indirect instruction from the instruction pointer.
Thread 4b restores the indirect instruction from the instruction pointer.

This could actually solve the problem... as long as the program makes sure
to change the instruction pointer when needed...

Could work ! Nice idea ! =D

Bye,
Skybuck.

 >> Stay informed about: Better concept for a mini cpu: Load instructions from the .. 
Back to top
Login to vote
Skybuck Flying

External


Since: May 25, 2006
Posts: 295



(Msg. 3) Posted: Tue Dec 11, 2007 1:12 am
Post subject: Re: Crazy alternative idea for a MiniCPU, serial-threaded. [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Skybuck Flying" <spam RemoveThis @hotmail.com> wrote in message
news:fjkoqp$p2i$1@news4.zwoll1.ov.home.nl...
> Then again... maybe the minicpu will never working inside a moving
> warrior, if and only if the minicpu needs to execute compares and jumps...
>
> Because if it needs to execute compares or jumps then ofcourse the threads
> which would execute the cpu in serial-threaded fashion... would start
> executing elsewhere and would never return to their true position ?!
>
> This could be a problem !
>
> So maybe I need to try a totally different cpu with that crazy idea of
> mine:
>
> A couple of threads:
>
> 1. Thread 1 stores the instruction at the instruction pointer.
> 2. Thread 2 splits off execution to the instruction pointer
> 3. Thread 3 bombs the instruction at the instruction pointer
> (To bomb is to try and kill splitted off processes.)
> 4. Thread 4 restores the execution at the instruction pointer.

Little typo:

4. Thread 4 restores the instruction at the instruction pointer.

> 5. Thread 5 increments the instruction pointer.
> (Something like that)
>
> 6. Programs could modify the instruction pointer directly instead of using
> jumps and such.
>
> Only problem which remains is with jumps and spl's and compares and such
> which jump somewhere else...
> Those instructions will never get bombed ?! so they will keep executing ?!
> hmmmmmmm.
>
> Maybe three other threads can be used which store and bomb the indirect
> locations
>
> like:
>
> Thread 1b stores the indirect instruction from the instruction pointer.
> Thread 2b bombs the indirect instruction from the instruction pointer.
> Thread 4b restores the indirect instruction from the instruction pointer.
>
> This could actually solve the problem... as long as the program makes sure
> to change the instruction pointer when needed...
>
> Could work ! Nice idea ! =D
>
> Bye,
> Skybuck.
>
 >> Stay informed about: Better concept for a mini cpu: Load instructions from the .. 
Back to top
Login to vote
Skybuck Flying

External


Since: May 25, 2006
Posts: 295



(Msg. 4) Posted: Tue Dec 11, 2007 3:13 am
Post subject: Not so crazy, it's working =D Serial-Threaded CPU, oh yeah baby. [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Yes the idea is working.

I had to experiment a bit with the correct order of the threads etc, and the
instructions etc...

But now it's working and I fully understand how it should and must work and
I also understand possible future improvements.

Here is the algorithm for now:

; The following algorithm for a thread-serialized-cpu is working ! (just a
few little offset problems because of relative addressing with the
pointers):
; The algorithm could be slightly modified to use subtractions instead of
previous pointers to determine the previous pointers etc
; this as I said will have to wait until tomorrow Smile

; <- restore previous previous instruction at previous previous instruction
pointer
; <- bomb previous instruction pointer
; <- execute/split off at current instruction pointer
; <- store previous instructon as previous previous instruction
; <- store current instruction at instruction pointer as previous
instruction
; <- store previous instruction pointer as previous previous instruction
pointer
; <- store current instruction pointer as previous instruction pointer
; <- increment current instruction pointer

Full code/demonstration is posted in another usenet-thread Smile

Bye,
Skybuck.
 >> Stay informed about: Better concept for a mini cpu: Load instructions from the .. 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Score Surface for 94nop - Hi, some anonymous person (still called "bvowk" for simplicity ;-) is so kind to provide access to a pile of computers. I have suggested to calculate one score surface for standard settings. It takes roughly 1000 times the time of one "no...

Bug in pMARS - Hi, either I don't know how EQUs work or I have found a bug in the parser of pMARS. So far I cound pin it down to: ;redcode-tiny ;name test ;assert CORESIZE == 800 v3 EQU 3 * (3 / 2 + 1) + 3 v4 EQU (CORESIZE - v3) dat.f v3, v4 With the..

KOTH.ORG: Status - ICWS Experimental 94 03/06/06 - Weekly Status on 03/06/06 -=- irc.KOTH.org is up! Meetings held in #corewars -=- Tons of new features on www.KOTH.org/koth.html pages -=- *FAQ* page located at: www.KOTH.org/corewar-faq.html Current Status of the KOTH.ORG ICWS Experimental 94..

KOTH.ORG: Status - MultiWarrior 94 03/06/06 - Weekly Status on 03/06/06 -=- irc.KOTH.org is up! Meetings held in #corewars -=- Tons of new features on www.KOTH.org/koth.html pages -=- *FAQ* page located at: www.KOTH.org/corewar-faq.html Current Status of the KOTH.ORG Multiwarrior 94 CoreWar..

KOTH.ORG: Status - 94 No Pspace 03/06/06 - Weekly Status on 03/06/06 -=- irc.KOTH.org is up! Meetings held in #corewars -=- Tons of new features on www.KOTH.org/koth.html pages -=- *FAQ* page located at: www.KOTH.org/corewar-faq.html Current Status of the KOTH.ORG 94 No Pspace CoreWar Hill...
   Game Forums (Home) -> Core War All times are: Ekaterinburg, Islamabad, Karachi, Tashkent (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]