Sie sind auf Seite 1von 19

Lesson: Language of

Computer
CITA 152: COMPUTER LOGIC
FUAD URI
Homework - reflection
1. .are easy
2. .quick to finish
3. .and have deadline
Signed and Unsigned Numbers
Base 10 : 1, 2, 3, ., 10, 11,
.

Number 123ten = 11110112


Converting from binary to decimal
If we have binary number 1011two

(1 23) + (0 22) + (1 21) + (1 20)ten

= (1 8) + (0 4) + (1 2) + (1 1) ten

= 8 + 0 + 2 + 1ten

= 11ten
Exercise
1111two is
Overflow
For 32 bits number

1111 1111 1111 1111 1111 1111 1111 1111two = 4,294,967,295ten

If the number that is the proper result of such operations cannot be


represented by these rightmost hardware bits, overflow is said to have
occurred.
Negative numbers
How to represent negative numbers?

-1110101 or 101011-?
Example
Example / quick way
Representing Instructions in Computer
add $t0, $s1, $s2

This is called instruction format

numeric version of instruction is machine language


R - Instruction format (for register)

op: Basic operation of the instruction, traditionally called the opcode.


rs: The first register source operand.
rt: The second register source operand.
rd: The register destination operand. It gets the result of the operation.
shamt: Shift amount. (Section 2.6 explains shift instructions and this
term; it will not be used until then, and hence the field contains
zero in this section.)
funct: Function. This field, often called the function code, selects the
specific variant of the operation in the op field.
I - type instruction format (for immediate)

R or I format is distinguished by values of first field.


Example
If $t1 has the base of the array A and $s2 corresponds to h, the
assignment statement

A[300] = h + A[300];

lw $t0,1200($t1) # Temporary reg $t0 gets A[300]


add $t0,$s2,$t0 # Temporary reg $t0 gets h + A[300]
sw $t0,1200($t1) # Stores h + A[300] back into A[300]
Compiler
Compiles C language into Assembly language
Assembler
Compiles Assembly code into machine code.

The assembler turns the assembly language program into an object file.

Assemblers keep track of labels used in branches and data transfer


instructions in a symbol table: pair of address and sybols.
Linker
Instead of compiling or assembling the whole code for minor change.

Alternative: compile or assemble each procedure independently. So we


need way to link these procedures. Links assembly language programs.
Loader
A systems program that places an object program in main memory
so that it is ready to execute.
Dynamically Linked Libraries
Problem 1: library is part of exe code., if we change library.

Problem 2: loads all libraries, even if we do not need them.

These disadvantages lead to dynamically linked libraries (DLLs), where


the library routines are not linked and loaded until the program is run.

Das könnte Ihnen auch gefallen