DOC

Chapter 1 Background Info of Computer Languag

By Annie Simmons,2014-06-30 07:04
12 views 0
Chapter 1 Background Info of Computer Languag

Chapter 1 Background Info of Computer Language

    Contents

    1. Introduction

    2. Basic Knowledge

    3. Conversion

    4. Operation

    5. Number and Character

    1. Introduction

    Writing a program in assembly language requires knowledge of the computer’s hardware and details of its instruction set.

    The main internal hardware features of a computer are the memory,

    microprocessor, and registers.

    The main external hardware features are the computer’s I/O devices such as the keyboard, monitor, all sorts of disks and so on.

    Software consists of the various programs and data files (including the operating system) stored on all kinds of disk.

    2. Basic Knowledge

    2.1 Storage capacity

    1K = 1024B = 210 Kilo

    1M = 1024K = 220 Mega

    1G = 1024M = 230 Giga

1 Bit = 1 Binary Digit

    1 Byte = 8 Bit

    1 Word = 2 Byte = 16 Bit

    2.2 Bit

    Bit, the fundamental building block of computer storage is the bit. A bit may be off, so that its value is considered 0, or it may be on, so that its value is considered 1. Though a single bit does not provide much information, it is surprising what group of them can do.

    2.3 Byte

    Byte, A group of nine related bits is called a byte. The group of nine related bits represents storage locations both internally in memory and externally on all kinds of disks .Each byte consists of 8 bits for data and 1 bit for parity.

    The structure of a BYTE The 8 data bits provide the basis for binary arithmetic and for representing

    such characters as the letter ‘A’ and the asterisk symbol(*).

    Each bytes allow 256(28) different combinations of on-off conditions, from all

    bits off (00000000) through all bits on(11111111).For an instance, arepresent

    ation of the bits for the letter ‘A’ is 01000001.

    How does a computer know that bit value 01000001 represents the letter ‘A’?

    When you key in A on the keyboard, the system delivers a signal from that

    particular key into memory and sets a byte (in an internal location)

    to the bit value 01000001. Then you can move the contents of this byte about

    in memory as you will, and you can print it or display it on the screen as letter

    ‘A’.

    How does a computer know that bit value 01000001 represents the letter ‘A’ ?

    When you key in A on the keyboard, the system delivers a signal from that

    particular key into memory and sets a byte (in an internal location)

    to the bit value 01000001. Then you can move the contents of this byte about

    in memory as you will, and you can print it or display it on the screen as letter

    ‘A’.

    2.4 Word

    Which is consisted by two bytes, equal to sixteen bits. The figure below is the

    structure of the word :

    The structure of a WORD 2.5 Relationship

    A program can treat a group of one or more related bytes as a unit of data,

    such as time, distances, or Chinese characters. A group of bytes that defines a

    particular value is commonly known as data item or field. The PC also supports

    certain data sizes that are natural to it:

     Word A 2-byte (16-bit) item.

     Doubleword A 4-byte (32-bit) item.

     Quadword A 8-byte (64-bit) item.

     Paragraph A 16-byte (128-bit) area.

     Kilobyte (KB) The number 210 equals 1,024, which happens to be the

    value K, for kilobyte.

     Megabyte (MB) The number 220 equals 1,048,576, or 1 megabyte.

    The structure below expressed the relationship between byte , word and double word :

2.6 Parity

    In this section, there are two types of parity: odd parity and even parity. Normally, we use odd parity. According to the rule of odd parity, the number of bits in each byte that are on(1) is always odd. Oppositely, the rule even parity is that the number of in each byte that are on (1) is always even. For example, because the letter ‘A’(01000001) contains two bits that are on(1), the processor forces odd parity by automatically setting the parity bit on (01000001-1).

    When an instruction references a byte in internal storage, the processor check its bits for parity . If parity is even, the system assumes that a bit is ”lost” and display an error message .

    A parity error may be a result of a hardware fault or an electrical malfunction; either way, it is a rare event.

    3. Conversion

    3.1 Number System

    Number System

    3.2 Conversion Between Number System

    3.2.1 Conversion between Hexadecimal Number and Binary Number

    To convert a hex number to a decimal number, start with the leftmost hex

    digit, continuously multiply each hex digit by 16, and accumulate the results.

    Because multiplication is in decimal, convert hex digits A through F to decimal

    10 through 15.

    To convert a decimal number to a hex number, first divide the decimal

    number by 16; the remainder becomes the right most hex digit; next divide the

    new quotient by 16, the remainder, becomes the next hex digit to the left.

    Continue in this manner developing the hex number from the remainders of

    each step of the division until the quotient is zero.

    ? Convert from Binary to Hexadecimal

    ? From the right, breaking the binary number into groups of four

    bits

    ? Substitute the corresponding hex digit for each group of four bits

    ? Example 3.2.1

    ? Convert from Hexadecimal To Binary

    ? Substitute four bits for each hex digit

    ? Pading with leading zeros as needed

    ? Example 3.2.1

    3.2.2 Conversion between Binary Number and Decimal Number

    ? Convert from Binary to Decimal

    ? Multiply each bit by powers of 2

    ? Example 3.2.2

    ? Convert from Decimal To Binary

    ? Divide DecimalNumber by 2(base of Binary),getting Quotient and

    Remainder

    ? Remainder is the next digit(right to left);

    ? Example 3.2.2

    3.2.3 Conversion between Hexadecimal Number and Decimal Number

    ? Convert from hexadecimal to Decimal

    ? Example 3.2.3

    ? Multiply each bit by powers of 16

    ? Convert from Decimal To Hexadecimal

    ? Example 3.2.3

    ? Divide DecimalNumber by 16(base of hexadecimal), getting

    Quotient and Remainder

    ? Remainder is the next digit(right to left); Examples

    Example 3.2.1 Binary Hexadecimal

