Skip to content

Commit

Permalink
2.3.0: minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
acaldero committed Jun 18, 2023
1 parent 962580e commit f07e05c
Show file tree
Hide file tree
Showing 26 changed files with 286 additions and 281 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -522,13 +522,13 @@ cordova plugin add cordova-plugin-web-share

+ 2.1) Copy WepSIM files into the www directory:
```bash
wget https://github.com/acaldero/wepsim/releases/download/v2.2.1/wepsim-2.2.1.zip
unzip wepsim-2.2.1.zip
wget https://github.com/acaldero/wepsim/archive/refs/heads/master.zip
unzip master.zip
```

+ 2.2) Build www for the Apache Cordova project:
```bash
./wepsim-2.2.1/devel/mk_cordova.sh
./wepsim-master/devel/mk_cordova.sh
```

### 3) Build Android .apk:
Expand Down
2 changes: 1 addition & 1 deletion devel/mk_cordova.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fi

# preparing www
mv www www.initial.$$
cp -a ./wepsim-2.1.8/ws_dist www
cp -a ./wepsim-master/ws_dist www

# adapting paths...
sed -i .bak 's/wepsim/android_asset\/www/g' ./www/examples/hardware/ep/images/processor.svg
Expand Down
7 changes: 4 additions & 3 deletions devel/mk_dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ echo " Step for npm install/update:"
echo " * terser jshint"
echo " * yargs clear inquirer fuzzy commander async"
echo " * inquirer-command-prompt inquirer-autocomplete-prompt"
echo " * codemirror @codemirror/lang-javascript"
echo " * rollup @rollup/plugin-node-resolve"
npm install
echo " Done.\n"
echo " Done."
echo ""


# pre-bundle
Expand All @@ -82,7 +82,8 @@ echo " * codemirror6"
node_modules/.bin/rollup -c external/codemirror6/rollup.config.mjs
terser -o external/codemirror6/min.codemirror.js external/codemirror6/codemirror.bundle.js
rm -fr external/codemirror6/codemirror.bundle.js
echo " Done.\n"
echo " Done."
echo ""


# skeleton
Expand Down
24 changes: 18 additions & 6 deletions external/codemirror6/codemirror.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@

import { EditorView, basicSetup } from "codemirror"
import { basicSetup, EditorView } from "codemirror"
// import { languages } from "@codemirror/language-data"
import { javascript } from "@codemirror/lang-javascript"
import { keymap } from "@codemirror/view"
import { defaultKeymap, history, historyKeymap } from "@codemirror/commands"
import { syntaxHighlighting, defaultHighlightStyle } from "@codemirror/language"
import { autocompletion } from "@codemirror/autocomplete"

import { javascript } from "@codemirror/lang-javascript"

let editor = new EditorView({
extensions: [basicSetup, javascript()],
parent: document.body
})
var view = new EditorView({
doc: "\n\n\n\n\n\n\n\n\n\n",
extensions: [
basicSetup,
history(),
keymap.of([...defaultKeymap, ...historyKeymap]),
javascript(),
syntaxHighlighting(defaultHighlightStyle),
],
parent: document.body
}) ;

2 changes: 1 addition & 1 deletion external/codemirror6/min.codemirror.js

Large diffs are not rendered by default.

120 changes: 60 additions & 60 deletions sim_sw/assembly.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,26 +428,26 @@ function read_data ( context, datosCU, ret )
}

return asm_langError(context,
i18n_get_TagFor('compiler', 'NO TAG OR DIRECTIVE') +
"'" + possible_tag + "'") ;
i18n_get_TagFor('compiler', 'NO TAG OR DIRECTIVE') +
"'" + possible_tag + "'") ;
}

var tag = possible_tag.substring(0, possible_tag.length-1);

