🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: rec.games.corewar
Article #260

Re: ICSW Standards Operands Question

#260
From: Jeff Raven
Date: Sat, 12 Dec 1992 21:02
57 lines
2807 bytes
In article <Dec.12.15.00.59.1992.1713@foghat.rutgers.edu>,
morrow@foghat.rutgers.edu (John Morrow) says:

>I found the following sort of code in some of the examples I was
>looking at (the following is a fragment from "vampire.cw") and was
>wondering if the operand "#(spin-bite)" on the line labeled "start"
>was allowed under ICSW-88 standards.  If so, then what are the
>rules governing mathamatical operations within operands, ESPECIALLY
>where it concerns immediate addressing.  This strikes me as being
>a bit "high level" compared to the way the rest of things are done.

>>nprc   dat 500
>>spin   spl 0
>>       djz 2 nprc
>>fang   jmp @1
>>bite   dat 1000
>>start  mov #(spin-bite) @bite
>            ^^^^^^^^^^^^

Well, there're two ways of answering this question, depending on what
you think that code actually does -

1. Moves the difference between the fields of 'spin' and 'bite' to the
location pointed at by 'bite'.

2. Moves the difference between the core addresses of 'spin' and 'bite'
to the location pointed at by 'bite'.

So, in case one, this amounts to MOV #(0 - 1000), @bite - a rather
complicated instruction for a simple assembly language like Redcode.
Furthermore, since the fields of 'spin' and 'bite' change as the program
executes, this command can't be simplified during assembly.

Case two, on the other hand, boils down to MOV #((-4) - (-1)), @bite
- or simply MOV #-3, @bite. This is simple. Furthermore, since 'bite'
and 'spin' always have the same relative addresses, their difference
will always be -3, and the command can therefore be simplified during
assembly.

So, what do we have? Case one - a rather complicated sort of command,
which will, after assembly, remain a rather complicated command. Then
we have case two - a less comlicated command, which after assembly
yields a fairly simple instruction.

Which is right? Case two. Here's why - whenever a label appears in the
field of an instruction, it is always interpreted as the *address* of
the line the label appears on. Because of this, and since the addresses
of each label can be determined during assembly, it is always possible
to simplify any such equation. As a result, the actual code that is
sent to the MARS doesn't have any equations at all - each has been
reduced to the form '??? value, value'.

Is that any help?

Jeff Raven
jar129@psuvm.psu.edu
Technical Details
Message-ID: <92347.160254JAR129@psuvm.psu.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!uwm.edu!psuvax1!psuvm!jar129
References: <Dec.12.15.00.59.1992.1713@foghat.rutgers.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!uwm.edu!psuvax1!psuvm!jar129
Organization: Penn State University
Date: Sat, 12 Dec 1992 16:02:54 EST
From: Jeff Raven <JAR129@psuvm.psu.edu>
Message-ID: <92347.160254JAR129@psuvm.psu.edu>
Newsgroups: rec.games.corewar
Subject: Re: ICSW Standards Operands Question
References:  <Dec.12.15.00.59.1992.1713@foghat.rutgers.edu>
Lines: 57