Saturday, 8 December 2012

Data Representation

Data Representation 

In order to understand how to manipulate data and perform computations in MIPS program, you must understand how data is represented by a computer in a view of MIPS programming language. There are two way data can be represent which is in character and numbers. First we’ll talk about character representation.
Next will be number representation.

Character Representation
An eight bit is a byte. A character can be represented with one byte. Most computer offer 8-bit byte to represent characters following the American Standard code for Information Interchange also known as the ASCII for character representations. A table below will summarize ASCII. You can gain more detail about ASCII table by surfing the net.
Part of what an assembler does is to assemble the ASCII bit patterns that you have asked to be placed in the memory. Here is a section of an assembly language program:
                .asciiz    “XYZ  xyz”
Here is the bit patterns that the assembler will produce in the object module:
                58 59 5A 20 78 79 7A 00
The .asciiz part  of the source code asked the assembler to assemble the characters between the quote marks into ASCII bit patterns. The numbers represent hexadecimal system, or the front of each number can be written as 0x. The first character, “A”, corresponds to the bit pattern 0x41 while the second character, “B”, correspond to the bit pattern 0x42 if you look at the table below. The final bit pattern will be 0x00 which known as the NULL is used by the assembler to show the end of the string of the characters.
There is an alternative way to write each character:
                .byte 88 89 90 32 120 121 122 00


Number Representation
Although computers operate on binary numbers, however in MIPS number is represented in decimal system or hexadecimal system. Therefore it is important to remember what kind of number system that you want to write in the program when inserting number into a register. For example, to load number 16 into register $5, we have two ways to represent decimal 16 in MIPS:
1.       Ori $5, $0, 16      # load number 16 into register $5
2.       Ori $5, $0, 0x10  # load number 16 into register $5

Yap Chi Hian B031210334

No comments:

Post a Comment