"Save As"; command-line assembler; 32-bit limit (so far) in opcodes
This commit is contained in:
parent
f24213aa1d
commit
5b92659b97
4
Makefile
4
Makefile
|
@ -21,3 +21,7 @@ archive:
|
||||||
git archive --prefix 8bitworkshop- -o release/8bitworkshop-tools.zip HEAD tools
|
git archive --prefix 8bitworkshop- -o release/8bitworkshop-tools.zip HEAD tools
|
||||||
|
|
||||||
|
|
||||||
|
web:
|
||||||
|
ifconfig | grep inet
|
||||||
|
python2 -m SimpleHTTPServer 2>> http.out
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,9 @@ div.mem_info {
|
||||||
margin-left:8px;
|
margin-left:8px;
|
||||||
background-color: #666;
|
background-color: #666;
|
||||||
}
|
}
|
||||||
|
.btn_label {
|
||||||
|
color: #ccc;
|
||||||
|
}
|
||||||
.btn_group.debug_group {
|
.btn_group.debug_group {
|
||||||
}
|
}
|
||||||
.btn_group.view_group {
|
.btn_group.view_group {
|
||||||
|
|
15
index.html
15
index.html
|
@ -39,10 +39,11 @@ ga('send', 'pageview');
|
||||||
☰ <span class="caret"></span>
|
☰ <span class="caret"></span>
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||||
<li><a class="dropdown-item" href="#" id="item_new_file">New File...</a></li>
|
<li><a class="dropdown-item" href="#" id="item_new_file">New File...</a></li>
|
||||||
<li><a class="dropdown-item" href="#" id="item_share_file">Share File as GitHub Gist...</a></li>
|
<li><a class="dropdown-item" href="#" id="item_share_file">Share File as GitHub Gist...</a></li>
|
||||||
<li><a class="dropdown-item" href="#" id="item_reset_file">Revert to Original...</a></li>
|
<li><a class="dropdown-item" href="#" id="item_reset_file">Revert to Original...</a></li>
|
||||||
<li><a class="dropdown-item" href="#" id="item_download_rom">Download ROM Image...</a></li>
|
<li><a class="dropdown-item" href="#" id="item_download_file">Download File</a></li>
|
||||||
|
<li><a class="dropdown-item" href="#" id="item_download_rom">Download ROM Image</a></li>
|
||||||
<li><a class="dropdown-item" href="#" id="item_record_video">Record Video...</a></li>
|
<li><a class="dropdown-item" href="#" id="item_record_video">Record Video...</a></li>
|
||||||
<li class="dropdown dropdown-submenu">
|
<li class="dropdown dropdown-submenu">
|
||||||
<a tabindex="-1" href="#">Debug</a>
|
<a tabindex="-1" href="#">Debug</a>
|
||||||
|
@ -50,6 +51,12 @@ ga('send', 'pageview');
|
||||||
<li><a class="dropdown-item" href="#" id="item_debug_expr">Break Expression...</a></li>
|
<li><a class="dropdown-item" href="#" id="item_debug_expr">Break Expression...</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="dropdown dropdown-submenu">
|
||||||
|
<a tabindex="-1" href="#">Options</a>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li><i id="item_low_power_check" style="display:hidden" class="fa fa-check"></i><a class="dropdown-item" href="#" id="item_low_power">Low Power Mode</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
<hr>
|
<hr>
|
||||||
<li class="dropdown dropdown-submenu">
|
<li class="dropdown dropdown-submenu">
|
||||||
<a tabindex="-1" href="#">Platform</a>
|
<a tabindex="-1" href="#">Platform</a>
|
||||||
|
@ -82,7 +89,7 @@ ga('send', 'pageview');
|
||||||
<span class="btn_group view_group" id="speed_bar" style="display:none">
|
<span class="btn_group view_group" id="speed_bar" style="display:none">
|
||||||
<button id="dbg_slowest" type="submit" title="Slowest"><span class="glyphicon glyphicon-fast-backward" aria-hidden="true"></span></button>
|
<button id="dbg_slowest" type="submit" title="Slowest"><span class="glyphicon glyphicon-fast-backward" aria-hidden="true"></span></button>
|
||||||
<button id="dbg_slower" type="submit" title="Slower"><span class="glyphicon glyphicon-backward" aria-hidden="true"></span></button>
|
<button id="dbg_slower" type="submit" title="Slower"><span class="glyphicon glyphicon-backward" aria-hidden="true"></span></button>
|
||||||
<span id="fps_label">60.00</span> fps
|
<span class="label"><span id="fps_label">60.00</span> fps</span>
|
||||||
<button id="dbg_faster" type="submit" title="Faster"><span class="glyphicon glyphicon-forward" aria-hidden="true"></span></button>
|
<button id="dbg_faster" type="submit" title="Faster"><span class="glyphicon glyphicon-forward" aria-hidden="true"></span></button>
|
||||||
<button id="dbg_fastest" type="submit" title="Faster"><span class="glyphicon glyphicon-fast-forward" aria-hidden="true"></span></button>
|
<button id="dbg_fastest" type="submit" title="Faster"><span class="glyphicon glyphicon-fast-forward" aria-hidden="true"></span></button>
|
||||||
</span>
|
</span>
|
||||||
|
@ -224,8 +231,10 @@ ga('send', 'pageview');
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
/*
|
||||||
var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
||||||
if (!isFirefox && platform_id != 'vcs') { $("#best_in_firefox").show(); }
|
if (!isFirefox && platform_id != 'vcs') { $("#best_in_firefox").show(); }
|
||||||
|
*/
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
{"fmt":"pop ~reg", "bits":["01001",0,"00001","110"]},
|
{"fmt":"pop ~reg", "bits":["01001",0,"00001","110"]},
|
||||||
{"fmt":"rts", "bits":["01001","111","00001","110"]},
|
{"fmt":"rts", "bits":["01001","111","00001","110"]},
|
||||||
{"fmt":"jsr ~reg", "bits":["01110","111","00",0,"110"]},
|
{"fmt":"jsr ~reg", "bits":["01110","111","00",0,"110"]},
|
||||||
|
{"fmt":"jsr ~imm16", "bits":["0001110001011000",0,"0111011100100110"]},
|
||||||
|
|
||||||
{"fmt":"bcc ~rel8", "bits":["10000001",0]},
|
{"fmt":"bcc ~rel8", "bits":["10000001",0]},
|
||||||
{"fmt":"bcs ~rel8", "bits":["10001001",0]},
|
{"fmt":"bcs ~rel8", "bits":["10001001",0]},
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
mov ax,@$4ffe
|
mov ax,@$4ffe
|
||||||
mov dx,@ClearTiles
|
mov dx,@ClearTiles
|
||||||
jsr dx
|
jsr dx
|
||||||
mov dx,@ClearSprites
|
mov ex,@ClearSprites
|
||||||
jsr dx
|
jsr ex
|
||||||
reset
|
reset
|
||||||
InitPageTable:
|
InitPageTable:
|
||||||
mov ax,@$6000 ; screen buffer
|
mov ax,@$6000 ; screen buffer
|
||||||
|
|
|
@ -372,6 +372,11 @@ function _downloadROMImage(e) {
|
||||||
saveAs(blob, getCurrentFilename()+".rom");
|
saveAs(blob, getCurrentFilename()+".rom");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _downloadSourceFile(e) {
|
||||||
|
var blob = new Blob([editor.getValue()], {type: "text/plain;charset=utf-8"});
|
||||||
|
saveAs(blob, getCurrentFilename());
|
||||||
|
}
|
||||||
|
|
||||||
function populateExamples(sel) {
|
function populateExamples(sel) {
|
||||||
sel.append($("<option />").text("--------- Examples ---------").attr('disabled',true));
|
sel.append($("<option />").text("--------- Examples ---------").attr('disabled',true));
|
||||||
for (var i=0; i<PRESETS.length; i++) {
|
for (var i=0; i<PRESETS.length; i++) {
|
||||||
|
@ -1312,6 +1317,7 @@ function setupDebugControls(){
|
||||||
else
|
else
|
||||||
$("#item_debug_expr").hide();
|
$("#item_debug_expr").hide();
|
||||||
$("#item_download_rom").click(_downloadROMImage);
|
$("#item_download_rom").click(_downloadROMImage);
|
||||||
|
$("#item_download_file").click(_downloadSourceFile);
|
||||||
$("#item_record_video").click(_recordVideo);
|
$("#item_record_video").click(_recordVideo);
|
||||||
if (platform.setFrameRate && platform.getFrameRate) {
|
if (platform.setFrameRate && platform.getFrameRate) {
|
||||||
$("#speed_bar").show();
|
$("#speed_bar").show();
|
||||||
|
|
|
@ -124,24 +124,30 @@ var Assembler = function(spec) {
|
||||||
self.buildInstruction = function(rule, m) {
|
self.buildInstruction = function(rule, m) {
|
||||||
var opcode = 0;
|
var opcode = 0;
|
||||||
var oplen = 0;
|
var oplen = 0;
|
||||||
|
// iterate over each component of the rule output ("bits")
|
||||||
for (var i=0; i<rule.bits.length; i++) {
|
for (var i=0; i<rule.bits.length; i++) {
|
||||||
var b = rule.bits[i];
|
var b = rule.bits[i];
|
||||||
var n,x;
|
var n,x;
|
||||||
|
// is a string? then it's a bit constant
|
||||||
|
// TODO
|
||||||
if (b.length) {
|
if (b.length) {
|
||||||
n = b.length;
|
n = b.length;
|
||||||
x = parseInt(b,2);
|
x = parseInt(b,2);
|
||||||
} else {
|
} else {
|
||||||
|
// it's an indexed variable, look up its variable
|
||||||
var id = m[b+1];
|
var id = m[b+1];
|
||||||
var v = spec.vars[rule.varlist[b]];
|
var v = spec.vars[rule.varlist[b]];
|
||||||
if (!v) {
|
if (!v) {
|
||||||
return {error:"Could not find matching identifier for '" + m[0] + "'"};
|
return {error:"Could not find matching identifier for '" + m[0] + "'"};
|
||||||
}
|
}
|
||||||
n = v.bits;
|
n = v.bits;
|
||||||
|
// is it an enumerated type? look up the index of its keyword
|
||||||
if (v.toks) {
|
if (v.toks) {
|
||||||
x = v.toks.indexOf(id);
|
x = v.toks.indexOf(id);
|
||||||
if (x < 0)
|
if (x < 0)
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
|
// otherwise, parse it as a constant
|
||||||
x = parseConst(id, n);
|
x = parseConst(id, n);
|
||||||
// is it a label? add fixup
|
// is it a label? add fixup
|
||||||
if (isNaN(x)) {
|
if (isNaN(x)) {
|
||||||
|
@ -158,14 +164,16 @@ var Assembler = function(spec) {
|
||||||
}
|
}
|
||||||
if (oplen == 0)
|
if (oplen == 0)
|
||||||
warning("Opcode had zero length");
|
warning("Opcode had zero length");
|
||||||
|
else if (oplen > 32)
|
||||||
|
warning("Opcodes > 32 bits not supported");
|
||||||
else if ((oplen % width) != 0)
|
else if ((oplen % width) != 0)
|
||||||
warning("Opcode was not word-aligned (" + oplen + " bits)");
|
warning("Opcode was not word-aligned (" + oplen + " bits)");
|
||||||
return {opcode:opcode, nbits:oplen};
|
return {opcode:opcode, nbits:oplen};
|
||||||
}
|
}
|
||||||
|
|
||||||
self.loadArch = function(arch) {
|
self.loadArch = function(arch) {
|
||||||
if (self.loadFile) {
|
if (self.loadJSON) {
|
||||||
var json = self.loadFile(arch + ".json");
|
var json = self.loadJSON(arch + ".json");
|
||||||
if (json && json.vars && json.rules) {
|
if (json && json.vars && json.rules) {
|
||||||
spec = json;
|
spec = json;
|
||||||
preprocessRules();
|
preprocessRules();
|
||||||
|
@ -292,13 +300,16 @@ if (typeof module !== 'undefined' && require.main === module) {
|
||||||
var stdinBuffer = fs.readFileSync(0);
|
var stdinBuffer = fs.readFileSync(0);
|
||||||
var code = stdinBuffer.toString();
|
var code = stdinBuffer.toString();
|
||||||
var asm = new Assembler();
|
var asm = new Assembler();
|
||||||
asm.loadFile = function(filename) {
|
asm.loadJSON = function(filename) {
|
||||||
return fs.readFileSync(filename, 'utf8');
|
return JSON.parse(fs.readFileSync(filename, 'utf8'));
|
||||||
|
};
|
||||||
|
asm.loadInclude = function(filename) {
|
||||||
|
filename = filename.substr(1, filename.length-2); // remove quotes
|
||||||
|
//return fs.readFileSync(filename, 'utf8');
|
||||||
|
};
|
||||||
|
asm.loadModule = function(top_module) {
|
||||||
|
//TODO
|
||||||
};
|
};
|
||||||
var out = asm.assembleFile(code);
|
var out = asm.assembleFile(code);
|
||||||
if (out.errors) {
|
console.log(out);
|
||||||
console.log(out.errors);
|
|
||||||
} else {
|
|
||||||
console.log(out.outwords);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1126,7 +1126,7 @@ function compileJSASM(asmcode, platform, options, is_inline) {
|
||||||
load("assembler");
|
load("assembler");
|
||||||
var asm = new Assembler();
|
var asm = new Assembler();
|
||||||
var includes = [];
|
var includes = [];
|
||||||
asm.loadFile = function(filename) {
|
asm.loadJSON = function(filename) {
|
||||||
// TODO: what if it comes from dependencies?
|
// TODO: what if it comes from dependencies?
|
||||||
var path = '../../presets/' + platform + '/' + filename;
|
var path = '../../presets/' + platform + '/' + filename;
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
|
|
Loading…
Reference in New Issue