作者XX9 ( 佛曰: ....)
看板FCUProblems
标题[考古] 系统程式/黄志铭/92下期末考
时间Fri Jan 16 20:39:56 2009
※ [本文转录自 FCU_Talk 看板]
作者: kilonbia (专题~"~) 看板: FCU_Talk
标题: [考题] [资讯系-系统程式][黄志铭][92下期末考]
时间: Sun Jul 8 20:12:07 2007
[系统程式][黄志铭][期末考]
[壹]、What is the most important differece between a macro and a subroutine?
How should a programmer decide whether to use a macro or a subroutine to
accomplish a given logical function? 10%
[贰]、Drow a state diagram for a finite automation to recognize the following
tokens: 20%
(a) Signed integer(e.g. +123 or 6789 or -15):This integer may begin
with a sign (+ or -) or not; however they may not begin whit digit 0
(except for the integer that consists of a single 0)
(b) Real constant(e.g. -0.38 or 123.50):This real constant may begin
with a sign(+ or -) or not, and consists of a string of digits that
contains a decimal point. There must be at least one digit before
the decimal point.
[参]、Consider the following grammer:
<assign> ::= id := <term>;
<exp> ::= id * <exp> | id * <term>
<term> ::= id + <term> | (<exp>) | id
Assume that the scanner will report token type id when it sees a valid
Pascal identifier. Which of the following strings is a valid sentence
(i.e., <assign>)in the language generated by this grammar? 10%
(1) ALBERT := B + C;
(2) D := B * C;
(3) X := B + (C * D + E);
(4) A := B + (C * D);
(5) P := B + (C * D) + E;
[肆]、In APL all expressions are evaluated from right to left with no
precedence associated with any of the operators. Parentheses may be used
to change this default precedence. In the following "toy" version,
suppose that + and * are the only legal operators. Thus, A ← 3 * 3 + 4
would put the result of 3*7 into A. A ← (3 * 3) + 4 would ass 3*3 to 4
and put the result into A. Please give a BNF grammer for sucj statements,
providing for default right-to-left precedence and parentheses. 20%
[伍]、Apply and expand the following two macro invocation statements to
following macro definition: 20%
(1) RDBUFF F1,BUFFER,LENGTH,(04,12)
(2) LABEL RDBUFF F1,BUFFER,LENGTH,00
Macro definition:
25 RDBUFF MACRO &INDEV,&BUFADR,&RECLTH,&EOR
27 &EORCT SET %NITEMS(&EOR)
30 CLEAR X
35 CLEAR A
45 +LDT #4096
50 $LOOP TD =X'&INDEV'
55 JEQ $LOOP
60 RD =X'&INDEV'
63 &CTR SET 1
64 WHILE (&CTR LE &EORCT)
65 COMP =X'0000&EOR[&CTR]'
70 JEQ $EXIT
71 &CTR SET &CTR+1
73 ENDW
75 STCH &BUFADR,X
80 TIXR T
85 JLT $LOOP
90 $EXIT STX &RECLTH
100 MEND
[陆]、Suppose that the following macro definitions appeared at the beginning
of a SIC/XE program. 20%
(1) Show the contents of NAMTAB and DEFTAB jast after this code is
scanned by the macro processor. (Pointer values are given as line
number into DEFTAB)
(2) Now suppose that right after these definitions, the macro processor
scans a line that says : MACROS
Show the contents of NAMTAB and DEFTAB now.
1 MACROS MACOR
2 RDBUFF MACOR &INDEV,&BUFADR,&RECLTH
3 LDS &BUFADR
4 MEND
5 WRBUFF MACRO &OUTDEV,&BUFADR,&RECLTH
6 LDS &BUFADR
7 MEND
8 MEND
9 MACROX MACOR
10 RDBUFF MACOR &INDEV,&BUFADR,&RECLTH
11 LDT &BUFADR
12 MEND
13 WRBUFF MACRO &OUTDEV,&BUFADR,&RECLTH
14 LDT &BUFADR
15 MEND
16 MEND
--
男人就该原谅女人的谎言~
by 香吉士
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 123.240.180.106
1F:推 XX9:疑 这是op吗 07/08 20:23
2F:推 kilonbia:NO~ 一个是92年 一个是95年XDDD 考试范围不一样^^" 07/08 20:28
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.132.214.27