[컴구 완전정복] 2. Instructions & Assembly Language

은서·2025년 12월 31일

CS 완전정복

목록 보기
2/5

📘 강의자료 2 요약

Instructions & Assembly Language

이 강의는 Instruction Set Architecture (ISA)와 Assembly language를 중심으로,
프로그램이 실제로 instruction 단위에서 어떻게 표현되고 실행되는지를 설명한다.
특히 instruction의 종류와 역할을 구분해 이해하는 것이 핵심이다.

1. Assembly Language와 Instruction Level

Assembly language는 machine language를 사람이 읽을 수 있도록 표현한 low-level language이다.

  • 각 assembly instruction은 특정 machine instruction에 직접 대응된다

  • CPU가 수행하는 연산, 데이터 이동, 제어 흐름이 그대로 드러난다

  • high-level language 코드가 실제로 어떤 instruction sequence로 변환되는지 확인할 수 있다

이를 통해 프로그램 실행을 instruction level에서 이해할 수 있다.

2. Instruction Set Architecture (ISA)

Instruction Set Architecture (ISA)는 software와 hardware 사이의 interface이다.

ISA는 다음 요소들을 정의한다.

  • instruction의 종류와 의미

  • instruction format

  • register set

  • addressing mode

  • memory access 방식

프로그램은 ISA 위에서 실행되며,
CPU는 내부 구현과 관계없이 ISA 규칙을 만족하면 동일한 프로그램을 실행할 수 있다.

3. Register-based Execution Model

Instruction execution은 register-based로 이루어진다.

  • arithmetic and logical instruction은 register를 operand로 사용한다

  • intermediate result는 register에 저장된다

  • memory는 직접 연산 대상이 되지 않는다

이 구조는 instruction execution을 단순화하고,
효율적인 hardware 설계를 가능하게 한다.

4. Load / Store Architecture

강의자료에서 사용하는 기본 메모리 모델은 load/store architecture이다.

  • memory 접근은 load instruction과 store instruction으로만 수행된다

  • 나머지 instruction은 register 간 연산만 수행한다

  • memory address는 register + offset 형태로 계산된다

이 방식은 computation과 memory access를 명확히 분리한다.

5. Instruction Categories

강의자료에서는 instruction을 기능에 따라 여러 범주로 구분한다.

(1) Arithmetic Instructions

  • add, sub, mul, div 등

  • register에 저장된 값을 대상으로 산술 연산을 수행한다

  • 연산 결과는 register에 저장된다

(2) Logical Instructions

  • and, or, xor, not 등

  • bit-level logical operation을 수행한다

  • 조건 판단 및 마스킹(masking)에 사용된다

(3) Data Transfer Instructions

  • load, store, move 등

  • memory와 register 사이의 데이터 이동을 담당한다

  • load/store architecture의 핵심 구성 요소이다

(4) Control Flow Instructions

  • branch, jump, call, return 등

  • program counter(PC)를 변경하여 실행 흐름을 제어한다

  • 조건 분기와 반복 구조를 구현한다

(5) Comparison Instructions

  • compare, set-on-condition 계열 instruction

  • 두 operand를 비교하여 condition flag 또는 결과 값을 생성한다

  • branch instruction과 함께 사용되어 제어 흐름을 결정한다

6. Addressing Modes

Instruction은 operand를 지정하기 위해 addressing mode를 사용한다.

대표적인 addressing mode는 다음과 같다.

  • register addressing

  • immediate addressing

  • base + offset addressing

addressing mode는 instruction의 표현력과 실행 효율에 직접적인 영향을 준다.

7. High-level Language와 Instruction Mapping

하나의 high-level language statement는
여러 개의 assembly instruction으로 변환될 수 있다.

이를 통해 다음을 이해할 수 있다.

  • program execution은 instruction sequence로 구성된다

  • instruction count와 instruction type 분포가 성능에 영향을 준다

  • compiler는 high-level code를 instruction 형태로 재구성한다

정리

강의자료 2는 다음 내용을 다룬다.

  • Assembly language는 instruction-level execution을 이해하기 위한 도구이다

  • ISA는 instruction, register, memory 사용 규칙을 정의한다

  • Execution은 register 중심이며, memory access는 load/store로 제한된다

  • Instruction은 연산, 데이터 이동, 제어 흐름 등으로 구분된다

  • High-level program은 instruction sequence로 실현된다

profile
개발자 대학생🌱

0개의 댓글