Try   HackMD

System Programming

NTNU 系統程式

Back to Note Overview
Back to System Programming
tags: SystemProgramming 110-1 CSIE 選修 NTNU

Ch.01 Background

1.1 Introduction

  • Definition
    • 由支持計算機操作的各種程式組成

1.2 System Software and Machine Architecture

1.3 The Simplified Instructional Computer (SIC)

  • Simplified Instructional Computer(SIC)
    • Comes in two versions
      • The Standard model
      • An XE version(extra equipments, extra expensive)
    • The two versions has been designed to be upward compatible

1.3.1 SIC Machine Architecture

  • Memory
    • consists of 8-bits bytes
    • word: 3 consecutive bytes(24 bits)
    • total: 215 bytes
  • Registers
    • 5 registers
      • 24 bits length (each)
        Mnemonic Number Special use
        A 0 Accumulator
        X 1 Index register
        L 2 Linkage register
        PC 8 Program counter
        SW 9 Status word
  • Data Formats
    • Integers are stored as 24-bit binary number
    • 2’s complement representation for negative values
    • Characters are stored using 8-bit ASCII codes(at right most bits)
    • No floating-point hardware on the standard version of SIC
  • Instruction Formats
    • Standard version of SIC
    • 24 bits
      opcode x address
      8 1 15
    The flag bit
    x
    is used to indicate indexed-addressing mode
  • Buses
    • Data Bus: 24/8 bits
    • Address Bus: 15 bits
  • Addressing Modes
    • There are two addressing modes available, indicated by x bit in the instruction
      Mode Indication Target Address calculation
      Direct x=0 TA=address
      Indexed x=1 TA=address=(
      X
      )
    (
    X
    )
    : the contents if register
    X

1.3.2 SIC/XE Machine Architecture

  • Memory
    • Maximum memory available on a SIC/XE system is 1 megabyte(
      220
      bytes)
  • Instruction format
    • Format 1(1 bytes)
      op
      8
      • Ex.
        Mneminic Format Opcode Effect
        FIX 1 C4 A <- (F)[convert to integer]
    • Format 2(2 bytes)
      op r1 r2
      8 4 4

    Format 1 & 2 are instructions that do not reference memory at all.

    • Format 3(3 bytes)

      op n i x b p e disp
      6 1 1 1 1 1 1 12
    • Format 4(4 bytes)

      op n i x b p e address
      6 1 1 1 1 1 1 20
    • Addressing mode for format 3

      Mode Indication Target address calculation Notes
      Base relative b=1, p=0 TA=(B)+disp
      (
      0disp4095
      )
      Program-counter relative b=0, p=1 TA=(PC)+disp
      (
      2048disp2047
      )
      指令跟指令的間隔通常小於
      212
  • Registers
    • Additional registers are provided by SIC/XE
      Mnemonic Number Special Use
      B 3 Base register
      S 4 General working register
      T 5 General working register
      F 6 Floating point accumulator(48 bits)
  • 48-bit floating-point data type (他說不重要)
  • Instruction Format
    • 15 bits in SIC
    • 20 bits in SIC/XE

About n, i, x, b, p, e !

  • Target address

    n, i: how to use the target address(TA)

    n i
    1 1 Direct(Simple) addressing
    1 0 Indirect addressing (尋寶遊戲)
    0 1 Immediate addressing (no memory access)
    0 0 相容 SIC
  • e

    e Format
    0 format 3
    1 format 4
  • About TA 計算

    Mode Indication Target address calculation Notes
    Base relative mode b=1, p=0 TA=(B)+disp+(X)
    (
    0disp4095
    )
    Program-counter relative mode b=0, p=1 TA=(PC)+disp+(X)
    (
    2048disp2047
    )
    指令跟指令的間隔通常小於
    212

SIC Programming Examples

LDA ZERO STA INDEX

x = a + b * c
y = x * a

LDA b MUL c ADD a STA x LDA x MUL a STA y

1 4 Traditional (CISC) Machines

1.5 RISC Machines