Jonathan A Titus Microcomputer Pioneer
 
Mark-8 Design Microcomputer According to Titus Microcontroller Project Postscriptum Lessons Home



Lesson 2: Pico Numeration System




Pico Data Types
The assembler for the SX-28, the processor of the Pico system, is able to understand four data types: decimal, binary, hexadecimal, and ASCII. The recommended notations to differentiate between the data types are shown in Fig 1.1. Additional methods for data type notation in Fig 1.2 are also usable but it is not recommended as their usage may generate warnings during compilation. Variables are only allowed to take up 32-bits of memory and numbers which exceed this will generate an error during assembly of the code.
Data Type Syntax Example Max Value
Decimal #xxxx #4500 #4_294_967_295
Binary %xxxx %11011011 %1111_1111_1111_1111_1111_1111_1111_1111
Hex $xxxx $42EF $FFFF_FFFF
ASCII 'x' 'Z'

Data Type Syntax Example
Decimal xxxx 4500
Binary xxxxb 11011011b
Hex xxxxh 42EFh



Operators
The SX-28 assembly provides support for expressions which are evaluated during assembly of programs. They may be linked together in expressions much like in mathematics but with several differences that should be considered. Operators that the SX-28 assembler has in common with algebra are shown below in Fig 1-3. Watch out when dealing with exponentiation as there is no exponentiation operator and the symbol that commonly depicts exponentiation is used as the operator for XOR.
Symbol Usage Operation
|| |a| Absolute Value
- -a Negative
+ a + b Addition
- a - b Subtraction
* a * b Multiplication
/ a / b Division
// a // b Modulus


Expressions
Expressions are not evaluated by the SX-28 assembler the same that you may be used to in a mathematics course. PEMDAS, which stands for “parentheses, exponentiation, multiplication, division, addition, subtraction”, is a common term used to describe order of operations in mathematics. The SX-28 assembler interprets them much differently as expressions are evaluated strictly from left to right after parentheses are considered. For example, the expression 2+3*5 which would normally evaluate to 17 would evaluate to 25 on the Pico. To get the correct answer of 17, the expression would have to be written 2+(3*5).

Expression usage is very simple. You can insert them directly into the assembly code and they will evaluate as described previously. Be aware that expressions are only evaluated during assembly and not during run-time so variables unknown to the assembler during assembly should not be included in any expressions.
mov result0, 2+(3*5); 17 is moved into result
mov result1, 2+3*5; 25 is moved into result
mov result2, (2+3)*5; 25 is moved into result



Copywrite Florida Gulf Coast University 2007
Validate CSS Validate XHTML