Crossware

Table of Contents        Previous topic       Next topic       

Javascript in General

The simulator uses Google's V8 Javascript engine. V8 implements ECMAScript as specified in ECMA-262, 5th edition.  The V8 engine will compile Javascript code into x86 machine code to give a high execution performance.

The V8 engine is used in Google's Chrome web browser.  Note however that the simulator is not a web browser -  there is not DOM object and no Window object.  Instead the simulator provides it's own intrinsic objects.  The jState.Core and the console instrinsic objects are always present.  These are provided by the main simulator DLL.  All other intrinsic objects are specific to the selected microcontroller.  They are generated by the extension DLL for the selected microcontroller.  You can discover all microcontroller specific instrinsic objects using the jState Code Creation Wizards.  You can also use the jState Code Creation Wizards  to discover and write code for all events and properties supported by each microcontroller specific instrinsic object.

The jState.Core object is also included in the jState Code Creation Wizards enabling you to discover and write code for the events, properties and commands supported by this object.

The console object has just two functions  log() and clear().  These are described in the Getting Started section.

Note that the in-built properties of the intrinsic objects are not enumerable.  Therefore you cannot write a Javascript function that will list them.

You can determine if a register property is readable or writeable or both using the jState Code Creation Wizards.  If the property is readable, the Read Register button will be enabled.  If the property is writeable, the Write Register button will be enabled.

As well as properties for registers, there are constant properties for the associated bitfields. For example, the STM32Fxxx ADC2 peripheral has a readable and writeable control register CR1 accessible using jState.adc2.CR1.  The DUALMOD0 bit of this register can be accessed either numerically if you know it's offset or using the jState.adc2.ADC_DUALMOD0 constant property. The jState Code Creation Wizards can generate code using these constant bitfield properties.