604524007

Upload: hung-leo

Post on 07-Apr-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/4/2019 604524007

    1/6

    COMP 212 Computer Organization and Systems

    Page 1 of 6

    Lab 1

    Objectives: The objectives of this lab is to review the number systems and explain

    how computer systems define symbols through the introduction of the ASCII

    character table.

    Part I: Number Systems used in computers

    1.0. Representation of Binary and its relations with Hexadecimal systems

    All modern computer systems use the binary representation internally directly as a

    result of the use of semi-conductors which can easily be switched between two levels of

    voltage corresponding to 0 and 1, respectively.

    In the binary system (base 2), there are only two symbols, 1 and 0, corresponding to the

    two numbers. In computers, data are grouped in bytes. Each byte is 8 digits, which if

    divided into two 4-bit numbers, naturally can be converted into hexadecimal numbers

    easily as shown in the below table.

    The binary hexadecimal conversion table.

    because binary numbers are long and difficult to remember, conversion from binary to

    decimal is not as easy as that to hexadecimal numbers, hexadecimal numbers are often

    used as a replacement to machine code(binary).

    1.1 Conversion between Decimal and Binary numbers

    Binary Decimal

    0000 = 0 0100 = 4 1000 = 8 1100 = C

    0001 = 1 0101 = 5 1001 = 9 1101 = D

    0010 = 2 0110 = 6 1010 = A 1110 = E

    0011 = 3 0111 = 7 1011 = B 1111 = F

  • 8/4/2019 604524007

    2/6

    COMP 212 Computer Organization and Systems

    Page 2 of 6

    The decimal value of the binary number 110102 is

    24+ 2

    3+ 2

    1= 16 + 8 + 2 = 26

    Decimal to Binary

    Take 61 as an example.

    6110 1111012

    1.2 Conversion between Hexadecimal and Binary

    Hexadecimal to Binary

    Consider DE116,

    Therefore, the binary representation ofDE116 is 1101111000012

    Binary to Hexadecimal

    Consider the binary string 1111101010012

    The hexadecimal representation of1111101010012 is FA916

    1111 1010 1001

    F A 9

    = FA916

    1101 1110 0001

    D E 1

  • 8/4/2019 604524007

    3/6

    COMP 212 Computer Organization and Systems

    Page 3 of 6

    1.3 Conversion between Decimal and Hexadecimal

    Hexadecimal to Decimal

    The decimal value of the binary number A0F616is

    163x10 + 16

    1x15 + 16

    0x6 = 40960 + 240 + 6 = 41206

    Decimal to Hexadecimal

    Take 561 as an example.

    56110 23116

    1.4 Decimal vs Binary vs Hexadecimal

    Dec Hex Bin

    15 0F 00001111

    26 1A 00011010

    79 4F 01001111

    255 FF 11111111

  • 8/4/2019 604524007

    4/6

    COMP 212 Computer Organization and Systems

    Page 4 of 6

    Byte notations

    Unit Value

    KB 210 Bytes = 1024 Bytes

    MB 220 Bytes = 1024 KB

    GB 230 Bytes = 1024 MB

    TB 240 Bytes = 1024 GB

    1.5 The ASCII Table: the definition of characters in computers

    The ASCII table is the first computer character coding standard which assigns each

    character symbol a computer code. ASCII code is intended for U.S.A. as interchange

    code. Only 7 bits are used. The high bit (the 8ths bit in a bit) is used as a so called

    parity bit to check for errors in communication (no need to know this part for the time

    being). With the code space of 27

    (128 in total) number of code values to use, it defined

    all the symbols in the English language and also some logical symbols that are not

    printable, but as control code. Below is the ASCII table, where the control characters

    are in the code range of 00 1F, and 7F, the rest are printable characters (20 7E).

    For example:

    A: 4116 or 010000012 or 6510

  • 8/4/2019 604524007

    5/6

    COMP 212 Computer Organization and Systems

    Page 5 of 6

    Exercise 1:

    Please complete the rest of the table

    1st

    2nd

    3rd

    4th

    Hex 0x55

    Dec 110

    Bin 01101001

    ASCII x

    Exercise 2:

    Please convert the followings Hexadecimal value to ASCII code

    1. 0x4D656D6F727920344742

    2. 0x42696E6172792D3031

    3. 0x436F6D7040504F4C5955

    1.6 Application of hexadecimal

    In the computer, we usually use the Hexadecimal values to represent memory

    addresses.

  • 8/4/2019 604524007

    6/6

    COMP 212 Computer Organization and Systems

    Page 6 of 6

    Exercise 3:

    IfHello is stored in the memory address 0x4389, what is the memory address ofo?

    Exercise 4:

    If memory address is 1-byte in length, how many memory addresses it can support?

    Exercise 5:

    What does 1 byte shown in the above memory diagram mean? Is it the memory

    address length? Please explain.