Feature: Add `*ADDR` assembly operation (`*ADDR`, used as an operand, is replaced with the memory address where the current line will be stored after assembly)
This commit is contained in:
parent
5c41369ecd
commit
4e01a0943c
|
|
@ -123,12 +123,19 @@ function decodeInstructions(line) {
|
||||||
}
|
}
|
||||||
dbg(2, `pointsToByte: ${labels[label].pointsToByte}`);
|
dbg(2, `pointsToByte: ${labels[label].pointsToByte}`);
|
||||||
dbg(2, `bytesToReplace: ${labels[label].bytesToReplace}`);
|
dbg(2, `bytesToReplace: ${labels[label].bytesToReplace}`);
|
||||||
|
|
||||||
|
// Handle references to the Instruction Pointer
|
||||||
|
} else if (arg_str.toLowerCase() === '*addr') {
|
||||||
|
dbg(2, `operand references current address`);
|
||||||
|
arg_num = IP;
|
||||||
|
dbg(2, `arg_num: ${num2hex(arg_num)}`);
|
||||||
|
|
||||||
// Handle references to constants
|
// Handle references to constants
|
||||||
} else if (arg_str.startsWith('=')) {
|
} else if (arg_str.startsWith('=')) {
|
||||||
// FIXME - a quick hack to get around problems caused by another use of lower-casing to sanitize input:
|
// FIXME - a quick hack to get around problems caused by another use of lower-casing to sanitize input:
|
||||||
arg_str = arg_str.substring(1).toLowerCase(); // strip '>'
|
arg_str = arg_str.substring(1).toLowerCase(); // strip '>'
|
||||||
dbg(2, `operand references '${arg_str}'`);
|
dbg(2, `operand references '${arg_str}'`);
|
||||||
|
// TODO: support *ADDR
|
||||||
arg_str = constants[arg_str];
|
arg_str = constants[arg_str];
|
||||||
dbg(2, `arg_str from '${arg_str}`);
|
dbg(2, `arg_str from '${arg_str}`);
|
||||||
|
|
||||||
|
|
@ -140,6 +147,7 @@ function decodeInstructions(line) {
|
||||||
// FIXME - a quick hack to get around problems caused by another use of lower-casing to sanitize input:
|
// FIXME - a quick hack to get around problems caused by another use of lower-casing to sanitize input:
|
||||||
arg_str = arg_str.toLowerCase();
|
arg_str = arg_str.toLowerCase();
|
||||||
dbg(2, `INDY - operand references '${arg_str}'`);
|
dbg(2, `INDY - operand references '${arg_str}'`);
|
||||||
|
// TODO: support *ADDR
|
||||||
arg_str = constants[arg_str];
|
arg_str = constants[arg_str];
|
||||||
|
|
||||||
// Handle indirect expressions
|
// Handle indirect expressions
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@
|
||||||
|
|
||||||
### Assembler
|
### Assembler
|
||||||
|
|
||||||
|
- [ ] Support use of `*ADDR` with =constants
|
||||||
- [ ] Pad up to 256 bytes
|
- [ ] Pad up to 256 bytes
|
||||||
- [ ] Validate labels
|
- [ ] Validate labels
|
||||||
- [ ] Return pure machine code when printing to stdout (and not in debug mode)
|
- [ ] Return pure machine code when printing to stdout (and not in debug mode)
|
||||||
|
|
|
||||||
|
|
@ -93,5 +93,8 @@ With verbose debugging output:
|
||||||
|
|
||||||
ADD =foo ; use a constant as an operand
|
ADD =foo ; use a constant as an operand
|
||||||
|
|
||||||
|
LDA *ADDR ; `*ADDR` is a magic value referencing the memory address
|
||||||
|
; that the current line will store at after assembly
|
||||||
|
|
||||||
- Hexadecimal numbers are preceded by a `$`
|
- Hexadecimal numbers are preceded by a `$`
|
||||||
- Whitespace is ignored
|
- Whitespace is ignored
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
;; Test referencing address of line being assembled
|
||||||
|
|
||||||
|
LDA *ADDR
|
||||||
|
STO $25
|
||||||
|
FHP 0 ; hop if carry set
|
||||||
|
JMP @setCarry
|
||||||
|
END
|
||||||
|
|
||||||
|
@setCarry
|
||||||
|
FTG 0
|
||||||
|
JMP ($25)
|
||||||
Loading…
Reference in New Issue