Skip to content

6502 Assembler

Chysn edited this page Jan 23, 2022 · 22 revisions

To assemble instructions, enter

.A addr mne [operand]

where addr is a valid 16-bit hexadecimal address, mne is a 6502 mnemonic, and operand is a valid operand. A description of the 6502 instructions is beyond the scope of this document.

wAx will assemble the instruction at the specified address. If the instruction was entered in direct mode, wAx will provide a prompt for the next address after the instruction. You may enter another instruction, or press RETURN.

Note that the comma is an alias for A:

., addr mne [operand]

Comments

wAx stops parsing text after a semicolon, so everything after a semicolon is a comment.

.A 1800 AND #$01 ; MASK BIT 0

Immediate Mode Operands

wAx supports several types of operands for immediate mode instructions (e.g., LDA #)

.A 1800 LDA #$0C        ; HEX BYTE
.A 1802 LDY #"J"        ; PETSCII CHARACTER
.A 1804 AND #%11110000  ; BINARY BYTE
.A 1806 CMP #250        ; BASE-10 BYTE

Accumulator Mode Operand

wAx supports both explicit and implicit syntax for accumulator mode instructions (ROR, ROL, LSR, ASL):

.A 1800 ROR A  ; TAKE YOUR
.A 1802 ROR    ; PICK!

Arithmetic

wAx allows you to apply simple arithmetic to address operands by placing + or - after the operand. The range is a hexadecimal value between -F and +F. For example:

.A 1800 STA @V+1
.A 1800 STA $9000+5
.A 1800 LDA ($FF-F),Y

Entering Data

For additional details, see Memory Editor.

In addition to 6502 code, you may also enter program data with the @ tool. The following formats are supported:

Text

You may enter quoted text of up to 16 characters:

.A 1800 "YOUR TEXT HERE"

Hex Bytes

You may enter up to four bytes (in direct mode) or up to eight bytes (in a BASIC program) using a colon:

.A 1800 :1A 2B 3C 4D

Binary Bytes

You may enter one binary byte (eight bits) using a percent sign:

.A 1800 %00110001

The Command Pointer

wAx keeps track of the address after the last-assembled instruction. This address can be inserted into your code with the asterisk (*). This is especially useful when using BASIC programs for assembly. So instead of writing this:

10 .A 1800 LDA #"J"
20 .A 1802 JSR $FFD2
30 .A 1805 BRK

you can write this:

10 .A 1800 LDA #"J"
20 .A *    JSR $FFD2
30 .A *    BRK

This allows you to easily relocate the code by changing its address on the first line.

The * is called the "Command Pointer." You may set the address of the Command Pointer by using the * tool:

 5 *1800
10 .A * LDA #"J"
20 .A * JSR $FFD2
30 .A * BRK

An * is replaced with the Command Pointer address in wAx commands, except for within the * tool itself, and within quoted strings. If, for some reason, you use it as an operand, remember to use $:

.A 1800 JSR $CB1E
.A 1803 JMP $*

When the Command Pointer is changed during execution of a BASIC program, wAx sets the CP variable. For example

10 .M 1000 1200
20 PRINT "END:",CP-1

Note that CP is set to the next address that would have been used, so CP-1 will be the last address that wAx used.

Clone this wiki locally