Binary Hexadecimal:

Binary Hexadecimal:

    Example 3.2.2 Binary Decimal

     Binary Decimal

Binary Decimal Descending order & Division

Example 3.2.3 Hexadecimal Decimal

    Hexadecimal Decimal

Hexadecimal Decimal Descending order & Division

4. Operation

    4.1 Arithmetic Operation

    (1) Binary Principle:

    When two occurs, carry 1 to the next more significant position.

     Addition Rules: Multiplication Rules:

(2) Hexadecimal Principle:

    When sixteen occurs, carry 1 to the next more significant position.

    And there are two examples below:

    The first example:

    The second example:

4.2 Logic Operation (by-bit operation)

    AND OR

    NOT XOR

4.3 Logic Operation (by-bit operation)

5. Number and Character

    5.1 Representation of Positive and Negative

    (1)Assuming the machine’s word length is 8-bit

    (2)Assuming the machine’s word length is16-bit

    5.2 Original Anti and Two’s Complement Code

    Representation of original code : symbol + absolute value

    e.gn = 8bit

    Anti-code expression

    Anti-code of a positive number is the positive number itself.

    e.gn = 8bit

     [+ 5]A = 0 000, 0101 = 05H

     [- 5]A = 1 111, 1010 = FAH

    *[+ 0]A = 0 000,0000 = 00H

    *[ - 0]A = 1 111,1111 = FFH

    Representation of Two’s Complement:

    Positive: the same with the original code

    Negative:

    (1)Write the absolute value of a negative number that corresponds to the

    complement

    (2)By-bit for the anticode

    (3)The bottom-plus-one

    Example:

    e.g. The length of the machine is eight bitsthe two’s complement of [- 46]

    = ?

    5.3 Addition and Subtraction of Two’s Complement Addition rules:

    [X+Y] =[X] +[Y] two’s Complementtwo’s Complementtwo’s ComplementSubtraction rules:

    [X-Y] =[X]+[-Y] two’s Complementtwo’s Complementtwo’s ComplementSubtraction can be implement by addition.

5.4 Representation of Characters

    Letters, numerals, punctuation marks, and other characters are represented in

    a computer by assigning a numeric value to each character. Several schemes

    for assigning these numeric values have been used. The system commonly

    used with microcomputers is the American Standard Code for Information

    Interchange (abbreviated ASCII and pronounced ASK-ee).

ASCII CODE:

    To standardize the representation of data, microcomputer manufactures

    have adopted the ASCII (American National Standard Code for Information

    Interchange) code. The ASCII code facilitates the transfer of data between

    different computer devices.

    The 8-bit ASCII code that the PC uses provides 256 characters, including

    symbols for foreign alphabets. In the text book, appendix B provides a

    convenient list of the 256 ASCII characters.

    ? Seven bits to represent characters, so 128 different characters can be

    represented using ASCII codes.

    ? Printable characters: 20h~7eh

    ? A~Z 41h~5ah

    ? a~z 61h~7ah

    ? 0~9 30h~39h

    ? Control characters:00h~1fh

    ? ESC 1bh , 0dh carriage return(CR), 0AH line feed(LF)

    Expressed as a one-byte character, the low seven for the ASCII character

    values, generally used for high parity bit.

    To standardize the representation of data, microcomputer manufactures have

    adopted the ASCII code. The ASCII code facilitates the transfer of data

    between different computer devices.

For an example:

     ASCII Characters:

    E.g. ‘A’ 41H

     ‘a’ 61H

     ‘1’ 31H

     ENTER 0DH

Report this document

For any questions or suggestions please email
cust-service@docsford.com