Texas Instruments MSC1210 User Manual

Page 198

Advertising
background image

Number Bases

16-4

16.3 Number Bases

Most assemblers are capable of accepting numeric data in a variety of number
bases. Commonly supported are decimal, hexadecimal, binary, and octal.

Decimal: To express a decimal number in assembly language, simply enter
the number normally.

Hexadecimal: To express a hexadecimal number, enter the number as a hex-
adecimal value, and terminate the number with the suffix “h”. For example, the
hexadecimal number 45 is expressed as 45h. Furthermore, if the hexadecimal
number begins with an alphabetic character (A, B, C, D, E, or F), the number
must be preceded with a leading zero. For example, the hex number E4 is writ-
ten as 0E4h. The leading zero allows the assembler to differentiate the hex
number from a symbol because a symbol never starts with a number.

Binary: To express a binary number, enter the binary number followed by a
trailing B, to indicate binary. For example, the binary number 100010 is ex-
pressed as 100010B.

Octal: To express an octal number, enter the octal number itself followed by
a trailing Q, to indicate octal. For example, the octal number 177 is expressed
as 177Q.

As an example, all of the following instructions load the accumulator with 30
(decimal):

MOV A,#30

MOV A,#11110B

MOV A,#1EH

MOV A,#36Q

16.4 Expressions

You may use mathematical expressions in your assembly language instruc-
tions anywhere a numeric value may be used. For example, both of the follow-
ing are valid assembly language instructions:

MOV A,#20h + 34h

;Equivalent to #54h

MOV 35h + 2h,#10101B ;Equivalent to MOV 37h,#10101B

Advertising