/* Copyright (c) 2014 Juergen Marsch, Pur3 Ltd. See the file LICENSE for copying permission. */
/*!
**/
var ASMList,ASMBase;
ASMBase = process.memory().stackEndAddress;
ASMList = [];
exports.connect = function(){
function ASM(){
this.loadArray = function(varName,format,arr){
var a = {name:varName,format:format,start:ASMBase + 1};
for(var i = 0; i < arr.length; i++){
poke16(ASMBase,arr[i]);
ASMBase += 2;
}
ASMList.push(a);
eval('var ' + a.name + ' = E.nativeCall(' + a.start + ',"' + a.format + '");');
};
this.loadSD = function(varName,format,fileName){
var arr,fs = require("fs");
arr = new Uint16Array(E.toArrayBuffer(fs.readFile(fileName)));
return(this.loadArray(varName,format,arr));
};
this.list = function(){ return ASMList; }
}
return new ASM();
}
It could be used like this
var x = require("ASM").connect();
x.loadArray("tst1","int(int,int)",[0x1840,0x4770]);
require("ASM").connect().loadArray("tst2","int(int)",[0x4770]);
require("ASM").connect().loadSD("tst3","int(int,int)","node_binaries/adder.BIN");
console.log(require("ASM").connect().list());
console.log(tst1(2,6) + " should be 8");
console.log(tst2(3) + " should be 3");
console.log(tst3(4,5) + " should be 9");
I can't follow the comment about STM32F1Flash. That module already exists in your collection. Which kind of data would you write from ASM to Flash ?
I would like to keep ASM module as small as possible, so it doesn't add load which is used in special cases only.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Module could be like this
It could be used like this
I can't follow the comment about STM32F1Flash. That module already exists in your collection. Which kind of data would you write from ASM to Flash ?
I would like to keep ASM module as small as possible, so it doesn't add load which is used in special cases only.