Skip to content

Instantly share code, notes, and snippets.

@heejongahn
Created October 17, 2015 08:28
Show Gist options
  • Save heejongahn/00d68a40415613893ad0 to your computer and use it in GitHub Desktop.
Save heejongahn/00d68a40415613893ad0 to your computer and use it in GitHub Desktop.
2015 Fall 아키텍쳐 정리
@heejongahn
Copy link
Author

Instruction Set Architecture III

RISC vs CISC

  • RISC 장점 : 간단한 구현, 공간 및 전력 절약, 파이프라이닝 특화
  • CISC 장점 : 코드 밀집도, 호환성

RISC의 특징:

  • hardwired control
  • load-store machine
  • few addressing modes
  • fixed-size instruction
  • rely on compiler optimization

대표적 CISC인 x86: variable length encoding... 실질적으로는 microengine을 이용해
microoperation들로 쪼개서 사용


오해

강력한 인스트럭션 -> 고성능?

인스트럭션 수는 적겠지만 구현이 어렵다. 또한 컴파일러가 머리 터진다. 아마 clock
cycle time도 늘어나야 할듯?

어셈코드로 짜면 고성능?

컴파일러가 너보다 똑똑할걸...

backward compatibility를 위해선 인스트럭션 셋이 고정되어야 한다

추가시키는건 괜찮아!


Compilation

source code -> tokens -> abstract syntax tree

Forward Reference

  • arithmetic / logical / shift 등은 인스트럭션 내에 필요한 정보 다 있음
  • branch는 pc-relative
  • 라벨들의 위치를 알기 위해서는 어셈블리 코드를 두 번 읽어야 한다. 플젝 해봤지?
  • jump는 절대주소 필요로 함. 링킹 마친 후에 할 수 있음.

Symbol Table

  • 다른 파일에서 사용될 수 있는 "item"들에 대한 정보 저장
  • label for function call
  • data

Relocation Table

  • 지금은 주소를 알 수 없는 "item"들에 대한 정보 저장
  • j / jal 레이블
  • static section의 데이터

링커

  • input: object code files, information tables
  • output: 실행가능 코드

여러 오브젝트 파일을 하나의 실행가능 코드로 엮어준다.

이 때

relocated text1 | relocated tex2 | relocated data1 | relocated data2

가 최종 포맷이 된다.

스텝 바이 스텝

  1. 각 오브젝트 파일에서 text segment 뽑아내서 합침
  2. 각 오브젝트 파일에서 data segment 뽑아내서 합친 뒤에 text 뒤에 붙임
  3. relocation table 보면서 각 항목들에 해당하는걸 절대주소로 채움

이 때

  • text segment는 0x400000으로 가정
  • 링커는 각 데이터, 텍스트 섹션의 길이를 알고 있음
  • 절대주소 계산 알아서 잘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment