Sie sind auf Seite 1von 23

System Programming Mid-Term

Date: October 28th, 2005


Time: 09:10-12:00
Q1(10%)
. . (B)=006000
. . (PC)=003000
 Consider the memory contents . . (X)=000090
shown in the following figure. 3030 003600
. .
What would be loaded to register A . .
with the instruction 022030 . .
3600 103000
(hexidecimal)?
. .
. .
. .
6390 00C303
. .
. .
. .
C303 003030
. .
. .
2
. .
Q1(10%)

Machine instruction Value loaded into


Hex Binary Target register A

op n i x b p e disp/address address

022030 000000 1 0 0 0 1 0 0000 0011 0000 3030 103000


. . (B)=006000
. . (PC)=003000
. . (X)=000090
3030 003600
. .
. .
. .
3600 103000
. .
. .
. . 3
Q2(40%)
 Why does Beck's "System Software" textbook
design a hypothetical computer SIC to present the
concepts in his book?
 illustrate the most commonly encountered hardware
features and concepts, while avoiding most of the
idiosyncrasies (p.4)
 easy to learn
 What are the maximum memory size of SIC and
SIC/XE, respectively?
 215/220 (p.5/p.7)
4
Q2(40%)
 How many addressing modes do SIC and SIC/XE
support, respectively?
 2/18 (p.6/p.499)
 How many instructions are there in the SIC/XE
instruction set?
 59 (p.496~498)
 How does SIC determine whether the result of a TD
instruction is successful?
 CC (condition code) = LT means the device is ready (p.7)

5
Q2(40%)
 What are the two general purpose registers in
SIC/XE?
 S,T (p.7)
 What is the size of F register?
 48bits (p.7)
 Why does the assembler need to handle the source
files in two passes?
 Pass1 assign addresses to all symbol
 Pass2 generate object code
 in order to solve the problem of forward reference
6
Q3(10%)
 Translate (by hand) the following assembly program to SIC
object code. (The output format will look like Figure 2.3, which
contains H record, T record, and E record.)
Loc Source statement Object code
STRCPY START 1000
FIRST 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
END FIRST
7
Q3(10%)
 Translate (by hand) the following assembly program to SIC
object code. (The output format will look like Figure 2.3, which
contains H record, T record, and E record.)
Loc Source statement Object code
1000 STRCPY START 1000
1000 FIRST LDX ZERO 041025
1003 MOVECH LDCH STR1,X 50900F
1006 STCH STR2,X 54901A
1009 TIX ELEVEN 2C1028
100C JLT MOVECH 381003
100F STR1 BYTE C’TEST STRING’ 544553…
101A STR2 RESB 11
1025 ZERO WORD 0 000000
1028 ELEVEN WORD 11 00000B
102B END FIRST
8
Q3(10%)

Machine instruction
Code Binary Hex
op x disp/address
LDCH STR1,X 01010000 1 001 0000 0000 1111 50900F
STCH STR2,X 01010100 1 001 0000 0001 1010 54901A

9
Q3(10%)
HSTRCPY00100000002B
^ ^ ^
T0010000F04102550900F54901A2C1028381003
^ ^ ^ ^ ^ ^ ^
T00100F0B5445535420535453494E47
^ ^ ^
T0010250600000000000B
^ ^ ^ ^
E001000
^

10
Q4(10%)
 Translate (by hand) the following assembly program
to SIC/XE object code.
Loc Source statement Object code
STRCP2 START 1000
FIRST LDT #11
LDX #0
MOVECH LDCH STR1,X
STCH STR2,X
TIXR T
JLT MOVECH
STR1 BYTE C'TEST STRING'
STR2 RESB 11
END FIRST
11
Q4(10%)
 Translate (by hand) the following assembly program
to SIC/XE object code.
Loc Source statement Object code
1000 STRCP2 START 1000
1000 FIRST LDT #11 75000B
1003 LDX #0 050000
1006 MOVECH LDCH STR1,X 53A008
1009 STCH STR2,X 57A010
100C TIXR T B850
100E JLT MOVECH 3B2FF5
1011 STR1 BYTE C'TEST STRING' 544553…
101C STR2 RESB 11
1027 END FIRST
12
Q4(10%)

Machine instruction
Code Binary Hex
op n i x bpe disp/address
LDCH STR1,X 0101 00 1 1 1 0 1 0 0000 0000 1000 53A008
STCH STR2,X 0101 01 1 1 1 0 1 0 0000 0001 0000 57A010
JLT MOVECH 0011 10 1 1 0 0 1 0 1111 1111 0101 3B2FF5

13
Q4(10%)
HSTRCP2001000000027
^ ^ ^
T0010001175000B05000053A00857A010B8503B2FF5
^ ^ ^ ^ ^ ^ ^ ^
T0010110B544553542053545249
^ ^ ^
E001000
^

14
Q5(10%)
 Disassemble (convert object code back into
assembly language) the following SIC program.

HSUM 00100000000E
T0010000E01000005000190102D000B3B2FF8
E001000

15
Q5(10%)

Loc Source statement Object code


1000 SUM START #1000
1000 FIRST LDA #0 010000
1003 LDX #1 050001
1006 LOOP ADDR #X,A 9010
1008 TIX #11 2D000B
100B JLT #LOOP 3B2FF8
100E END #FIRST

16
Q5(10%)

Machine instruction
Hex Binary Code
op n i x bpe disp/address
3B2FF8 0011 10 1 1 0 0 1 0 1111 1111 1000 JLT LOOP

17
Q6(10%)
 Simulate (by hand) the execution of the above program and let
the breakpoint be 00100E. What would be the value of register
A and register X when (PC) = 00100E?

Iteration 1 2 3 4 5 6 7 8 9 10 11
Register
A 0 1 3 6 10 15 21 27 36 45 55
X 1 2 3 4 5 6 7 8 9 10 11

 1+2+3+……+9+10=55
 A=37, X=B

18
Q7(10%)
 Simulate (by hand) the execution of the object code
below. Let the breakpoint be 001011. What is the
value of register A when (PC) = 001011?

HGAUSS 001000000017
T0010000C01000169200B1B4003232008
T00100C0B6F40009C40000002000064
E001000

19
Q7(10%)
Loc Source statement Object code
1000 GAUSS START #1000
1000 FIRST LDA #1 010001
1003 LDB #TWO 69200B
BASE #TWO
1006 ADD #K100 1B4003
1009 MUL #K100 232008
100C LDS #TWO 6F4000
100F DIVR #S,A 9C40
1011 TWO WORD #2 000002
1014 K100 WORD #100 000064
1017 END #FIRST

20
Q7(10%)

Machine instruction
Hex Binary Code
op n i x bpe disp/address
69200B 0110 10 0 1 0 0 1 0 0000 0000 1011 LDB #TWO
1B4003 0001 10 1 1 0 1 0 0 0000 0000 0011 ADD #K100
232008 0010 00 1 1 0 0 1 0 0000 0000 1000 MUL #K100
6F4000 0110 11 1 1 0 1 0 0 0000 0000 0000 LDS #TWO

21
Q7(10%)

Loc 1000 1003 1006 1009 100C 100F 1011


Register
A F 1 1 101 10100 10100 5050
B F F 2 2 2 2 2
S F F F F F 2 2

 [(1+100)*100]/2=5050
 A=13BA

22
Homework

 The code can work well  greater than 7


 If I need to correct it  less then 5
 Second chance  23:59 on Nov. 4th (tonight)
 Subject of email: [SP HW1v2] ########
 Email to me: s94321517@ncnu.edu.tw

23

Das könnte Ihnen auch gefallen