일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- control
- XML
- python
- react
- DB
- Linux
- javascript
- computer
- html
- Class
- MacOS
- data structure
- system
- Pipelining
- while
- DS
- Algorithm
- architecture
- DATAPATH
- php
- for
- Java
- mysql
- DoM
- MIPS
- CSS
- function
- web
- instruction
- github
- Today
- Total
목록system (66)
YYYEJI

Console 화면에 출력하는 코드는 아래와 같습니다. public static void main(String[] args) { System.out.print("Hello! "); System.out.println("There"); System.out.print("Welcome to My Blog !"); } 위에 코드에서 print, println이 쓰였습니다. 둘의 차이점은 무엇일까요? print는 결과 출력 후 줄바꿈을 하지 않지만 println은 출력 후 줄바꿈을 해줍니다. ◡̈

IEEE (Institute of Electrical and Electronics Engineers) 에서는 F.P에 대한 표준 format을 가지고 있습니다. Machine code로 F.P를 표현하기 위해서 IEEE 754 format을 사용합니다. (2진수로 부동소수점으로 표현하라는 의미입니다.) 왜 필요할까요? ① Fraction 표현 Ex) 3.1416 . . . ② 매우 작은 숫자를 표현 Ex) .000000001 ③ 매우 큰 숫자를 표현 Ex) 3.12345 x 10^n 하기 위해서 입니다. Format을 알아봅시다. ① Scientific notation coefficient X (base number) ^ exponent Ex) 7.1234 X 10^4 , 0.1234 ^ 10^9 ② N..

MIPS version 나눗셈 연산을 알아보기 전에 나눗셈 format을 살펴보겠습니다. 0001001 # quotient ---------------- 1000 | 1001010 # Divisor and Dividend - 1000 ---------------- 10 # Partial remainder ........ ---------------- 10 # Remainder 본격적으로 MIPS 나눗셈 수행 방식을 알아보겠습니다. 알고리즘은 아래와 같습니다. partial에서 remainder가 divisor보다 크거나 작으면 quotient bit가 1이 됩니다. 반대로 작으면 quotient bit는 0이 됩니다. MIPS에서 나눗셈 수행 결과는 HI register와 LO register에 담기는데..

MIPS version 곱셈 연산을 알아보기 전에 곱셈 format을 살펴보겠습니다. 0010 # multiplicand X 1001 # multiplier ---------------------------------- 0010010 # product 본격적으로 MIPS 곱셈 수행 방식을 알아보겠습니다. MIPS는 곱셈을 하는데 있어서 하드웨어를 줄이는 방법으로 발전해 왔습니다. (In MIPS, Multiplier은 계속 오른쪽으로 shift 시키기 때문에 생략하겠습니다.) Version 1 Multiplicand를 왼쪽으로 움직이고, product는 움직이지 않습니다. (Using shift left logic) Version2 Multiplicand와 product를 상대적으로 생각해서 Multip..

** C code를 기준 ** 아래 코드를 MIPS assembly code로 변환해 보겠습니다. #include int main(void){ int i = 1; int sum = 0; int n = 15; while(in) goto exit div $t0, $t2 # hi = i/3 mfhi $t3 # t3 = hi bne $t3, $zero, loop # if (t3 != 0) goto loop add $t1, $t1, $t0 # sum += i j loop exit: li $v0, 4 la $a0, str1 syscall li $v0, 1 add $a0, $zero, $t1 syscall .end .text 코드를 하나하나 살펴보면 main: addi $t0, $zero, 0 # i = 0 addi..

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..

Addressing mode에는 여러가지가 존재하는데 MIPS에는 어떤 addressing mode가 있는지 살펴봅시다. MIPS에 addressing mode는 아래와 같이 있습니다. ① Immediate addressing ② Register addressing ③ Base addressing ④ PC-Relative addressing ⑤ Pseudo-direct addressing ① Immediate addressing op rs rt imm 16 Ex) addi, andi, slti ② Register addressing op rs rt rd shamt function ✓ rs, rt, rd가 모두 register를 가리키고 있습니다. Ex) add, mult, and, slt, sll ③ B..