Presentation is loading. Please wait.

Presentation is loading. Please wait.

MIPS Architecture Topics –What resources MIPS assembly manipulates –CPU (Central Processing Unit) –ALU (Arithmetic & Logical Unit), Registers –Memory –I/O.

Similar presentations


Presentation on theme: "MIPS Architecture Topics –What resources MIPS assembly manipulates –CPU (Central Processing Unit) –ALU (Arithmetic & Logical Unit), Registers –Memory –I/O."— Presentation transcript:

1 MIPS Architecture Topics –What resources MIPS assembly manipulates –CPU (Central Processing Unit) –ALU (Arithmetic & Logical Unit), Registers –Memory –I/O –How are resources being manipulated Data transfer Arithmetic Operations I/O

2 MIPS Architecture (Microprocessor without Interlocked Pipeline Stages) CPU

3 Assembly Programmer’s View Programmer-Visible State –Program Counter (PC) Address of next instruction –Location Counter (LOC) –Register File Heavily used program data –Condition Codes Store status information about most recent arithmetic operation Used for conditional branching Memory Object Code Program Data OS Data Addresses Data Instructions Stack – Memory Byte addressable array (organized in words) Code, user data, (some) OS data Includes stack PC Registers CPU Condition Codes

4 Registers 32 32-bit Registers –Zero: always 0, and cannot be modified –$t0 -- $t9 (10): General purpose –$a0 -- $a3 (4): General purpose (arguments) –$s0 -- $s7 (8): General purpose –$v0, $v1 (2): General purpose –$sp (1): stack pointer –$ra (1): return address

5 Resources Memory Address: 32-bit Data: 32-bit Min. data unit: 8-bit Registers – 32 registers – Temporary data memory ALU – operators

6 Operations on Resources Memory Store Retrieve Registers – Store – Retrieve ALU – Arithmetic/logical operators

7 Operations on Resources Memory Storesw reg, D(reg) Retrievelw reg, D(reg) (indirect, indexed) Registers – Storeli reg, literal (immdiate) la reg, addr move reg1, reg2 (or reg1, reg2, $0) – Retrieve ALU – operators

8 Data Transfer X = A[1] (load word) Compute Effective Address (address of A + index offset in bytes) Transfer the effective address to Memory Address Register (MAR) Read memory into Memory Data Register (MDR) Transfer to CPU register A[1] = X (store word) Transfer register to MDR Computer effective address to MAR Write

9 Arithmetic Operation X =X+Y Transfer X, Y (in registers) to ALU (Arithmetic & Logic Unit) Add Transfer the sum to a register

10 MIPS instructions http://www.mrc.uidaho.edu/mrc/people/jff/digital/MIPSi r.htmlhttp://www.mrc.uidaho.edu/mrc/people/jff/digital/MIPSi r.html www.cs.uml.edu/~kim/203/mips_instr.xls MIPS Reading www.cs.uml.edu/~kim/203/mips.doc MARS MIPS simulator http://courses.missouristate.edu/KenVollmar/MARS/ Resources

11 Assembly Instruction label: instruction operand {,operand} #comments label – a place holder: address Instruction – operation to perform Operand – data or target of the operation Register Literal constant Memory address

12 Directives (Establish initial data structure).ascii (store string in memory with no null-termination).asciiz (store string in memory with null termination).byte b1,..,bn.word w1,..,wn.word w:n (store w into n successive words).space n.datadata segment.textassembly instructions Directives

13 Data Transfer From the viewpoint of registers Moving Data lw Dest, Source: – Move 4-byte (“long”) word – Constant or from memory address – To Dest register Operand Types – Immediate: Constant integer data 0xff for hex constant Otherwise, decimal – Memory: 4 consecutive bytes of memory Various “address modes” – Register: One of 32 integer registers

14 Addressing Modes Indirect(R) Mem[Reg[R]] – Register R specifies memory address lw $t1, ($t2) IndexedD(R) Mem[Reg[R]+D] – Register R specifies start of memory block – Constant displacement D specifies offset lw $t1, 8($t2)

15 Operand Addressing –No instruction for reg-to-reg transfer –Cannot do memory-memory transfers with single instruction –sw instruction violates (dest, source) spec of operands Imm Reg Mem Reg Mem Reg SourceDestination li $t1, 0x4 la $t1, A sw $t1,A($t2) lw $t1,A($t2) C Analog temp = 0x4; temp2 = &A; A[n] = temp; temp = A[n]; Addr

16 .data array:.word0x37, 0x55, 0xF.text la $s0, array la$s1, array+4 la$s2, 8($s0) li$a0, 4 lw$t0, 0($s0) lw$t3, array($a0) lw$t1, 8($s0) lb$t2, ($s0) Example

17 I/O Instructions ServiceCall code ($v0) Arguments (input)Results print integer 1$a0 = integersigned decimal integer printed in console window print string4$a0 = address of stringstring printed in console window Read integer 5(none)$v0 holds integer that was entered Read string8$a0=address to store $a1= length limit characters are stored exit10(none)Ends the program – http://courses.missouristate.edu/kenvollmar/mars/help/syscallhelp.h tml

18 .data prompt:.asciiz“Enter an integer to square:\n“ # message area.text main:# printf(“Enter an integer to square: \n”); la $a0, prompt # get the address of the message to $a0 li $v0, 4 # read to display the message syscall # scanf(“%d”, x); li $v0, 5 # read an integer into $v0 syscall mul$a0, $v0, $v0 # squared input value, save in $a0 # printf(“%4d”, (x*x)); li $v0, 1 # print the squared value syscall printf(“Enter an integer to square: \n”); scanf(“%d”, x); printf(“%4d”, (x*x)); Square an input Number


Download ppt "MIPS Architecture Topics –What resources MIPS assembly manipulates –CPU (Central Processing Unit) –ALU (Arithmetic & Logical Unit), Registers –Memory –I/O."

Similar presentations


Ads by Google