You are reading a single comment by @JumJum and its replies. Click here to read the full conversation.
  • Module could be like this

    /* 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:ASMBas­e + 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)",[0x184­0,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().lis­t());
    
    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.

About

Avatar for JumJum @JumJum started