assembler - Add feature: Allow binary numbers with prefix '0b' and hex numbers with prefix '0x'
This commit is contained in:
parent
eff9043665
commit
866f553346
|
|
@ -3,7 +3,7 @@
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
const { logMemory } = require('./logging.js');
|
const { logMemory } = require('./logging.js');
|
||||||
const { num2hex } = require('./conversions.js');
|
const { num2hex, hex2num, bin2num } = require('./conversions.js');
|
||||||
const DBG = require('./dbg.js');
|
const DBG = require('./dbg.js');
|
||||||
|
|
||||||
const CFG = require('./machine.config.js');
|
const CFG = require('./machine.config.js');
|
||||||
|
|
@ -111,6 +111,8 @@ function preparseSourceCode(source) {
|
||||||
**/
|
**/
|
||||||
function decodeNumericOp(arg) {
|
function decodeNumericOp(arg) {
|
||||||
if (arg.startsWith("$")) return hex2num(arg.replace("$", ""));
|
if (arg.startsWith("$")) return hex2num(arg.replace("$", ""));
|
||||||
|
if (arg.startsWith("0x")) return hex2num(arg.replace("0x", ""));
|
||||||
|
if (arg.startsWith("0b")) return bin2num(arg.replace("0b", ""));
|
||||||
return parseInt(arg);
|
return parseInt(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -399,8 +401,6 @@ function stripWhitespaceFromEnds(line) {
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
function hex2num(hex) { return parseInt(hex, 16) };
|
|
||||||
|
|
||||||
|
|
||||||
/** MAIN **/
|
/** MAIN **/
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue