🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: rec.games.corewar
2 messages
2 total messages Started by John Morrow Sat, 12 Dec 1992 20:01
ICSW Standards Operands Question
#258
Author: John Morrow
Date: Sat, 12 Dec 1992 20:01
29 lines
1268 bytes
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
            ^^^^^^^^^^^^
>	sub bite @bite
>	sub #1 bite
>       mov fang @bite
>	add #10 bite
>	cmp #500 nprc 	
>	jmp start	

Thanks,

John Morrow
morrow@remus.rutgers.edu

PS - Sorry if this has been covered before at length...
Re: ICSW Standards Operands Question
#260
Author: 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
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