if (! isValidTag(tag)) {
return asm_langError(context,
i18n_get_TagFor('compiler', 'INVALID TAG FORMAT') +
"'" + tag + "'") ;
i18n_get_TagFor('compiler', 'INVALID TAG FORMAT') +
"'" + tag + "'") ;
}
if (context.firmware[tag]) {
return asm_langError(context,
i18n_get_TagFor('compiler', 'TAG OR INSTRUCTION') +
"'" + tag + "'") ;
i18n_get_TagFor('compiler', 'TAG OR INSTRUCTION') +
"'" + tag + "'") ;
}
if (ret.labels2[tag]) {
return asm_langError(context,
i18n_get_TagFor('compiler', 'REPEATED TAG') +
"'" + tag + "'") ;
i18n_get_TagFor('compiler', 'REPEATED TAG') +
"'" + tag + "'") ;
}

// Store tag
Expand Down Expand Up @@ -496,20 +496,20 @@ function read_data ( context, datosCU, ret )
if (".word" !== possible_datatype)
{
return asm_langError(context,
i18n_get_TagFor('compiler', 'NO NUMERIC DATATYPE') +
"'" + possible_value + "'") ;
i18n_get_TagFor('compiler', 'NO NUMERIC DATATYPE') +
"'" + possible_value + "'") ;
}

// check valid label
if (! isValidTag(possible_value)) {
return asm_langError(context,
i18n_get_TagFor('compiler', 'INVALID TAG FORMAT') +
"'" + possible_value + "'") ;
i18n_get_TagFor('compiler', 'INVALID TAG FORMAT') +
"'" + possible_value + "'") ;
}
if (context.firmware[possible_value]) {
return asm_langError(context,
i18n_get_TagFor('compiler', 'TAG OR INSTRUCTION') +
"'" + possible_value + "'") ;
i18n_get_TagFor('compiler', 'TAG OR INSTRUCTION') +
"'" + possible_value + "'") ;
}

number = 0 ;
Expand All @@ -528,11 +528,11 @@ function read_data ( context, datosCU, ret )
if (free_space < 0)
{
return asm_langError(context,
i18n_get_TagFor('compiler', 'EXPECTED VALUE') + possible_datatype +
"' (" + size*BYTE_LENGTH + " bits), " +
i18n_get_TagFor('compiler', 'BUT INSERTED') + possible_value +
"' (" + num_bits.length + " bits) " +
i18n_get_TagFor('compiler', 'INSTEAD') ) ;
i18n_get_TagFor('compiler', 'EXPECTED VALUE') + possible_datatype +
"' (" + size*BYTE_LENGTH + " bits), " +
i18n_get_TagFor('compiler', 'BUT INSERTED') + possible_value +
"' (" + num_bits.length + " bits) " +
i18n_get_TagFor('compiler', 'INSTEAD') ) ;
}

// Word filled
Expand Down Expand Up @@ -603,13 +603,13 @@ function read_data ( context, datosCU, ret )
possible_value = ret1.number ;
if (ret1.isDecimal == false) {
return asm_langError(context,
i18n_get_TagFor('compiler', 'NO NUMBER OF BYTES') +
"'" + possible_value + "'") ;
i18n_get_TagFor('compiler', 'NO NUMBER OF BYTES') +
"'" + possible_value + "'") ;
}
if (possible_value < 0) {
return asm_langError(context,
i18n_get_TagFor('compiler', 'NO POSITIVE NUMBER') +
"'" + possible_value + "'") ;
i18n_get_TagFor('compiler', 'NO POSITIVE NUMBER') +
"'" + possible_value + "'") ;
}

// Fill with spaces/zeroes
Expand Down Expand Up @@ -640,9 +640,9 @@ function read_data ( context, datosCU, ret )
if ( (ret1.isDecimal == false) && (possible_value >= 0) )
{
return asm_langError(context,
i18n_get_TagFor('compiler', 'INVALID ALIGN VALUE') +
"'" + possible_value + "'. " +
i18n_get_TagFor('compiler', 'REMEMBER ALIGN VAL')) ;
i18n_get_TagFor('compiler', 'INVALID ALIGN VALUE') +
"'" + possible_value + "'. " +
i18n_get_TagFor('compiler', 'REMEMBER ALIGN VAL')) ;
}

