Free Web Hosting by Netfirms
Web Hosting by Netfirms | Free Domain Names by Netfirms

 
4.1 DEFINITION OF NEW NAME

Another way to declare new name is assign expression. Syntax is:

   name = expression

where 'name' is any legal name (see '3. Labels and Instructions'). With this,  we declare name which type is L_VAR - variable type. L_VAR type can be reassigned to another value:

   Data1 = 10  ; new name

   Data2 = Data1 + 123 ; new name

   Data1 = -Data3  ; reassignment
Type L_LABEL can not be reassigned.

Another restriction that was introduced to this version of mas is dependence for previous declaration. If expression depend of some other name, this name must be declared previous:

  Data2 = Data1  ; error - undeclared Data1

  Data1 = 123
Most assemblers do not issue error for this. In previous BETA version of mas  this was not error. Only reason for this was logical nature of code design. I DO NOT LIKE logic to reference some data that is not declared yet! Maybe this is one mistake, but that's me :)

Unlike this, expressions CAN REFERENCE LABEL that is not declared. I think that is good, because it permits to calculate size of code:

   CodeSize = end - start

  start:

   ; some code

  end:
This violate my phrase of LOGICAL CODING, but it's very useful.

Right side of assign operator (=) is expression. Expression can have operators (unary and binary), numbers, already declared names and labels.

Numbers are represented in C-like style with exception for binary numbers:

 '0x' followed by a..fA..F0..9 - HEX numbers
 '0b' followed by 0 or 1  - BINARY numbers
 '0'  followed by 0..7  - OCTAL numbers
 '1..9' followed by 0..9  - DECIMAL numbers
 

[PREV][INDEX][NEXT]