Assembler - Pseudo Operations CBM Prg Studio

C64Studio currently only implements a subset of pseudo operations of CBMPRGStudio. These pseudo ops are supported:




ALIGN <alignaddress>[,<fillvalue>]

This pseudo op fills memory until a full multiple of alignaddress is reached.
If [fillvalue] is omitted 0 is used.



ALIGN $2 ;wait for even address ALIGN 256,$ff ;align code to page border, fill gap with $ff


DC.B, BYTE

This pseudo op allows to insert text, characters, or one ore more bytes at the current location.

Allowed are text literals, character literals, constant values, expressions and labels as content.
text literals are surrounded by ", character literals by '
Constant values can be set as decimal, hexadecimal (with prefixed $), chars (surrounded by ' or ").
Labels are treated as 16-bit values. To get the high or low byte prefix the label with < (low byte) or > (high byte)
Expressions are evaluated during the final pass. They must evaluate to a valid byte value.
CBM works like !TEXT, but reverses character casing.



DC.B "HELLO WORLD" BYTE 206,184,191,182,198,196,184,0,203,198,0,202,198,204,191,191,184,202,202,0,0


DC.W

This pseudo op allows to insert words (2 bytes) at the current location.

Allowed are constant values, expressions and labels as content.
Constant values can be set as decimal, hexadecimal (with prefixed $).
Labels are treated as 16-bit values.
Expressions are evaluated during the final pass. They must evaluate to a valid word value.



;inserts $80, $77 DW $7780


DS/DS.B/DS.Z <count>[,<value>]

This pseudo op fills the given value count times at the current location.
For the expression form the expression is evaluated for every byte. The expression inside the brackets uses the label "i" as index, ranging from 0 to count - 1. Any global "i" label is suspended inside the brackets and restored afterwards.



DS 64*4,0 DS.B 10 DS.Z 20


IF <expression>
ELSE
ENDIF

This pseudo op starts an conditional block. The conditional block is only evaluated if the expression yields a result not equal to zero. The opening curly brace must be on the same line.

IF checks if the expression is not equal zero, and if it is, all code until the next matching ENDIF are added.

A conditional block has to end with an ENDIF statement. An optional else statement may open an opposite conditional block.


IF DISK_LOAD ! TAPE_LOAD JMP $7780 ELSE JMP START_CODE ; start game ENDIF


INCBIN "<file name>"

This pseudo op inserts a file as binary data. The file name is required without apostrophes!



INCBIN "..\CHARS\LEVEL1.CHR"


INCLUDE "<file name>"

This pseudo op includes another source file at the current location. File names are used relative to the file containing the directive.



INCLUDE "PLOTDOWN.PDS"


MAC/MACRO <Function Name>
ENDM

This pseudo op defines a macro function. To end the body of a function specify ENDM
The number of parameters is variable.

To call a macro use <Function Name> [<Parameter 1>[,<Parameter 2>],..]

Parameters inside the macro are assigned to labels {1} upwards. Parameters are currently not supported.



MACRO name lda #5@1 EQU VARS rts ENDM ;call macro name


RORG <address>

This pseudo op alters the following assembly as if the current memory location was starting with the provided address.

Allowed are constant values, expressions and labels as content. Mainly useful for code that will be copied around or bank switched (cartridge). When setting REND the program counter is set to the proper location address again.



RORG $0400 ... REND


REND

This pseudo op is the counter part for RORG. The following assembly is used the proper memory location.

When setting REND the program counter is set to the proper location address again after a RORG.



RORG $0400 ... REND


SUBROUTINE [<zone name>]

This pseudo op declares a new zone. Any local labels (labels starting with '.') are only accessible inside their containing zone.



SUBROUTINE .locallabel ... SUBROUTINE NamedSubRoutine .locallabel


REPEAT <expression>
REPEND

This pseudo op repeats the block until REPEND for [expression] times.



REPEAT 4 inx iny REPEND


PROCESSOR, SEG, SEG.U

These pseudo op are merely included to safely allow assembling, but do not do anything.



PROCESSOR 6502 SEG SegmentA SEG.U UnknownSegment


ORG <address>[,<pseudo address>]

This pseudo op sets the current assembling address to [address] (similar to * = ...).

If [pseudo address] is set the following assembly is compiled as if the current memory location was starting with the provided address.

Allowed are constant values, expressions and labels as content. Mainly useful for code that will be copied around or bank switched (cartridge). When calling ORG without [pseudo address] the program counter is set to the proper location address again.



;set PC to $0801 ORG $0801 ;set PC to $8000, assemble as if it was set to $100 though ORG $8000, $100 ;restore proper PC to $8100 ORG $8100


INCDIR "<directory name>"

This pseudo op adds a directory to the search list. Files included via INCBIN or INCLUDE are searched in these directories.



INCDIR "DATA"