Thread View: rec.games.corewar
2 messages
2 total messages
Started by Ingo Wilken
Mon, 11 Jan 1993 00:47
my error or MARS bug?
Author: Ingo Wilken
Date: Mon, 11 Jan 1993 00:47
Date: Mon, 11 Jan 1993 00:47
66 lines
2476 bytes
2476 bytes
Hi,
I'm new to this game, and I'm wondering if I found a bug in the MARS
program (Amiga, MADgic Core 4.1 by Mark A. Durham) or am I just
misinterpreting something.
This piece of code should bomb an area "just in front" of itself, and
selects its targets with a Fibonacci series:
firewall DAT #0 #0
bombing MOV bomb @fib1
MOV fib1 ftmp
ADD fib0 fib1
MOV ftmp fib0
CMP #-233 fib1
JMZ bombing firewall
MOV fcp1 fib1
MOV fcp0 fib0
JMZ bombing firewall
fib1 DAT #0 #-5
fib0 DAT #0 #-3
ftmp DAT #0 #0
fcp1 DAT #0 #-5
fcp0 DAT #0 #-3
bomb DAT #0 #0
END bombing
Coresize is 8000, and my program gets loaded to address 4000.
This is a coredump ;-) of the area:
4000: DAT #0000, #0000
4001: MOV 0014, @0009
4002: MOV 0008, 0010
4003: ADD 0008, 0007
4004: MOV 0008, 0007
4005: CMP #7767, 0005
4006: JMZ 7995, 7994
4007: MOV 0006, 0003
4008: MOV 0006, 0003
4009: JMZ 7992, 7991
4010: DAT #0000, #7995
4011: DAT #0000, #7997
4012: DAT #0000, #0000
4013: DAT #0000, #7995
4014: DAT #0000, #7997
4015: DAT #0000, #0000
Seems ok so far. Now, from my interpretation of the ICWS-88 text
("redcode-icws-88" from soda.berkeley.edu), the B-field of the first MOV
should be processed like this:
Read the b-field of 4010 (=> 7995), add the PC (=> 11996), then modulo
coresize (=> 3996). Result: Copy the bomb from 4015 to 3996.
But the simulator does something else, it copies the bomb to 4005!
It seems that instead of adding the address of the current instruction (4001)
it adds the address of the DAT (4010).
Now who's wrong?
Ingo
--
Ingo Wilken, CS Student, Univ.of Oldenburg, FRG | You mean I really did all of
wilken@uniol.uucp (..!uunet!unido!uniol!wilken) | dat stuff? Now dat explains
Ingo.Wilken@arbi.informatik.uni-oldenburg.de | why my head hurts an' why I
wilken@uniol.zer IRC:Nobody OL:ingo@faramir | feel so bad! -Snarf
Re: my error or MARS bug?
Author: Scott W. Adkins
Date: Mon, 11 Jan 1993 05:55
Date: Mon, 11 Jan 1993 05:55
40 lines
2443 bytes
2443 bytes
In article <1993Jan11.011528.17746@arbi.Informatik.Uni-Oldenburg.DE> Ingo.Wilken@arbi.informatik.uni-oldenburg.de (Ingo Wilken) writes:
>
>4001: MOV 0014, @0009 ------+
>.... |
>4005: CMP #7767, 0005 <-+ | Example of indirection...
>.... | |
>4010: DAT #0000, #7995 --+ <-+
>....
>4015: DAT #0000, #0000
>
>Seems ok so far. Now, from my interpretation of the ICWS-88 text
>("redcode-icws-88" from soda.berkeley.edu), the B-field of the first MOV
>should be processed like this:
>Read the b-field of 4010 (=> 7995), add the PC (=> 11996), then modulo
>coresize (=> 3996). Result: Copy the bomb from 4015 to 3996.
>
>But the simulator does something else, it copies the bomb to 4005!
>It seems that instead of adding the address of the current instruction (4001)
>it adds the address of the DAT (4010).
The simulator is correct and you are just misinterpreting the ICWS-88 text
(which is amazingly easy to do, imho). It all comes down to this meaning:
For indirect operands, take the value of the indirect mode for the current
instruction and use it to fetch the instruction it is pointing to. (i.e.
@9 means fetch the instruction that is PC+9 locations away). With this
newly fetched instruction, uses its B-Field as an offset from *that*
location to fetch yet a newer instruction...
So, in the above example, the "4001: mov 14, @9" means that @9 points
to 4001+9=4010 which is "4010: dat #0, #-5". The #-5 is then used to
calculate the new offset from *that* location (i.e. 4010), which is
4010-5=4005 which is "4005: cmp #-233, 5".
Well, I hope this will help clarify things... Good luck!
Scott
--
Scott W. Adkins Internet: sadkins@ohiou.edu
~~~~~~~~~~~~~~~ ak323@cleveland.freenet.edu
Ohio University of Athens Bitnet: adkins@ouaccvma.bitnet
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads