logging in or signing up Basics dipsimt Download Post to : URL : Related Presentations : Share Add to Flag Embed Email Send to Blogs and Networks Add to Channel Uploaded from authorPOINT lite Insert YouTube videos in PowerPont slides with aS Desktop Copy embed code: (To copy code, click on the text box) Embed: URL: Thumbnail: WordPress Embed Customize Embed The presentation is successfully added In Your Favorites. Views: 18 Category: Education License: All Rights Reserved Like it (0) Dislike it (0) Added: August 01, 2011 This Presentation is Public Favorites: 0 Presentation Description No description available. Comments Posting comment... Premium member Presentation Transcript Basics Instruction Set Architecture: Basics Instruction Set Architecture Panickos Neophytou Recitation 1 – 09/07/2005 09/12/2005 CS0447: Computer Organization and Assembly Link for this presentation: www.cs.pitt.edu/~panickos/classes/cs0447/Basics.pptContact info: Contact info Panickos Neophytou Office 6514 Sennott Square Office Hours: Monday 2:30-5:30 & Tuesday 3:45-6:45 Email panickos@cs.pitt.edu (use “cs0447” anywhere in the subject to get my attention) TA’s course web page www.cs.pitt.edu/~panickos/classes/cs0447 (under construction BUT available)Outline: Outline Decimal to Binary conversions Binary to Hexadecimal conversions Instruction Set Architecture SPIMDecimal to Binary conversions: Decimal to Binary conversions Example 1 - (Convert Decimal 44 to Binary)Decimal to Binary conversions: Decimal to Binary conversions Example 2 - (Convert Decimal 15 to Binary)Decimal to Binary conversions: Decimal to Binary conversions Example 3 - (Convert Decimal 62 to Binary)Binary to Hexadecimal conversions: Binary to Hexadecimal conversions In the Hexadecimal system you have 16 symbols to represent natural numbers. Dec. Hex Dec. Hex 0 0 8 8 1 1 9 9 2 2 10 A 3 3 11 B 4 4 12 C 5 5 13 D 6 6 14 E 7 7 15 FBinary to Hexadecimal conversions: Binary to Hexadecimal conversions Convert the following Hex number to Binary: 286F A3E1 Convert the following Binary number to Hexadecimal: 0101 0011 1111 0110 1011 1010 0001 1100Instruction Set Architecture: Instruction Set Architecture op Operation code rs First source register operand rt Second source register operand rd Destination register operand shamt Shift amount - used in shift instructions funct Select the variant of the operation in the op code field op rs rt rd shamt funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bitsInstruction Set Architecture: Instruction Set Architecture Specific Instruction Formats Format 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits Comments R op rs rt rd shamt funct Arithmetic I op rs rt address/immediate Transfer, branch,immediate J op target address JumpInstruction Set Architecture: Instruction Set Architecture Arithmetic Instructions Instruction Example Meaning Comments add add $1,$2,$3 $1=$2+$3 Always 3 operands subtract sub $1,$2,$3 $1=$2-$3 Always 3 operands add immediate addi $1,$2,10 $1=$2+10 add constant add unsigned addu $1,$2,$3 $1=$2+$3 Always 3 operations subtract unsigned subu $1,$2,$3 $1=$2-$3 Always 3 operations add immed.unsigned addiu $1,$2,10 $1=$2+10 Always 3 operationsInstruction Set Architecture: Instruction Set Architecture Logical Instruction Example Meaning Comments and and $1,$2,$3 $1=$2&$3 3 register operands or or $1,$2,$3 $1=$2|$3 3 register operands and immediate andi $1,$2,10 $1=$2&10 AND constant or immediate or $1,$2,10 $1=$2|10 OR constant shift left logical sll $1,$2,10 $1=$2<<10 Shift left by constant shift right logical srl $1,$2,10 $1=$2>>10 Shift right by constantInstruction Set Architecture: Instruction Set Architecture Data Transfer Instruction Example Meaning Comments load word lw $1,10($2) $1=Memory[$2+10] memory to register store word sw $1,10($2) Memory[$2+10]=$1 register to memory load upper immed. lui $1,10 $1=10x2^16 load constant into upper 16 bitsInstruction Set Architecture: Instruction Set Architecture Conditional Branch Instruction Example Meaning Comments branch on equal beq $1,$2,10 if($1==$2)go to PC+4+10 Equal test branch on not equal bne $1,$2,10 if($1!=$2)go to PC+4+10 Not equal test set on less then slt $1,$2,$3 if($2<$3)$1=1;else $1=0 Less than compareInstruction Set Architecture: Instruction Set Architecture Unconditional Jump Instruction Example Meaning Comments jump j 1000 go to 1000 Jump to target address jump register jr $31 go to $31 For switch, procedure return jump and link jal 1000 $31=PC+4;go to 1000 For procedure callSPIM: SPIM Spim is a self-contained simulator that will run MIPS32 assembly language programs. Freeware Can be downloaded and installed onto Windows or Unix based machines from: http://www.cs.wisc.edu/~larus/spim.html Will be used for assignmentsSPIM: SPIM Registers Instructions Loaded Data OutputSPIM - Assembler Syntax: SPIM - Assembler Syntax Program includes .data and .text Comments begin with #. Rest of line is ignored. Identifier names are sequence of letters, numbers, underbars (_) and dots (.). Labels are declared by putting them at beginning of line followed by colon. Use labels for variables and code locations. Instruction format: op field followed by one or more operands: addi $t0, $t0, 1 Operands may be literal values or registers. Register is hardware primitive, can stored 32-bit value: $s0 Numbers are base 10 by default. 0x prefix indicates hexadecimal. Strings are enclosed in quotes. May include \n=newline or \t=tab. Used for prompts.SPIM: SPIM Simple Example: # SPIM Code to print hello world # a comment starts with a till the end of the line .data # start putting stuff in the data segment greet: .asciiz “Hello world\n” # declare greet to be the string .text # start putting stuff in the text segment main: # main is a label here. Names a function li $v0, 4 # system call code for print_str la $a0, greet # address of string to print syscall # print the string jr $ra # return from main # here li is load immediate into an integer register # la is load computed address into an integer register # jr is standard return from function call...$ra contains return addressSPIM: SPIM Modify the program by adding these instructions: addi $10, $10, 4 addi $11, $11, 28 add $12, $10, $11 Use the “step” option (from the Simulator menu) of SPIM to watch your program’s execution step-by-step.MIPS Basics : MIPS Basics Implementing Conditional Statements if ( i == j ) i++; j--; bne $r1, $r2, L1 # branch if ! ( i == j ) addi $r1, $r1, 1 # i++ L1: addi $r2, $r2, -1 # j-- if ( i == j ) i++; else j--; j += i ; bne $r1, $r2, ELSE #branch if !( i == j ) addi $r1, $r1, 1 # i++ j L1 # jump over else ELSE: addi $r2, $r2, -1 # j– L1: add $r2, $r2, $r1 # j += i You do not have the permission to view this presentation. In order to view it, please contact the author of the presentation.
Basics dipsimt Download Post to : URL : Related Presentations : Share Add to Flag Embed Email Send to Blogs and Networks Add to Channel Uploaded from authorPOINT lite Insert YouTube videos in PowerPont slides with aS Desktop Copy embed code: (To copy code, click on the text box) Embed: URL: Thumbnail: WordPress Embed Customize Embed The presentation is successfully added In Your Favorites. Views: 18 Category: Education License: All Rights Reserved Like it (0) Dislike it (0) Added: August 01, 2011 This Presentation is Public Favorites: 0 Presentation Description No description available. Comments Posting comment... Premium member Presentation Transcript Basics Instruction Set Architecture: Basics Instruction Set Architecture Panickos Neophytou Recitation 1 – 09/07/2005 09/12/2005 CS0447: Computer Organization and Assembly Link for this presentation: www.cs.pitt.edu/~panickos/classes/cs0447/Basics.pptContact info: Contact info Panickos Neophytou Office 6514 Sennott Square Office Hours: Monday 2:30-5:30 & Tuesday 3:45-6:45 Email panickos@cs.pitt.edu (use “cs0447” anywhere in the subject to get my attention) TA’s course web page www.cs.pitt.edu/~panickos/classes/cs0447 (under construction BUT available)Outline: Outline Decimal to Binary conversions Binary to Hexadecimal conversions Instruction Set Architecture SPIMDecimal to Binary conversions: Decimal to Binary conversions Example 1 - (Convert Decimal 44 to Binary)Decimal to Binary conversions: Decimal to Binary conversions Example 2 - (Convert Decimal 15 to Binary)Decimal to Binary conversions: Decimal to Binary conversions Example 3 - (Convert Decimal 62 to Binary)Binary to Hexadecimal conversions: Binary to Hexadecimal conversions In the Hexadecimal system you have 16 symbols to represent natural numbers. Dec. Hex Dec. Hex 0 0 8 8 1 1 9 9 2 2 10 A 3 3 11 B 4 4 12 C 5 5 13 D 6 6 14 E 7 7 15 FBinary to Hexadecimal conversions: Binary to Hexadecimal conversions Convert the following Hex number to Binary: 286F A3E1 Convert the following Binary number to Hexadecimal: 0101 0011 1111 0110 1011 1010 0001 1100Instruction Set Architecture: Instruction Set Architecture op Operation code rs First source register operand rt Second source register operand rd Destination register operand shamt Shift amount - used in shift instructions funct Select the variant of the operation in the op code field op rs rt rd shamt funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bitsInstruction Set Architecture: Instruction Set Architecture Specific Instruction Formats Format 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits Comments R op rs rt rd shamt funct Arithmetic I op rs rt address/immediate Transfer, branch,immediate J op target address JumpInstruction Set Architecture: Instruction Set Architecture Arithmetic Instructions Instruction Example Meaning Comments add add $1,$2,$3 $1=$2+$3 Always 3 operands subtract sub $1,$2,$3 $1=$2-$3 Always 3 operands add immediate addi $1,$2,10 $1=$2+10 add constant add unsigned addu $1,$2,$3 $1=$2+$3 Always 3 operations subtract unsigned subu $1,$2,$3 $1=$2-$3 Always 3 operations add immed.unsigned addiu $1,$2,10 $1=$2+10 Always 3 operationsInstruction Set Architecture: Instruction Set Architecture Logical Instruction Example Meaning Comments and and $1,$2,$3 $1=$2&$3 3 register operands or or $1,$2,$3 $1=$2|$3 3 register operands and immediate andi $1,$2,10 $1=$2&10 AND constant or immediate or $1,$2,10 $1=$2|10 OR constant shift left logical sll $1,$2,10 $1=$2<<10 Shift left by constant shift right logical srl $1,$2,10 $1=$2>>10 Shift right by constantInstruction Set Architecture: Instruction Set Architecture Data Transfer Instruction Example Meaning Comments load word lw $1,10($2) $1=Memory[$2+10] memory to register store word sw $1,10($2) Memory[$2+10]=$1 register to memory load upper immed. lui $1,10 $1=10x2^16 load constant into upper 16 bitsInstruction Set Architecture: Instruction Set Architecture Conditional Branch Instruction Example Meaning Comments branch on equal beq $1,$2,10 if($1==$2)go to PC+4+10 Equal test branch on not equal bne $1,$2,10 if($1!=$2)go to PC+4+10 Not equal test set on less then slt $1,$2,$3 if($2<$3)$1=1;else $1=0 Less than compareInstruction Set Architecture: Instruction Set Architecture Unconditional Jump Instruction Example Meaning Comments jump j 1000 go to 1000 Jump to target address jump register jr $31 go to $31 For switch, procedure return jump and link jal 1000 $31=PC+4;go to 1000 For procedure callSPIM: SPIM Spim is a self-contained simulator that will run MIPS32 assembly language programs. Freeware Can be downloaded and installed onto Windows or Unix based machines from: http://www.cs.wisc.edu/~larus/spim.html Will be used for assignmentsSPIM: SPIM Registers Instructions Loaded Data OutputSPIM - Assembler Syntax: SPIM - Assembler Syntax Program includes .data and .text Comments begin with #. Rest of line is ignored. Identifier names are sequence of letters, numbers, underbars (_) and dots (.). Labels are declared by putting them at beginning of line followed by colon. Use labels for variables and code locations. Instruction format: op field followed by one or more operands: addi $t0, $t0, 1 Operands may be literal values or registers. Register is hardware primitive, can stored 32-bit value: $s0 Numbers are base 10 by default. 0x prefix indicates hexadecimal. Strings are enclosed in quotes. May include \n=newline or \t=tab. Used for prompts.SPIM: SPIM Simple Example: # SPIM Code to print hello world # a comment starts with a till the end of the line .data # start putting stuff in the data segment greet: .asciiz “Hello world\n” # declare greet to be the string .text # start putting stuff in the text segment main: # main is a label here. Names a function li $v0, 4 # system call code for print_str la $a0, greet # address of string to print syscall # print the string jr $ra # return from main # here li is load immediate into an integer register # la is load computed address into an integer register # jr is standard return from function call...$ra contains return addressSPIM: SPIM Modify the program by adding these instructions: addi $10, $10, 4 addi $11, $11, 28 add $12, $10, $11 Use the “step” option (from the Simulator menu) of SPIM to watch your program’s execution step-by-step.MIPS Basics : MIPS Basics Implementing Conditional Statements if ( i == j ) i++; j--; bne $r1, $r2, L1 # branch if ! ( i == j ) addi $r1, $r1, 1 # i++ L1: addi $r2, $r2, -1 # j-- if ( i == j ) i++; else j--; j += i ; bne $r1, $r2, ELSE #branch if !( i == j ) addi $r1, $r1, 1 # i++ j L1 # jump over else ELSE: addi $r2, $r2, -1 # j– L1: add $r2, $r2, $r1 # j += i