110 likes | 283 Views
The MIPS Processor. Appendix A. Assembly Language. Symbolic representation of a computer's machine language. more readable than machine language each processor has its own assembly language no two assembly languages are the same. Why Use Assembly Language. Primary reason:
E N D
The MIPS Processor Appendix A
Assembly Language • Symbolic representation of a computer's machine language. • more readable than machine language • each processor has its own assembly language • no two assembly languages are the same.
Why Use Assembly Language • Primary reason: • for speed or size of a critical application • compiler may not produce the best instructions • have better control over which instructions are used • Example: • embedded systems or devices
Drawbacks of Assembly Language • Are not widely used by everyday programmers • programs are machine dependent • programs are longer than those in a high-level language • programs have no structure; hard to read
The Assembler • Translates assembly language instructions into machine language instructions
Translation • Symbols can be used before they are defined. • A two step translation is required: • resolve labels (find memory locations) • translate assembly instructions
Sample Program # # Prints all primes in the numbers 1 - 100 # .text main: li $t0, 1 WHILE: bgt $t0, 100, WHILE_END move $a0, $t0 jal TEST_PRIME beqz $v0, INC1 la $a0, Message move $a1, $t0, jal PRINTF INC1: addi $t0, $t0, 1 j WHILE WHILE_END: li $v0, 10 syscall ################################### .data Message: .asciiz "This number is prime: " NEWLINE: .asciiz "\n"
Object File • object code - machine instructions, data, and bookkeeping info. • can not be executed directly • it may refer to routines in other object files • Six distinct sections on Unix systems:
The Linker • linker - combines a collection of object files into an executable file. • programs can be split into smaller pieces (files) • each file contains logically related routines and data
The Loader • loader - used to load a program into memory • sets the registers • initializes the program counter • For the MIPS processor: