slide1 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
系統程式 PowerPoint Presentation
Download Presentation
系統程式

Loading in 2 Seconds...

play fullscreen
1 / 77

系統程式 - PowerPoint PPT Presentation


  • 201 Views
  • Uploaded on

系統程式. Introduction. Related Courses. Operating System. Computer Programming. Compiler. System Programming. Introduction to Computer Science. SW. HW. Introduction to Digital System. Data structure. Algorithm. Computer Architecture and Organization. An Overview. System software?

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

系統程式


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
    Presentation Transcript
    1. 系統程式 Introduction

    2. Related Courses Operating System Computer Programming Compiler System Programming Introduction to Computer Science SW HW Introduction to Digital System Data structure Algorithm Computer Architecture and Organization

    3. An Overview • System software? • System software vs. application software: System software are usually related to the architecture of the machine on which they are to run. • Some aspects of system software do not directly depend on its host machine. • Simplified Instructional Computer (SIC)

    4. Applications System Software Systems Programming H/W

    5. sample.exe output Example: Programming sample.c Compiler Loader, Linker & Runtime System

    6. Computers

    7. Mother Board Source: Charles S. Parker, Understanding Computers Today & Tomorrow, Dryden, 1998

    8. CPU Source: Charles S. Parker, Understanding Computers Today & Tomorrow, Dryden, 1998

    9. Turing Machine • Tape • Head • Table • State Register

    10. The von Neumann architecture

    11. SIC Machine Architecture • Memory • 8-bit bytes • A word consists of three bytes and is addressed by the lowest numbered byte. • A total of 32,768 (2^15) bytes in memory • Registers • Five 24-bit special-purpose registers • A (accumulator), X (index), L (linkage), PC (program counter), SW (status word) IP: instruction pointer

    12. SIC (2) • Data Formats • 24-bit integers (no floating-point numbers) • negative values are represented by 2’s complement • 8-bit ASCII for characters • Instruction Formats 8 1 15 opcode x address

    13. SIC (3) • Addressing Modes • Direct Mode: x=0; TA=address • Indexed Mode: x=1; TA=address+(X) • Instruction Set • Load and store registers • Integer arithmetic • Value comparison • Branching int a[10] for (int i=0; i<10; i++) a[i] = i; if ((a>b) && (x<y)) c=a+b; else c=20+y-x;

    14. 存取指令:LDA Memory CPU A暫存器

    15. 存取指令:STA Memory CPU A暫存器

    16. 資料複製:LDA & STA Memory CPU A暫存器 C1=D1 LDA D1 STA C1

    17. 算術運算:ADD、SUB、MUL、DIV Memory CPU A暫存器 G1=R1+B1 LDA R1 ADD B1 STA G1

    18. LDA (LoaD into the register A) addr=0300 TA=0300 addr=0300 (X)=0100 TA=addr+(X)=0400 SIC Machine Instructions • Examples: • 000000000000001100000000 • 000000001000001100000000 (X)=0100 103000 0300 103333 0400

    19. 1 s 11 36 exponent fraction SIC/XE Machine Architecture • Memory: 1 MB • Register: 4 new registers: B (base), S (general), T (general), F (floating-point accumulator) • Float-point • 48bits Data Format: n =

    20. 8 Discuss WHY 6 bits are sufficient. op 4 4 r2 r1 op 6 12 op x e disp i p n b 20 n p x i b e op address SIC/XE Instruction Formats • More complex instruction formats are required to meet the need to address 1MB. • SIC/XE has four instruction formats:

    21. SIC/XE Machine Instructions • Please refer to Figure 1.1 on page 11 • How does a SIC/XE processor • differentiate format 1, 2, 3, and 4 instructions? • differentiate format 3 and 4 instructions? • know when to compute target address using based relative addressing, program-counter relative address, or neither? • determine how to find actual operands with immediate, direct, indirect modes?

    22. Encoding Format Information OPCODE 0X 1X 2X 3X 4X 5X 6X 7X FORMAT 3/4 3/4 3/4 3/4 3/4 3/4 3/4 3/4 OPCODE 8X 9X AX BX CX DX EX FX FORMAT 3/4 2 2 2 1 3/4 3/4 1

    23. Decoding SIC/XE instructions • Suppose that you are given a machine instruction in the hexadecimal format. You decode the instruction with the following steps. • Determine the format of the instruction • (Rewrite the instruction in its binary format) • If it is a format 1 or 2 instruction… • If it is a format 3 or 4 instruction…

    24. Deciding SIC/XE Instruction Formats • Format 1: if first byte is CX or FX • Format 2: if first byte is 9X, AX, or BX • Format 3 or Format 4: all else • If n=i=0: a SIC instruction, get two more bytes • SIC/XE instructions all else • Decode the next byte and check the e bit • If e=0: Format 3 • If e=1: Format 4

    25. Decoding Format 1/2 Instruction • Format 1 • Find the opcode in Appendix A • Format 2 • Find the opcode in Appendix A • Translate register numbers back to corresponding register names • Tables on pages 5 and 7

    26. Decoding Format 3/4 Instructions • Steps: • Fill the rightmost two bits of the opcode with 0s • Find the opcode in Appendix A • If format 3 instruction, add 8 zeros (if binary format) or 2 zeros (if hexadecimal format) to the left of disp • Calculate target address according to bits x, b, and p • Determine the addressing mode according to bits n and i • Find the actual operand • Carry out the operation

    27. 解讀SIC/XE機器語言指令 找出Target Address

    28. TA = (PC) + disp Figure 1.1 TA = (PC) + disp = 3000+600=3600

    29. TA = (X)+(B) + disp Figure 1.1 TA = (X)+(B) + disp=90+6000+300=6390

    30. TA = (PC) + disp Figure 1.1 TA = (PC) + disp = 3000+30=3030

    31. TA = disp Figure 1.1 TA = disp = 30

    32. TA = disp Figure 1.1 TA = disp = 0C303

    33. Figure 1.1(Cont’d) The fifth example: 003600 0000 0000 0011 0110 0000 0000 According to the third paragraph on page 10, the b, p, and e bits merge with disp because n=i=0. Discussion: When would a SIC/XE assembler set n=i=0 and n=i=1?

    34. n=i=0 標記一個SIC指令 所以TA等於3600 Figure 1.1

    35. 解讀SIC/XE機器語言指令 找出實際運算對象

    36. TA是運算資料的位址 TA = (PC) + disp Figure 1.1 TA = (PC) + disp = 3000+600=3600

    37. TA是運算資料的位址 TA = (X)+(B) + disp Figure 1.1 TA = (X)+(B) + disp=90+6000+300=6390

    38. TA是運算資料的位址的位址 TA = (PC) + disp Figure 1.1 TA = (PC) + disp = 3000+30=3030

    39. TA本身就是運算資料 TA = disp Figure 1.1 TA = disp = 30

    40. SIC指令只要看x是否為1 n=i=0 標記一個SIC指令 所以TA等於3600 Figure 1.1

    41. TA是運算資料的位址 TA = disp Figure 1.1 TA = disp = 0C303

    42. SIC/XE機器語言指令的解讀 • 實際上,機器語言的解讀是非常機械化的過程 • 附錄A(第三版課本的第499頁上面)有更多的解讀機制 • 除了提供解讀更多機制之外,附錄A(第三版課本的第499頁上面)的表格,還揭露了SIC/XE CPU的設計有更多的限制。有一些看似可以的addressing mode並沒有出現在表格中。這一些是來自於硬體線路的設計的限制。對於SIC/XE來說,當然是假想的限制。

    43. 6 12 op x e disp i p n b SIC/XE (1) • e=1: format 4; e=0: format 3 • b=1, p=0: base relative TA=(B)+disp • b=0, p=1: pc relative TA=(PC)+disp (Negative values are in 2’s complement notation.) 20 op n i x p e address b n: indirect i: immediate x: index b: base p: program counter e: extended

    44. 6 12 op x e disp i p n b 20 n p x i b e op address SIC/XE (2) • b=0,p=0: disp is used as the TA. For a Format 4 instruction, b and p are normally set to 0. (simple addressing) • i=1,n=0: immediate addressing • i=0,n=1: indirect addressing (Data addressed by TA is used as the address of the real operand.) n: indirect i: immediate x: index b: base p: program counter e: extended

    45. 6 12 op x e disp i p n b 20 n p x i b e op address SIC/XE (3) • i=n=0 or i=n=1: respectively, direct and simple addressing (TA is the location of the operand.) n: indirect i: immediate x: index b: base p: program counter e: extended

    46. SIC/XE (4) • Summary of addressing modes n i x b p e 0 Format 3 1 Format 4 1 0 0 Format 3, base relative 0 1 0 Format 3, pc relative 0 0 0/1 Format 3/4, disp is TA, direct 0 1 immediate (TA: operand) 1 0 indirect (TA: address of address) simple (TA: address of operand) 1 1 1 index

    47. ?????? ALPHA 000005 FIVE 5A CHARZ ?? C1 Figure 1.2 A register of SIC LDA FIVE STA ALPHA LDCH CHARZ STCH C1 ……… ALPHA RESW 1 FIVE WORD 5 CHARZ BYTE C’Z’ C1 RESB 1

    48. A = ALPHA A = ALPHA+INCR 000001 ONE ?????? ALPHA ?????? BETA ?????? GAMMA ?????? DELTA ?????? INCR Figure 1.3 A = ALPHA+INCR-1 A register of SIC LDA ALPHA ADD INCR SUB ONE STA BETA ……… ONE WORD 1 ……… ALPHA RESW 1 BETA RESW 1 GAMMA RESW 1 DELTA RESW 1 INCR RESW 1

    49. X(X)+1: (X):ELEVEN STATUS WORD, CONDITION CODE X Figure 1.4 A register of SIC STR2 STR1 ? T X register of SIC ? E ? S LDX ZERO MOVECH LDCH STR1,X STCH STR2,X TIX ELEVEN JLT MOVECH ……… STR1 BYTE C’TEST STRING’ STR2 RESB 11 ……… ZERO WORD 0 ELEVEN WORD 11 ? T ? ? S ? T ? R ? I ? N ? G ZERO 000000 00000B ELEVEN

    50. SIC Programming Examples • Figure 1.2 on page 13 • Figure 1.3 on page 15 • Figure 1.4 on page 16 • Figure 1.5 on page 17 • Figure 1.6 on page 19 • Figure 1.7 on page 20