Professional Documents
Culture Documents
1.0 Outcomes
At the end of this chapter, you should be able to:
numeric data because arithmetic operations can be performed on them. Alphanumeric data, on
acronym of American Standard Code for Information Interchange. This code assigns the letters
of the alphabet, decimal digits from 0 to 9 and some additional symbols a binary number of 7
bits, putting the 8th bit in its off state or 0. This way each letter, digit or special character
In most microcomputer, placing a 1 in the most significant bit uses an extended ASCII character
set. The extended ASCII is used to represent foreign letters, Greek and mathematical symbols
as well as box drawing and other special characters. Table 3.1 shows the ASCII code. Notice
that the codes from 0H to 1FH (Grey background) are called control codes and are used to
control the operation of the computer. The control codes are non-printable. Only 4 of the
MSB 0 1 2 3 4 5 6 7
LSB 0 SP 0 @ P ' P
1 ! 1 A Q a q
2 " 2 B R b r
3 # 3 C S c s
4 $ 4 D T d t
5 % 5 E U e u
6 & 6 F V f v
7 BEL ' 7 G W g w
8 ( 8 H X h x
9 ) 9 I Y i y
A LF * : J Z j z
B ESC + ; K [ k
C , < L \ l |
D CR _ = M ] m
E . > N ^ n ~
F / ? O - o DEL
fixed point, are whole number with no decimal point, while real numbers, sometimes called
floating point, have decimal point. The 80386 family of microprocessors can only perform
arithmetic operations on integers and therefore, only the representation of integers in computer
will be discussed here. Integers can be represented in the computer as pure binary format or as
each decimal digit from 0 to 9. Data in BCD can be stored either as packed BCD or as unpacked
BCD. In packed BCD, each nibble of a byte represents one decimal digit. Thus, we can store
two digits per byte of information. While, in unpacked BCD, the upper nibble is set to 0 and the
lower nibble is used to store the decimal digit. Thus, we can only store one digit per byte of
information. Table 3.2 below shows how integers are stored as packed and unpacked BCD.
427 0000 0100 0010 0111 0000 0100 0000 0010 0000 0111
An integer can be stored as a single byte (8-bits). The range for unsigned integer is from 0 to
28-1 i.e. from 0 to 255. While the range for the signed integer is from -27 to 27-1 i.e. from -128
to 127. Signed integers are stored in 2's complement, thus, the most significant bit is 1 for
negative numbers and 0 for positive numbers. Figure 3.1 shows how signed and unsigned
128 64 32 16 8 4 2 1 -128 64 32 16 8 4 2 1
0 0 0 0 0 0 0 0 Smallest 1 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 Largest 0 1 1 1 1 1 1 1
An integer can be stored as a single word (16-bits). The range for unsigned integer is from 0 to
216-1 i.e. from 0 to 65535. While the range for the signed integer is from -215 to 215-1 i.e.
from -32786 to 32785. Figure 3.2a shows the largest and smallest unsigned integer stored in
word format while Figure 3.2b shows the storage of the smallest and largest signed integers are
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Figure 3.2 a) Smallest and Largest Unsigned Integer in a 16-bit (word) format
Binary Weights
-32768 256 128 64 32 16 8 4 2 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Figure 3.2 b) Smallest and Largest of a Signed Integer in a 16-bit (word) format
An integer can be stored as a double word (32-bits). ). The range for unsigned integer is from 0
to 232-1 i.e. from 0 to 4294967295. While the range for the signed integer is from -231 to 231-1
memory. This technique stores the least significant byte of data in the low memory address and
the most significant byte in the high memory address. Figure 3.3 shows how the data FA3BH is
Binary Hexadecimal
00010H
0000DH
used. However, declaring a variable only assigns a space for it in memory and there is no type
checking by the assembler like in high level compilers. The space allocated depends whether
the variable is of Byte type, Word type or Double word type etc. All variables should be declared
Example Description
Age db 45 Reserves a single byte in memory and assign the value 45 (2D in
Hexadecimal)
Age db 30, 50 Reserves 2 bytes in memory and assign the values 30 and 50 respectively
Age db 4 dup(0) Reserves 4 bytes in memory and assign the values 0 to all of them
Name db “Ja” Reserves 2 bytes in memory and assign the ASCII codes for J and a
respectively
directive is:
Example Description
Age dw 30, -50 Reserves 2 words (4 bytes) in memory and assign the values 30 and -50
(FFCE in Hexadecimal) respectively
Age dw 4 dup(0) Reserves 4 bytes in memory and assign the values 0 to all of them
Name dw “Ja” Reserves 2 bytes in memory and assign the ASCII codes for J and a
respectively
1.3.3 Variables of Other Sizes
Similar to DB and DW which reserve 1 byte or 1 word in memory for the storage of the variable
content, there directives that can reserve double words, quadruple words and ten bytes as
The destination can be a register or a memory address where the data will be stored. However,
the source can be a register, a memory address, or an immediate value. The following rules
must be observed:
Table 3.6 shows examples of valid MOV instructions while Table 3.7 shows examples of invalid
MOV instructions.
Table 3. 6 Examples of Valid MOV Instructions
Instruction Description
Mov BL, 23 Store the number 23 decimal in the BL register
Mov AL, 10010010B The binary number 10010010 is stored in the AL register
mov cl, 0F3H The hexadecimal number F3 is stored in CL register
Mov DX, 7234O The Octal number 7234 is stored in the DX register
mov BX, 'AB' The ASCII code for the letters A and B are stored in the BX Register
Mov AX, BX The content of the BX register is copied into the AX register
Instruction Description
Mov CS, AX The code segment register cannot be the destination
Mov AX, BL The registers are not of the same size
Mov list1, list2 Both destination and source cannot be memory address
Mov SS, DS The source and destination cannot be both segment register