系統程式. 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?
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.Content is provided to you AS IS for your information and personal use only.Download presentation by click this link.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.During download, if you can't get a presentation, the file might be deleted by the publisher.
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? • 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)
Applications System Software Systems Programming H/W
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
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
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;
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
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 =
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:
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?
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
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…
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
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
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
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?
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
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
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
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
?????? 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
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
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
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