REF SP 1102 Fin
REF SP 1102 Fin
REF SP 1102 Fin
(d)
程式總長度多少? Load the following program to 2000x, what are the memory address for (a) BB (b)
CC (c) EE? (d) what’s the total program length?
Line Source statement
10 PG1 START 0
15 AA LDB #DELTA
20 BB SUBR A, X
25 USE CDATA
30 CC RESB 16
35 USE
40 DD +LDB #100
45 USE CBLKS
50 DELTA RESB 4096
55 EE RESB 2048
60 USE
65 LDA =C’123’
70 LTORG
80 END
2. [8 %]以下 SIC 程式片段採 12-bit 的 bit mask,寫出所有 T-record(s)的開始位置、長度與 bit-
mak. 例如: T 000010 1A FFC。Write all T-records, show only starting address, length, and bit-mask,
using 12-bit mask for the following SIC program. For example, T 000010 1A FFC.
Loc Statement Object code
1000 TIX AA 2C100C
1003 LDX BB 041011
1006 RSUB 4C0000
1009 COMP CC 281017
100C AA BYTE X'1122' 1122
100E BYTE C'112' 313132
1011 BB WORD 4096 001000
1014 STX GG 101019
1017 CC BYTE X'33' 33
1018 GG BYTE C'GG' 4747
101A LDX BB 041011
101D RSUB 4C0000
3. [4%, 3%] C macro 定義如下: (a)請寫出將 FCU(AV(3-4,4+6)) expand 的敘述及(b)其執行結果
#define AV(x,y) x+y*2
#define FCU(EXP) printf("EXP is "#EXP" =%d ",EXP)
The C macro definitions as above, (a) write down the statements after expanding FCU(AV(3-4,4+6))
(b) what is the execution result?
4. [6%, 3%, 8%, 6%] 參考下圖(僅列出相關部分), (a) 補上 REF2、REF4、REF5 右邊部分
的 object code (b) REF1 到 REF7 共有幾張相關的 modification records? (c) 補上 REF5、
REF6、REF7 相關的 modification records 內容 (d) 若連續 load 順序為 PGA、PGB、PGC,
PGA 之 load address 為 2000 x,畫出其 load map (註:load map 參考欄位:control section,
symbol name, address, length.)Program segment as follows, (a) fill the blanks for the object codes
for REF2, REF4, and REF5 (b) in total, how many modifiction records for REF1 through REF7? (c)
show modification records for REF5, REF6, and REF7 (d) if we load (continuously) PGA, PGB, and
then PGC, and PGA is loaded at 2000 x, show the load map. (FYI: load map columns are control
section, symbol name, address, and length.)
0000 PGB START 0
EXTDEF LISTB,ENDB
EXTREF LISTA,ENDA,LISTC,ENDC
…
0046 REF1 +LDA LISTA 03100000
004A REF2 LDT LISTB+4 77______
004D REF3 +LDX #ENDA-LISTA 05100000
0050 RESB 32
0070 LISTB EQU *
0080 RESB 16
0080 ENDB EQU *
0080 REF4 WORD LISTB+1 ______
0083 REF5 WORD ENDC-LISTC-1 ______
0086 REF6 WORD ENDB-LISTB+9 ??????
0089 REF7 WORD ENDA-1 ______
END
<PGA.OBJ>
HPGA 000000 000070
DLISTA 000040 ENDA 000054
RLISTB ENDB LISTC ENDC
<PGC.OBJ>
HPGC 000000 000090
DLISTC 000030 ENDC 000042
RLISTA ENDA LISTB ENDB
<PGB.OBJ>
HPGB 000000 00008C
DLISTB 000070 ENDB 000080
RLISTA ENDA LISTC ENDC
..
5. [25%] 採用課本之 one-pass macro processor 處理以下程式,寫出
(a) 處理完第 40 行後之 NAMTAB、DEFTAB (暫時不必寫 OUTPUT)
(b) 處理完第 50 行的 OUTPUT 內容
(c) 處理第 60 行所增加的 OUTPUT 內容
(d) 處理完第 110 行後之 NAMTAB、DEFTAB (增加的部分)
(e) 處理完整個程式後的 OUTPUT 內容(寫出(c)之後增加的部分即可),以及 NAMTAB、
DEFTAB 增加或改變的部分。
Use the one-pass macro processor in textbook to process the following code, write down the
(a) contents of NAMTAB and DEFTAB (no OUTPUT here) after processing Line 40
(b) content of OUTPUT after processing Line 50
(c) increased content of OUTPUT after processing Line 60
(d) increased contents of NAMTAB and DEFTAB after processing Line 110
(e) increased content of OUTPUT (after problem (c)), increased contents of NAMTAB and
DEFTAB after whole program is processed.
10 PG2 START 0
20 M1 MACRO &X1
30 LDA #(200-&X1)
40 MEND
50 M1 P2
60 KO M1 20
70 M2 MACRO
80 IOU MACRO &X2
90 LDX #&X2
100 MEND
110 MEND
120 M2
130 IOU GOD
140 END
6. [5%] 以下兩個控制結構最大的不同處何在?What are the differences between the two structures?
a) LDT #5 b) &CTR SET 0
CLEAR X WHILE (&CTR LT 5)
LOOP SUB #1 SUB #1
TIXR T &CTR SET &CTR+1
JLT LOOP ENDW