// Word filled
Expand Down Expand Up @@ -706,21 +706,21 @@ function read_data ( context, datosCU, ret )
// check string
if ("\"" !== possible_value[0]) {
return asm_langError(context,
i18n_get_TagFor('compiler', 'NO QUOTATION MARKS') +
"'" + possible_value + "'") ;
i18n_get_TagFor('compiler', 'NO QUOTATION MARKS') +
"'" + possible_value + "'") ;
}
if ("\"" !== possible_value[possible_value.length-1]) {
return asm_langError(context,
i18n_get_TagFor('compiler', 'NOT CLOSED STRING')) ;
i18n_get_TagFor('compiler', 'NOT CLOSED STRING')) ;
}
if ("" == possible_value) {
return asm_langError(context,
i18n_get_TagFor('compiler', 'NOT CLOSED STRING')) ;
i18n_get_TagFor('compiler', 'NOT CLOSED STRING')) ;
}
if ("STRING" != asm_getTokenType(context)) {
return asm_langError(context,
i18n_get_TagFor('compiler', 'NO QUOTATION MARKS') +
"'" + possible_value + "'") ;
i18n_get_TagFor('compiler', 'NO QUOTATION MARKS') +
"'" + possible_value + "'") ;
}

// process characters of the string
Expand Down Expand Up @@ -784,8 +784,8 @@ function read_data ( context, datosCU, ret )
else
{
return asm_langError(context,
i18n_get_TagFor('compiler', 'UNEXPECTED DATATYPE') +
"'" + possible_datatype + "'") ;
i18n_get_TagFor('compiler', 'UNEXPECTED DATATYPE') +
"'" + possible_datatype + "'") ;
}
}

Expand Down Expand Up @@ -862,25 +862,25 @@ function read_text ( context, datosCU, ret )
}

return asm_langError(context,
i18n_get_TagFor('compiler', 'NO TAG, DIR OR INS') +
"'" + possible_tag + "'") ;
i18n_get_TagFor('compiler', 'NO TAG, DIR OR INS') +
"'" + possible_tag + "'") ;
}

var tag = possible_tag.substring(0, possible_tag.length-1);
if (!isValidTag(tag)) {
return asm_langError(context,
i18n_get_TagFor('compiler', 'INVALID TAG FORMAT') +
"'" + tag + "'") ;
i18n_get_TagFor('compiler', 'INVALID TAG FORMAT') +
"'" + tag + "'") ;
}
if (firmware[tag]) {
return asm_langError(context,
i18n_get_TagFor('compiler', 'TAG OR INSTRUCTION') +
"'" + tag + "'") ;
i18n_get_TagFor('compiler', 'TAG OR INSTRUCTION') +
"'" + tag + "'") ;
}
if (ret.labels2[tag]) {
return asm_langError(context,
i18n_get_TagFor('compiler', 'REPEATED TAG') +
"'" + tag + "'") ;
i18n_get_TagFor('compiler', 'REPEATED TAG') +
"'" + tag + "'") ;
}

// store tag
Expand Down Expand Up @@ -1054,10 +1054,10 @@ function read_text ( context, datosCU, ret )

if (res[1] < 0) {
return asm_langError(context,
"'" + value + "' " +
i18n_get_TagFor('compiler', 'BIGGER THAN') +
WORD_LENGTH + " " +
i18n_get_TagFor('compiler', 'BITS'));
"'" + value + "' " +
i18n_get_TagFor('compiler', 'BIGGER THAN') +
WORD_LENGTH + " " +
i18n_get_TagFor('compiler', 'BITS'));
}

if (label_found) {
Expand Down Expand Up @@ -1160,8 +1160,8 @@ function read_text ( context, datosCU, ret )

default:
return asm_langError(context,
i18n_get_TagFor('compiler', 'UNKNOWN 1') +
"'" + field.type + "'") ;
i18n_get_TagFor('compiler', 'UNKNOWN 1') +
"'" + field.type + "'") ;
}

