Syntax of RASM

The syntax supported by RASM is flexible. It is not necessary to indent your sources, except for aesthetic reasons. It is not necessary to use the ":" symbol to define a label, although it is possible to do so. The colon will simply be ignored.

Files can be in windows or linux format, an internal and transparent conversion will be done.

RASM is not case sensitive, all letters are converted to uppercase, so don't be surprised to see only uppercase in error messages (except extended display). Symbols are also exported in uppercase by default, but it is possible to export them in case-sensitive form with the command line option -ec

Do not try to give an identical name to a label, a macro, an alias, a variable, the error will be fatal.

Comments

The comments input in RASM is classical and preceded by a semicolon. All following characters are ignored until the next carriage return. It is also possible to use the C syntax, i.e. the double slash (//) to start a comment, as well as the markers /* and */ to delimit comment blocks on several lines.

Labels

Labels are used to name a memory address linked to code or data. It is not necessary to place them at the beginning of a line or to follow them with ":".

There are special labels (see chapter on labels) called context labels (proximity, local, breakpoints)

Z80 mnemonics

All documented and undocumented instructions are supported.

The 8-bit addressing of the index registers IX and IY is done with LX, IXL or XL, etc.

Complex instructions with IX and IY are written as follows:

RES 0,(ID+d),r

Undocumented instructions

out (<byte>),a
in a,(<byte>)
in 0,(c)
in f,(c)
sll <register or memory>
sl1 <register or memory>

Special syntax

There is some shortcuts to keep to code clean and compact

PUSH BC,DE,HL => PUSH BC:PUSH DE:PUSH HL

POP BC,DE,HL => POP BC:PUSH DE:PUSH HL

NOP 5 => NOP:NOP:NOP:NOP:NOP

LD BC,BC => LD B,B:LD C,C
LD BC,DE => LD B,D:LD C,E
LD BC,HL => LD B,H:LD C,L
LD DE,BC => LD D,B:LD E,C
LD DE,DE => LD D,D:LD E,E
LD DE,HL => LD D,H:LD E,L
LD HL,BC => LD H,B:LD L,C
LD HL,DE => LD H,D:LD L,E
LD HL,HL => LD H,H:LD L,L
LD HL,(IX+n) => LD H,(IX+n+1):LD L,(IX+n) ; idem avec BC et DE
LD (IX+n),HL => LD (IX+n+1),H:LD (IX+n),L ; idem avec BC et DE

LD HL,SP => LD HL,0 : ADD HL,SP ; warning: flags modified!

EXA => EX AF,AF'

SRL BC => SRL B : RR C
SRL DE => SRL D : RR E
SRL HL => SRL H : RR L

SRA BC => SRA B : RR C
SRA DE => SRA D : RR E
SRA HL => SRA H : RR L

SLL BC => SLL C : RL B
SLL DE => SLL E : RL D
SLL HL => SLL L : RL H

SLA BC => SLA C : RL B
SLA DE => SLA E : RL D
SLA HL => SLA L : RL H

RR BC => RR B : RR C
RR DE => RR D : RR E
RR HL => RR H : RR L

RL BC => RR C : RR B
RL DE => RR E : RR D
RL HL => RR L : RR H

RLC BC => SLA B : RL C : RR B : RLC B
RLC DE => SLA D : RL E : RR D : RLC D
RLC HL => SLA H : RL L : RR H : RLC H

RRC BC => SRL B : RR C : RL B : RRC B
RRC DE => SRL D : RR E : RL D : RRC D
RRC HL => SRL H : RR L : RL H : RRC H

SRL8 BC => LD C,B : LD B,0
SRL8 DE => LD E,D : LD D,0
SRL8 HL => LD L,H : LD H,0
SRL8 IX => LD XL,XH : LD XH,0
SRL8 IY => LD YL,YH : LD YH,0

RST Z,#38 => JR Z,$+1 ; RST #38 opcode is the relative address!
RST NZ,#38 => JR NZ,$+1
RST C,#38 => JR C,$+1
RST NC,#38 => JR NC,$+1
Sauf mention contraire, le contenu de cette page est protégé par la licence Creative Commons Attribution-ShareAlike 3.0 License