Machine Language vs Assembly Language
machine instruction statement
|
assembly language
|
0000 0001 0010 1011 1000 0000 0010 0000
|
add $t0,$t1,$t2
|
The instruction means:
- add the integers in registers $t1 and $t2 and put the result in register $t0.
-
Assembly language —(assembler)—> Machine language
translator
Instruction Set
- Instructions are the language of the machine
Instructions Set Architecture (ISA) - Defines a "family" of microprocessors
- Examples: Intel x86 (IA32), Sun Sparc, DEC Alpha, IBM/360, IBM PowerPC, M68K, DEC VAX
- ISA includes:
◦Instruction set
◦Rules for using instructions --> Mnemonics, functionality, addressing modes
◦Instruction encodingThe Organization of A Computer
- There are five basic components:
- Input - devices that writes data to memory
- Output - devices that read data from memory and convey result of the computation
- Datapath (ALU) - performs arithmetic operations
- Memory - the storage area (keeping data that are needed by the running programs)
- Control - the component of a processor that sends the signals which
determine the operations of the datapath,memory,input and outputby : Nor Izzati
The process of processor completing three basic steps to execute one machine instruction is called machine cycle
MIPS is a reduced instruction set computer (RISC) instruction set architecture
Register- 32 general-purpose registers
- register preceded by $ in assembly language instruction two formats for addressing:
--> using register number e.g $0 through $31
--> using equivalent names e.g $t1,$sp - special registers Lo and Hi used to store result of
multiplication and division
--> not directly addressable; contents accessed with special mfhi ("move from Hi") and mflo
("move from Lo") - stack grows from high memory to low memory
-
Register
NumberAlternative
NameDescription
0zerothe value 01$at(assembler temporary) reserved by the assembler2-3$v0 - $v1(values) from expression evaluation and function results4-7$a0 - $a3(arguments) First four parameters for subroutine.
Not preserved across procedure calls8-15$t0 - $t7(temporaries) Caller saved if needed. Subroutines can use w/out saving.
Not preserved across procedure calls16-23$s0 - $s7(saved values) - Callee saved.
A subroutine using one of these must save original and restore it before exiting.
Preserved across procedure calls24-25$t8 - $t9(temporaries) Caller saved if needed. Subroutines can use w/out saving.
These are in addition to $t0 - $t7 above.
Not preserved across procedure calls.26-27$k0 - $k1reserved for use by the interrupt/trap handler28$gpglobal pointer.
Points to the middle of the 64K block of memory in the static data segment.29$spstack pointer
Points to last location on the stack.30$s8/$fpsaved value / frame pointer
Preserved across procedure calls31$rareturn addressThis is from Figure 9.9 in the Goodman&Miller textSystem call functions
System Calls
- used to read or print values or strings from input/output window, and indicate program end
- use syscall operating system routine call
- first supply appropriate values in registers $v0 and $a0-$a1
- result value (if any) returned in register $v0
Service Code
in $v0Arguments Results print_int 1$a0 = integer to be printed print_float 2$f12 = float to be printed print_double 3$f12 = double to be printed print_string 4$a0 = address of string in memory read_int 5integer returned in $v0 read_float 6float returned in $v0 read_double 7double returned in $v0 read_string 8$a0 = memory address of string input buffer
$a1 = length of string buffer (n)sbrk 9$a0 = amount address in $v0 exit 10
- There are five basic components:
Program Structure
- just plain text file with data declarations, program code (name of file should end in suffix .s to be used with SPIM simulator)
- data declaration section followed by program code section
- have a format that comprises of four columns:
Bagus. Sangat membantu. Thanks :)
ReplyDeleteterima kasih harap membantu anda :)
DeleteAwesome. Thans for the info. :)
ReplyDeletebagus3... maklumat yang berguna.. haaa..
ReplyDelete