[译]磁芯大战(Core War)的语言Redcode教程

主题: Core War(磁芯大战)的Redcode简介
译者: Michael Zeng [[email protected]]
日期: 02-5-9 15:23
*转载请勿删改,谢谢*

原题:
Corewar Tutorial Pt INewsgroups: rec.games.corewar
From: [email protected] (Mark A. Durham)
Subject: Intro to Redcode Part I
Organization: Rice University, Houston, TX
Date: Thu, 14 Nov 1991 09:41:37 GMT

Redcode介绍
-----------------------


  I. 前言 - 读者注意!    { 第一部分 }
 
 II. 标记                  { 第一部分 }

III. MARS的特性           { 第一部分 }

 IV. 地址模式           { 第二部分 }

  V. 指令集           { 第二部分 }


----------------------------------------------------------------------

Introduction to Redcode
-----------------------


  I. Preface - Reader Beware!    { Part I }
 
 II. Notation                    { Part I }

III. MARS Peculiarities          { Part I }

 IV. Address Modes               { Part II }

  V. Instruction Set             { Part II }


----------------------------------------------------------------------


I. 前言 - 读者注意!

   The name "Core War" arguably can be claimed as public domain. 
Thus, any program can pass itself off as an implementation of Core
War.(译者:不会翻译呀~) 理论上,大家都希望在一个系统上写Redcode,
并且知道在所有其他系统上它都会以相同的方式运行.  哎呀,这没什么关系呀.


I. Preface - Reader Beware!

   The name "Core War" arguably can be claimed as public domain.
Thus, any program can pass itself off as an implementation of Core
War.  Ideally, one would like to write a Redcode program on one system
and know that it will run in exactly the same manner on every other
system.  Alas, this is not the case.

   Core War 有四种系统:非ICWS系统, ICWS'86, ICWS'88, 和扩展系统.
非ICWS系统通常与A. K. Dewdney在《科学的美国》上的一篇文章
"Computer Recreations" 中描述的Core War不同.ICWS'86 和 ICWS'88 系统则分别
遵循"International Core War Society"在1986年和1988年制定的规则.扩展系统
一般支持ICWS'86, ICWS'88规则,并有一定的扩展.我将会谈到常用的公共扩展,如果
它们在所有扩展系统上都可用的话(大部分都不是).


   Basically, Core War systems fall under one of four catagories:
Non-ICWS, ICWS'86, ICWS'88, or Extended.  Non-ICWS systems are usually
a variant of Core War as described by A. K. Dewdney in his "Computer
Recreations" articles appearing in Scientific American.  ICWS'86 and
ICWS'88 systems conform to the standards set out by the International
Core War Society in their standards of 1986 and 1988, respectively.
Extended systems generally support ICWS'86, ICWS'88, and proprietary
extensions to those standards.  I will discuss frequently common
extensions as if they were available on all Extended systems (which
they most certainly are not).


    我将不会在这里讨论非ICWS系统. 如果你能读懂这篇文章,你就可以轻易理解
大多数非ICWS系统. 虽然ICWS'86和ICWS'88被称为"标准",但是它们都受歧义性和
额外标准问题的困扰,我将尝试指出来.
   注意.  因为几乎所有的解释想别的一样合理,我自然更喜欢"我"的解释. 
我会尝试指出其他解释有歧义的地方,并清楚表明我的或其他人的相关解释.


   I will not describe Non-ICWS systems in this article.  Most Non-
ICWS systems will be easily understood if you understand the systems
described in this article however.  Although called "standards",
ICWS'86 and ICWS'88 (to a lesser extent) both suffer from ambiguities
and extra-standard issues which I will try to address.
   This is where the reader should beware.  Because almost any
interpretation of the standard(s) is as valid as any other, I
naturally prefer MY interpretation.  I will try to point out other
common interpretations when ambiguities arise though, and I will
clearly indicate what is interpretation (mine or otherwise) as such.
You have been warned!


----------------------------------------------------------------------


 II. 标记 

   "86:" 表示ICWS'86的特性.  "88:" 则表示ICWS'88的.  "X:" 表示扩展系统. 
"Durham:"表示我偏好的解释.  "其他:" 其他人的解释.  "注释:"表示我在做什么和
为什么这样.  "评论:" 表示我跟从或反对该做法.没有冒号后缀的可视为普通.

II. Notation

   "86:" will indicate an ICWS'86 feature.  "88:" will indicate an
ICWS'88 feature.  "X:" will indicate an Extended feature.  "Durham:"
will indicate my biased interpretation.  "Other:" will indicate
interpretations adhered to by others.  "Commentary:" is me explaining
what I am doing and why.  "Editorial:" is me railing for or against
certain usages.  Items without colon-suffixed prefaces can be
considered universal.


   Redcode由以下格式的汇编语言指令组成

<标签>   <操作符> <A-模式><A-字段>, <B-模式><B-字段>   <注释>

 

   Redcode consists of assembly language instructions of the form

<label>   <opcode> <A-mode><A-field>, <B-mode><B-field>   <comment>


Recode例程:

; Imp
; by A. K. Dewdney
;
imp     MOV imp, imp+1      ; 程序把自己复制到前面一个指令
        END                 ; 并且移动穿过内存

(译者注:IMP是最短的Core War战士,只有一句)

An example Recode program:

; Imp
; by A. K. Dewdney
;
imp     MOV imp, imp+1      ; This program copies itself ahead one
        END                 ; instruction and moves through memory.


<标签>是可选的.
86: <标签> 从第一列开始,1到8个字符长,必须以字母开头且由合法字符组成.
    不分大小写("abc"等同于"ABC").
88: <标签> 同上, 但长度不限和区分大小写.  只有前8个字符有意义
X: <标签>前面可以有任意多的空白(空格, TAB键,和新行), 长度任意,必须以字母
开头且由合法字符组成. ("abc" 不同于 "ABC").
注释: 我全用小写字母写 标签,这样来和操作符和操作数区分

The <label> is optional.
86: <label> begins in the first column, is one to eight characters
    long, beginning with an alphabetic character and consisting
    entirely of alphanumerals.  Case is ignored ("abc" is equivalent
    to "ABC").
88: <label> as above, except length is not limited and case is not
    addressed.  Only the first eight characters are considered
    significant.
X: <label> can be preceded by any amount of whitespace (spaces, tabs,
    and newlines), consists of any number of significant alphanumerals
    but must start with an alphabetic, and case is significant ("abc"
    is different from "ABC").
Commentary: I will always use lowercase letters for labels to
    distinguish labels from opcodes and family operands.


操作符 和<标签>之间用空白隔开.  操作符不区分大小写.  DAT, MOV,
    ADD, SUB, JMP, JMZ, JMN, DJN, CMP, SPL, 和 END 都是可用的操作符
86: SPACE 也作为一个操作符.
88: SLT 和 EQU 是操作符.  SPACE 不是.
X: 以上的和XCH,PCT都是操作符,还有无数的扩展.
注释: END, SPACE, 和 EQU是伪指令,因为它们向汇编程序指明了操作,但不
    产生可执行的代码.  我用大写的操作符来和<标签>,文本区分开.


The <opcode> is separated from the <label> (if there is one) by
    whitespace.  Opcodes may be entered in either uppercase or
    lowercase.  The case does not alter the instruction.  DAT, MOV,
    ADD, SUB, JMP, JMZ, JMN, DJN, CMP, SPL, and END are acceptable
    opcodes.
86: SPACE is also recognized as an opcode.
88: SLT and EQU are recognized as opcodes.  SPACE is not.
X: All of the above are recognized as opcodes as well as XCH a

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值