Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 6 Programming the basic computer

Similar presentations


Presentation on theme: "Chapter 6 Programming the basic computer"— Presentation transcript:

1 Chapter 6 Programming the basic computer
충남대학교 컴퓨터전공 이 철 훈

2 Tab. 6-1 Computer instructions
Chapter 6 Introduction Basic computer의 instruction set Tab Computer instructions Computer System Architecture 1

3 Chapter 6 Machine Language Program : a list of instructions or statements for directing the computer to perform a required data-processing task Programming language types (Tab. 6-2, 3, 4, 5) 1. Binary code : machine language 2. Octal or hexadecimal code : equivalent translation of binary code 3. Symbolic code : assembly language 4. High-level language Computer System Architecture 1

4 Assembly Language Assembly language program의 각 line은 3가지 field로 구성된다.
Chapter 6 Assembly Language Assembly language program의 각 line은 3가지 field로 구성된다. 1. label field : empty or symbolic address 2. Instruction field : machine instruction or pseudoinstruction 3. Comment field : empty or comment Symbolic address 3자까지의 alphanumerical 문자로 구성되며, 첫 자는 반드시 letter이어야 한다. Comma로 끝난다. Computer System Architecture 1

5 Assembly Language Instruction field Chapter 6
1. Memory-Reference Instruction (MRI) 2. Register-Reference or I/O Instruction (non-MRI) 3. Pseudoinstruction with or without operand MRI : 2 or 3 symbolic separated by space ∗ 1st : three-letter symbol defining an MRI opcode ∗ 2nd : symbolic address ∗ 3rd : I or empty non-MRI : does not have address part ※ Instruction field에 사용된 symbolic address는 level field에 반드시 있어야 한다. Computer System Architecture 1

6 Tab. 6-2 Definition of Pseudoinstructions
Chapter 6 Assembly Language Pseudoinstruction : machine instruction이 아니고, assembler에게 정보를 주기 위한 instruction이다 Comments : 설명 목적으로 사용되며 반드시 slash로 시작된다. Tab Definition of Pseudoinstructions Computer System Architecture 1

7 Assembly Language Chapter 6 Computer System Architecture 1
Tab Assembly language program to subtract two numbers Tab Listing of translated program of Tab. 6-8 Tab Address symbol table Computer System Architecture 1

8 Tab. 6-11 Computer representation of the code line
Chapter 6 The Assembler Representation of symbolic program in memory PL3, LDA SUB I 1st Pass : generates address symbol table Location counter (LC ) : memory location assigned to instruction or operand presently being processed ∗ ORG pseudoinstruction에 의해 초기화된다 Tab Computer representation of the code line Computer System Architecture 1

9 The Assembler Chapter 6 Computer System Architecture 1
Fig Flowchart for first pass of assembler Tab Address symbol table for program in Tab. 6-8 Computer System Architecture 1

10 Chapter 6 The Assembler 2nd pass : machine instructions are translated by means of table lookup procedures 1. Pseudoinstruction table 2. MRI table 3. non-MRI table 4. Address symbol table ⇒ 모든 symbol은 이들 table 중 하나에 존재해야 한다. Error Diagnostics : assembler는 symbolic program에 있는 모든 가능한 error를 검출하여, error message를 출력해야 한다. MRI나 non-MRI table에 없는 잘못된 machine code symbol label에 없는 symbolic address, 등등 Computer System Architecture 1

11 Fig. 6-2 Flowchart for second pass of assembler
Chapter 6 Fig Flowchart for second pass of assembler Computer System Architecture 1

12 Tab. 6-13 Compiled symbolic program to add 100 number
Chapter 6 Program Loops Program loop : a sequence of instruction that are executed many times, each time with a different set of data (ex. Fortran Do statement) Computer System Architecture 1 Tab Compiled symbolic program to add 100 number

13 Programming Arithmetic and Logic Operations
Chapter 6 Programming Arithmetic and Logic Operations Hardware 구현 : 하나의 machine instruction으로 구현된 operation Software 구현 : 여러 개의 instruction으로 구현되는 operation Multiplication Program (Fig. 6-3) Computer System Architecture 1

14 Programming Arithmetic and Logic Operations
Chapter 6 Programming Arithmetic and Logic Operations Tab Program to multiply two positive numbers Computer System Architecture 1

15 Programming Arithmetic and Logic Operations
Chapter 6 Programming Arithmetic and Logic Operations Logic Operations OR : x + y = (x’y’)’ → DeMorgan’s theorem Shift Operations logical shift operations arithmetic shift operations Computer System Architecture 1

16 Tab. 6-16 Program to demonstrate the use of subroutine
Chapter 6 Subroutines Subroutines : a set of common instruction that can be used many times Tab Program to demonstrate the use of subroutine Computer System Architecture 1

17 Tab. 6-19 Program to input and output one character
Chapter 6 I/O Programming Tab Program to input and output one character Computer System Architecture 1

18 I/O Programming Program interrupt Chapter 6
Programmed I/O 방식에서의 CPU가 I/O device의 상태를 항상 체크해야 하므로 성능면에서 상당히 낭비가 많다. 이를 해결하기 위해서 I/O device가 CPU에게 interrupt를 걸어 I/O를 요청하게 한다 (interrupt 방식) Interrupt 처리 순서 1. Save contents of processor registers 2. Check with flag is set 3. Service the device whose flag is set 4. Restore contents of processor registers 5. Turn the interrupt facility on 6. Return to the running program Computer System Architecture 1

19 Tab. 6-23 Program to service interrupt
Chapter 6 I/O Programming Tab Program to service interrupt Computer System Architecture 1


Download ppt "Chapter 6 Programming the basic computer"

Similar presentations


Ads by Google