일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- Class
- DB
- MacOS
- Pipelining
- mysql
- Algorithm
- instruction
- react
- for
- data structure
- web
- while
- XML
- python
- github
- html
- php
- function
- DATAPATH
- control
- system
- MIPS
- DoM
- CSS
- Linux
- computer
- architecture
- Java
- DS
- javascript
- Today
- Total
목록instruction (12)
YYYEJI

Procedure call을 할 때 stack을 사용합니다. ✓ main 함수는 caller ✓ label 함수는 callee ʷʰʸ main 함수에서 $s0 register을 사용하다가 jal instruction을 수행해서 label 함수로 갔을 때 label 함수도 $s0 register을 사용할 수도 있습니다. 이때, main 함수에서 $s0 값을 저장하지 않고 label 함수로 넘어간다면 main 함수의 $s0 값이 사라지게 됩니다. 그래서 caller 함수에서는 stack register의 값을 push하고 pop 할 수 있습니다. 위와 같이 register의 값을 저장하기 위해 stack을 사용합니다. ✓ Stack poiner ($sp)로 어느 stack의 위치가 active한지 알려줍니다..

Procedure 란 C에서 흔히 말하는 function을 말합니다. subroutine이라는 이름도 사용합니다. 즉, Procedure, function, subroutine은 함수를 의미하는 단어들 입니다. Procedure call 은 함수를 부르는 과정입니다. MIPS에서 procedure에 관련된 공간은 아래와 같습니다. ① $a0 ~ $a3 - argument ② $v0 ~ $v1 - return value ③ $ra - return address procedure call 을 할 때 사용하는 instruction은 JAL과 JR이 있습니다. ① JAL Label - function call 이 실행되면 ✓ $ra ← 104 (Current PC value) ✓ PC ← 200 (from 10..

Pseudo instruction란? 실제 instruction은 아니지만 컴퓨터가 이해할 수 있는 instruction입니다. ✓ 간결한 코딩이 가능 ✓ 생산성이 향상 ① COPY Ex) move $t0, $t1 → MIPS에서는 add $t0, $t1, $zero로 인식합니다. ② Branch if Less Than Ex) blt $t0, $t1, L → if ($t0 $t1) goto L ④ Branch if Greater (Less) Than or Equal to Ex) bge $t0, $t1, L → if ($t0 >= $t1) goto L ◡̈

OP code Function code Instruction format ↑↑↑ 위에 표들을 참고해서 문제를 푸시면 됩니다 ↑↑↑ Loop: add $t1, $s3, $s3 add $t1, $t1, $t1 add $t1, $s3, $s6 lw $t0, 0($t1) bne $t0, $s5, Exit add $s3, #s3, #s4 j Loop Exit: Q1) add $t1, $s3, $s3 0 19 19 9 0 32 Binary: 000000 10011 10011 01001 00000 100000 Hexadecimal: 0x02734820 Q2) add $t1, $st1, $t1 0 9 9 9 0 32 Q3) add $t1, $t1, $s6 0 9 22 9 0 32 Q4) lw $t0, 0($t1) 35..

MIPS에는 3개의 instruction format이 있습니다. ① R type - 6field ② I type - 4field ③ J type - 2 field Instruction format을 살펴보기 전에 용어부터 살펴봅시다. R type에서는 ✓ op - operation code (opcode) ✓ rs - first source operand ✓ rt - second source operand ✓ rd - destination operand ✓ shamt - shift amount ✓ funct - funcion code I type에서는 ✓ op - operation code (opcode) ✓ rs - source operand ✓ rt - destination operand 다음으로는..

① Arithmetic instruction Format Instruction Format Meaning R ADD ADD rd, rs, rt rd ← rs+ rt R SUB SUB rd, rs, rt rd ← rs - rt I ADDI ADDI rt, rs, imm16 rt ← rs + se(imm16) R SLT SLT rd, rs, rt rd ← (rs

① BEQ / BNE 16-bit Offset ② J 26-bit address ③ JR 32-bit address 많은 거리를 jump하고 싶을 땐 많은 address를 가지고 있는 ③을 이용해라. ↓↓↓ BEQ / BNE ↓↓↓ https://yyyeji.tistory.com/120 [CS] MIPS Conditional branch Instruction (BEQ, BNE) ① BEQ - Branch if Equal Ex) BEQ $s1, $s2, label # if($s1 == $s2) PC op = 4 rs = 17 rt = 18 offset (word count) $s1의 값과 $s2의 값이 같으면 label의 값이 계산되어서 PC에 들어갑니다. ② BNE - Br.. yyyeji.tistory..

JUMP - 16bits 새로운 target 주소(PC)로 점프하는 instruction입니다. Ex) J label → PC = target address (Memory addressing mode와 굉장히 밀접한 관련이 있다.) op = 2 word address (Jump instruction의 op code는 2) Jump Register - 26bits JR $ra # PC ← $ra ( $ra → 31 register) op = 0 rs = 31 rt = 0 rd = 0 shamt = 0 func = 8 (R type 이기 때문에 op code는 0) (function code가 8이면 JR instruction) ($ra가 31번째 있기 때문에 rs가 31번) (나머지는 0으로 채워줌) Ju..