// check if bits fit in the space
Expand Down Expand Up @@ -1262,15 +1262,15 @@ function read_text ( context, datosCU, ret )
// No candidate
if (advance.length === 1) {
return asm_langError(context,
error + ". <br>" +
i18n_get_TagFor('compiler', 'REMEMBER I. FORMAT') +
format);
error + ". <br>" +
i18n_get_TagFor('compiler', 'REMEMBER I. FORMAT') +
format);
}

return asm_langError(context,
i18n_get_TagFor('compiler', 'NOT MATCH MICRO') + "<br>" +
i18n_get_TagFor('compiler', 'REMEMBER I. FORMAT') + format + ". " +
i18n_get_TagFor('compiler', 'CHECK MICROCODE')) ;
i18n_get_TagFor('compiler', 'NOT MATCH MICRO') + "<br>" +
i18n_get_TagFor('compiler', 'REMEMBER I. FORMAT') + format + ". " +
i18n_get_TagFor('compiler', 'CHECK MICROCODE')) ;
}

if (sum_res > 1)
Expand All @@ -1279,7 +1279,7 @@ function read_text ( context, datosCU, ret )
candidate = get_candidate(advance, firmware[instruction]);
if (candidate === false) {
return asm_langError(context,
i18n_get_TagFor('compiler', 'SEVERAL CANDIDATES') + format) ;
i18n_get_TagFor('compiler', 'SEVERAL CANDIDATES') + format) ;
}
}

Expand Down Expand Up @@ -1549,8 +1549,8 @@ function simlang_compile (text, datosCU)

if (typeof ret.seg[segname] === "undefined") {
return asm_langError(context,
i18n_get_TagFor('compiler', 'INVALID SEGMENT NAME') +
"'" + segname + "'") ;
i18n_get_TagFor('compiler', 'INVALID SEGMENT NAME') +
"'" + segname + "'") ;
}

if ("data" == ret.seg[segname].kindof) {
Expand Down Expand Up @@ -1580,8 +1580,8 @@ function simlang_compile (text, datosCU)
if (typeof value === "undefined") {
asm_setLabelContext(context, ret.labels[i].labelContext);
return asm_langError(context,
i18n_get_TagFor('compiler', 'LABEL NOT DEFINED') +
"'" + ret.labels[i].name + "'") ;
i18n_get_TagFor('compiler', 'LABEL NOT DEFINED') +
"'" + ret.labels[i].name + "'") ;
}

// Get the words in memory (machine code) where the label is used
Expand Down Expand Up @@ -1675,7 +1675,7 @@ function simlang_compile (text, datosCU)
(typeof ret.labels2["kmain"] === "undefined" ) )
{
return asm_langError(context,
i18n_get_TagFor('compiler', 'NO MAIN OR KMAIN')) ;
i18n_get_TagFor('compiler', 'NO MAIN OR KMAIN')) ;
}
}

Expand Down
35 changes: 0 additions & 35 deletions sim_sw/assembly/lexical.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,38 +253,3 @@ function asm_resetComments ( context )
context.comments = [] ;
}


/*
* Native
*/

// TODO: some checking of this code before running (like an anti-virus)

function asm_nextNative ( context )
{
var first = context.t ;
var last = context.t ;

// to detect blocks inside blocks -> { if () {} }
var braces = 1 ;
while ( (context.t < context.text.length) && (braces != 0) )
{
if ('{' == context.text[context.t])
braces++ ;
if ('}' == context.text[context.t])
braces-- ;

context.t++;
}
last = context.t - 1 ;

// store the comment but do not return it as token
var tok = context.text.substring(first, last) ;

context.tokens.push(tok) ;
context.token_types.push("NATIVE") ;
context.i = context.tokens.length - 1 ;

return context ;
}

Loading

0 comments on commit f07e05c

Please sign in to comment.