REF SP 1102 Fin

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

1. [12%] 假設以下程式 load 到 2000x 的位址,問 (a) BB (b) CC (c) EE 的記憶體位址在哪?

(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

7. [5%] 以下兩段敘述最大的不同處何在?What are the differences between the two segments?


a) LDT AA b) IF (&AA NE 0)
COMP #0 &BB SET 3
JEQ SKIP ENDIF
LDA #3
STA BB
SKIP …
8. [8%] 寫出以下 macro processor 處理後產生的程式。Write down the OUTPUT of the macro
processor.
PG3 START 0
RDB MACRO &IN=01, &BUF=, &OUT=F5
$BG TD =X'&IN'
IF (&OUT NE '')
JEQ $BG
WD =X'&OUT'
ELSE
LDA &BUF
WD =X'OUT'
ENDIF
STX &BUF->2
MEND
RDB BUF=TT
RDB IN=33, OUT=
TT RESW 1
END
9. [10%] 以下任務是在 two-pass 之 assembler 或 linking loader 的 pass 1 或 pass 2 完成的?
答案請寫 AP1, AP2, LL1, LL2 (分別表示 Assembler Pass 1/2, Linking Loader pass 1/2)
For the following task, is it accomplished in pass 1 or pass 2, of a two-pass assembler or a two-pass
linking loader? Write AP1, AP2, LL1, LL2 to represent Assembler Pass 1, 2, and Linking Loader pass
1, 2, respectively)
(a) 指定 control sections 的真實位址 “assign actual addresses to control sections”
(b) 產生像 WORD 或 BYTE 敘述的初始值 “generate values defined in data initialization
statements such as WORD and BYTE”
(c) 修正 object code 的 relocatable 部分 “modify relocatable portion of the object code”
(d) 指定程式中標籤符號 (symbol as label) 的相對位址(relative address) ”assign relative address
for the symbol as label in an assembly program”
(e) 處理 EQU assembler directive “process assembler directive EQU ”
10. [12%] 請修正錯誤的敘述: Correct the wrong statements:
(a) 呼叫 subroutine 的執行速度一般比呼叫 macro 快。 The execution speed of calling subroutine
is faster than that of invoking macro
(b) macro 比 subroutine 就是較易讀、執行會快、但 program size 較大。 Compare macro and
subroutine, macro is easy to read, faster speed, but the program size is bigger
(c) bootstrap loader 是一個 absolute loader。 Bootstrap loaderis an absolute loader
(d) boostrap loader 通常存放在 ROM。 Boostrap loaderis usually stored in ROM.
(e) bootstrap loader 通常從固定的位置(設備) load user program 。Bootstrap loader usually load
user program from a fixed location (device).
(f) address binding 可以在 complie time 或 assemble time 完成。Address binding can be done at
complie time or assemble time.
(g) linkage editor 產生的 object code 未來將以 relative loader 載入。The object code generated by
a linkage editor will be loaded by a relative loader.
(h) linking loader 跟 linkage editor 都會解決所有的 external references 。Both linking loader and
linkage editor will solve all external references.
(i) linkage editor 可產生一個連結完成的 object code,並載入記憶體中供編輯 。Linkage editor
will complete all linking, generate object code, and load it to memory for editing.
(j) dynamic linking 會在 loading time 做 address binding 。Dynamic linking performs address
binding on loading time.
(k) load_and_call 某個系統服務時,會由 OS load 此服務到 memory 後執行並返回原程式。Whe
we Load_and_call some system service, OS will load the service to memory, execute, and return to
the calling program.

You might also like