glenda.party
term% ls -F
term% cat index.txt
REDCODE(6)                       Games Manual                       REDCODE(6)



NAME
       redcode - assembler for mars game

SYNOPSIS
       redcode file1 file2 ...

DESCRIPTION
       Redcode  is an assembler for the Redcode assembly language specified by
       Dr. Kee Dewdney in the "Computer Recreations" column in  the  May  1984
       issue  of  Scientific  American.   The  command line contains a list of
       source file names (including the extension  ".red")  to  be  assembled.
       The  result  is  a  corresponding number of object files with extension
       ".obj".  For example, the following command:

            redcode dwarf.red gemini.red imp.red

       would assemble these three programs and  create  files  dwarf.obj  gem‐
       ini.obj imp.obj.

SOURCE FILES
       A  source  file  consists  of a name directive which specifies the pro‐
       gram's name, followed by any number of  program  and  data  statements,
       followed  by  an end directive which specifies the starting location of
       the program.  Statements have the following syntax:

            [label] opcode arg1 [arg2] [; comment]

ADDRESSING MODES
       There are three addressing modes; all  address  calculations  are  done
       modulo 8000.

       Syntax         Meaning

       #[0-9]+        immediate
       [0-9]+         relative
       @[0-9]+        indirect, relative

OPCODES
       The following opcodes are implemented, along with the corresponding se‐
       mantics specified in  pseudo-C:  Instruction    Mnem Opcode    Args Ex‐
       planation

       Move      mov  1    A B  B=A
       Add       add  2    A B  B+=A
       Subtract  sub  3    A B  B-=A
       Jump      jmp  4    A    PC=A
       Jump if zero   jmz  5    A B  PC=(B==0)?A:PC+1
       Jump if greater     jmg  6    A B  PC=(B<4000)?A:PC+1
       Dec, Jmp if 0  djz  7    A B  PC=(--B==0)?A:PC+1
       Compare        cmp  8    A B  PC=(A==B)?PC+1:PC+2

PSEUDO-OPS
       The following non-executable directives may be used to reserve and ini‐
       tialize data space:

       Directive Mnem Arg  Explanation

       Buffer space   bss  n    Reserve n words
       Data      data A    Initialize 1 word
       Name      name 't'  Name of program
       End       end  start     Specify starting location

A SAMPLE REDCODE PROGRAM
       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       ;;; Dwarf, a sample Redcode program
       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

            name 'dwarf'
       site data -1        ; address of last 0 'bomb'
       start     add  #5   site ; move site forward
            mov  #0   @site     ; write 0 'bomb'
            jmp  start          ; loop
            end  start

OBJECT FILES
       For documentation on the object code format, see mars(6).

SEE ALSO
       mars(6)

HISTORY
       20-May-84 Paul Milazzo (milazzo) at RICE
              Created.



                                    5/20/84                         REDCODE(6)