Upload
lucky-luke
View
233
Download
0
Embed Size (px)
Citation preview
8/6/2019 1999_ExamPM With My Answers
1/93
1
Fall, 1999
CLASS Information Technology Engineer Examination - Afternoon
Select questions to answer as described in the following chart:
Question Nos. Q1,Q2 Q3 to Q6 Q7 to Q10 Q11 to Q14 Q15 to Q17
Question Selection Compulsory Select 2 of4 Select 1 of4 Select 1 of4 Select 1 of3
Examination Time 13:00 ~ 15:30 150 minutes
Notes:
1. Use an HBpencil.Ifyouneed tochange an answer, erase yourprevious answercompletely andneatly. Wipe
away anyeraserfragments.2. Markyouranswersin accordancewiththeinstructions below. Yourtestwill not begradedifyoufail tocomplywiththeinstructions. Donotmarkorwriteonthe answersheetoutsideofthe
prescribedplaces.(1)Examinee Number
Writeyourexamineenumber inthespaceprovided, andmark the appropriatespace beloweachdigit.
(2)Date of Birth
Writeyourdateofbirth (innumbers)exactly asitisprintedonyourexamticket, andmarktheappropriatespace beloweachdigit.
(3)Question Selection
Markthe questionsthatyouselectto answerasfollows: [SYMBOL](4)Answers
Markyouranswerasshowninthefollowing Howto MarkYourAnswerssample question.
[SampleQuestion] Selectthecorrect answertoinsertinthe fromthechoicesprovided.
The Fall Information Technology EngineerExaminationisheldin
Answergroup: A. October B. November C. December
Since the correct answer is "A" (October), mark your answer sheet as
follows:
a [B.] [C.]
3. Assembler specifications are provided as a reference at the end of this booklet. Theinformationprovidedonpage 69 and beyond, however, isonlyintendedforusewithQ17.
a
Do not open the exam book until instructed to do so.
Inquiries about the exam questions will not be
Faint
Right Wrong
C
COBOL
Fortran
Assembler
8/6/2019 1999_ExamPM With My Answers
2/93
2
8/6/2019 1999_ExamPM With My Answers
3/93
3
Q1. Examine the flow chart that follows and read the explanation below before answering the
sub-question.
[ExplanationofFlow Chart]
(1) Thisflowchartinsertsthecharacterstringthatisstoredin Array B in a specifiedpositionin
thecharacterstringstoredin Array A.
(2) ThesizeofArray A isstoredin AMAX, the lengthofthecharacterstringisstoredin AX, and
theindividual characters arestoredin A[1], A[2], ..., A[AX].
(3) The lengthofthecharacterstringto beinsertedisstoredin BX, andtheindividual characters
arestoredin B[1], B[2], ..., B[BX].(4) Thepositionwherethecharacterstringisto beinsertedisstoredin PX (1PXAMAX).
(5) IfPX isgreaterthan AX+1, a spaceisinserted at A[AX+1] ~ A[PX1].
(6) Anytextthatoverflowsfrom Array A as a resultoftheinsertionisdiscarded.
(7) Theoperationofthe MIN functionthatisusedinthisflowchartis asfollows:
MIN(X,Y): Returns X when X
8/6/2019 1999_ExamPM With My Answers
4/93
4
[Flow Chart]
St
art
Moveprocessing
Moveprocessing
Spaceinsertionprocessing
Space
End
Characterstringinsertionprocessing
Spaceinsertionprocessing
Note:The specification of the loop
conditionsis asfollows:variable name: initial value,step, endvalue
Note
(Note)
Characterstringinsertionprocessing
8/6/2019 1999_ExamPM With My Answers
5/93
5
Sub-question: Selectthecorrect answersto
insertinthe intheflowchartfromthechoicesprovided.
Answergroupfora:
A. AMAXBX B. AMAXBX+1 C. AMAXBX1
D. AMAXPX E. AMAXPX+1 F. AMAXPX1
Answergroupforb:
A. AX+BX B. AX+BX+1 C. AX+BX1
D. PX+BX E. PX+BX+1 F. PX+BX1
Answergroupforc:
A. B[X+PX] B. B[X+PX+1] C. B[X+PX1]D. B[XPX] E. B[XPX+1] F. B[XPX1]
8/6/2019 1999_ExamPM With My Answers
6/93
6
Ans: p n a- A, b-A, c-E. u bi yu cu chn xu B vo trong xu A vi cc thng s sau:
+ di mng A l AX, di ln nht mng A l AMAX, di mng B l BX, v tr cn
t vo l PX (1 cc phn t mng A khng b nh hng
+ Trng hp PX > AX + 1 -> Thm vo cc phn t trng t AX + 1 n PX 1
+ Trng hp PX < AX + 1 -> Cc phn t ca mng A t PX n AX cn dch chuyn i BX v
tr, Do , ta xt theo chiu ngc li, vi AX + BX > AMAX th dch chuyn cc phn t t
PX n AMAX BX ln BX n v, cn khng th dch chuyn cc phn t t PX n AX ->
xt phn t Y = MIN(AMAX-BX, AX). (p n a-A)
\ Chn cc phn t mng B vo
+ Trng hp AX + BX AMAX, cc phn t ca B ch c chn cho ht AMAX -> xt phn
t Y = MIN(AX + BX, AMAX) (p n b-A)
Phn t 1 ca mng B c chn v tr A[PX], phn t 2 ca mng B c chn v tr A[PX + 1]
-> mi quan h ca phn t B[j] vi A[X] l X = j + PX -1 hay j = X PX + 1 (p n c-E)
Q2. Examine the flow chart that follows and read the explanation below before answering thesub-questions.
[ExplanationofFlow Chart]
Thisflowchartusesthe arraysshownin Fig. 1 and Fig. 2 tocalculatepassengerfaresfor
travel overa givendistance. Fractionsofa kilometertraveled areroundeduptothenextinteger.
The arraysuffixesstartfrom "1." Theelementsin Array D givedistances, theelementsin Array
P areusedinthefarecalculation.
8/6/2019 1999_ExamPM With My Answers
7/93
7
[Flow Chart]
Fig.1 Array D Fig.2 Array P
L: Upperlimitonsuffixd: Inputdistance (unit: km)f: Calculatedfare (unit: yen)
Start
Errorprocessing
End
8/6/2019 1999_ExamPM With My Answers
8/93
8
Sub-question 1. Whatisthefarefora passengerwhotravels 35km? Selectthecorrect answer
fromthechoicesprovided.
Answergroup:
A. 650 B. 700 C. 750
D. 850 E. 1,450
Sub-question 2. Change Array P (Fig. 3) and the flow chart so that the fare is calculated by
adding a fixed additional fareforeachincrementofadditional distancetraveled, asshowninthe
table below. (Donotchange Array D.)
Table. Relationship between Increment of
Distance and Additional Fare
Incrementofdistance(km) Additional fare (yen)
Fig. 3 Array P
8/6/2019 1999_ExamPM With My Answers
9/93
9
Selectthecorrect answerstoinsertinthe intheflowchartfromthechoicesprovided.
[Flow Chart after Changes]
Answergroupfora:
A. 0 p L
2 pi
0 pf
B. 0 p L
2 pi
P(i)pf
C. 5 p L
1 pi
0 pf
D. 5 p L
2 pi
0 pf
E. 5 p L
1 pi
P(i)pf
Answergroupforb:
A. D(i) f B. P(i) f
C. f+ D(i) f D. f+ P(i) f
E. f+ D(i 1)P(i) f
Ans: Sub1 C, Sub2- a-C, b-D . Thut ton u tin tnh s tin tng ng vi khong cch c
th cho vi D(i) l qung ng tng ng, v P(i) l s tin cn tr cho mi km bn D(i).
Vi Sub1 th ta c d = 35km ng vi khong t D(2) -> D(3). S tin phi tr = P[1] + P[2]*(D[2] D[1]) + P[3] * (d D[2]) = 150 + 30 * 10 + 20 * 15 = 150 + 300 + 300 = 750.
Thut ton th 2 th s tin tng ng c ng theo cc phn khong cch khc nhau. N
s so snh tng ng xem d nm trong khong no (D[i -1]->D[i]) v f=tng P[j] vi j = 1 ti
i. Khi to ban u, L = 5, i = 1 v f = 0 (p n a-C). Sau f = P[i] + f v vi mi ln lp th
Start
End
Errorprocessing
8/6/2019 1999_ExamPM With My Answers
10/93
10
f s tng ln P[i]. (p n b-D)
Q3. Carefullyreadtheexplanationofthefollowingprogram, theexplanationofthe
pseudo-languagedescriptionformat, andtheprogram, andthen answerSub-questions 1 and 2.
[ExplanationofProgram]
Thisprogram merges twoproductfiles intooneproductfile. Theprogram merges file A
(Fig. 1)withfile B (Fig. 2)tocreate file C (Fig. 3). Assume thatthere arenorecordsinfile Aandfile B thatsharethesameproductcode.
Select two questions fromQuestion 3 toQuestion 6, and mark which questions you have
selectedonyour answersheet. Ifyouselectthreeormore questions, onlythefirsttwo questions
Productcode ProductnameRecord 1 100 ToothbrushRecord 2 200 Rinse
Fig.1 file A
Productcode ProductnameRecord 1 150 TowelRecord 2 250 CupRecord 3 350 Pen
Fig.2 file B
Productcode ProductnameRecord 1 100 ToothbrushRecord 2 150 TowelRecord 3 200 RinseRecord 4 250 CupRecord 5 350 Pen
Fig. 3 file C
8/6/2019 1999_ExamPM With My Answers
11/93
11
[ExplanationofArtificial Language Description Format]
Format Explanation
Declaration block
This area iswhereprocedures, variables, names, types, etc.,
aredeclared.
Declaresnames, types, etc., ofprocedures, variables, etc.
Processing block
This area iswhereprocessingisperformed.
variablenexpression Assignsthevalueofanexpressionto a variable.
procedurename (argument, ) Calls a procedure.
conditional expression
Yes processing 1
No processing 2
Executesprocessing 1 whentheconditionistrue.
Executesprocessing 2 whentheconditionisfalse.
loopconditional expression
processing
Repeatedly executes theprocessing while the condition is
true.
Indicates a blockofprocessing.
=, Comparators that are used in conditional expressions and
loopconditional expressions.
{ } Comments.
8/6/2019 1999_ExamPM With My Answers
12/93
12
[Program] Program name: File Merge Integers:stsA, stsB, endf Files:fileA, fileB, fileC {sequential accessfiles}
Records:rcdA, rcdB Procedures: Recordinput (file, record, status )
{Thisprocedurereadsonerecordfromthefilespecified by"file", andstoresthedata inthe area specified by"record" . When a recordisinput, a "0" isstoredinthevariable
specified by"status"; whennorecordisinput, a "1"isstoredinthevariablespecifiedby "status".}
Procedure: Recordoutput (file, record){Thisprocedurestoresthecontentsofthe area specified by"record"inthefilespecified
by"file".}
Recordinput (fileA, rcdA, stsA) Recordinput (fileB, rcdB, stsB )
endf 0 endf = 0 {Repeatwhileendf = 0.}
stsA = 1 Yes stsB = 1
Yes endf 1No Recordoutput (fileC, rcdB)
Recordinput (fileB, rcdB, stsB )
No stsB =1 Yes Recordoutput (fileC, rcdA)
Recordinput (fileA, rcdA, stsA)No rcdAproductcode < rcdBproductcode
Yes Recordoutput (fileC, rcdA) Recordinput (fileA, rcdA, stsA)
No Recordoutput (fileC, rcdB)
Recordinput (fileB, rcdB, stsB )
Sub-question 1. Howmanytimeswill the "Yes"portionoftheprogram (indicated by " ") beexecuted? Selectthecorrect answerfromthechoicesprovided.
Answergroup
A. 1 B. 2 C. 3 D. 4 E. 5
Declarationblock
Proce
ssingblock
E
F
8/6/2019 1999_ExamPM With My Answers
13/93
13
Sub-question 2. Selectthecorrect answertoinsertinthe inthefollowingdescription
fromthechoicesprovided.
(1) Assumethattheconditional expressionindicated by "F" intheprogramwasincorrectly
asfollows.
rcdAproductcode > rcdBproductcode
Thecontentsoffile C wouldthen be a .
(2) Assumethat, intheoriginal program, thefileshownin Fig. 4 wasinput asfile A insteadof
thefileshownin Fig. 1. Thecontentsoffile C wouldthen be b .
Answergroup
A.Product
codeProduct
name100 Toothbrush150 Towel200 Rinse250 Cup350 Pen
Productcode Productname
200 Rinse100 Toothbrush
Fig. 4 file A
B.Product
codeProduct
name100 Toothbrush150 Towel200 Rinse350 Pen250 Cup
C.Product
codeProduct
name100 Toothbrush200 Rinse150 Towel350 Pen250 Cup
D.Product
codeProduct
name150 Towel100 Toothbrush200 Rinse350 Pen250 Cup
E.Product
codeProduct
name150 Towel200 Rinse100 Toothbrush250 Cup350 Pen
F.Product
codeProduct
name150 Towel250 Cup350 Pen100 Toothbrush200 Rinse
G.Product
codeProduct
name200 Rinse150 Towel250 Cup350 Pen100 Toothbrush
H.Product
codeProduct
name350 Pen250 Cup200 Rinse150 Towel100 Toothbrush
8/6/2019 1999_ExamPM With My Answers
14/93
14
Ans: Sub1 C, Sub2 a F, b E. bi yu cu vit gi m cho chng trnh ghp 2 file A,B
thnh 1 file C vi gi s khng c 2 record ging nhau v trng product code trn 2 file.
Theo thut ton trn, phn iu kin yes s c thc hin 3 ln
rcdA stsA rcdB stsB C
1 100 0 150 0 (100 < 150 -> doc A)
2 200 0 150 0 (200>150->doc B)
3 200 0 250 0 (200doc A)
4 xxx 1 250 0 (doc B)
5 xxx 1 350 0 (docB)
6 xxx 1 xxx 1 -> stop; endf = 1
Vy iu kin stsA = 1 s c thc hin 3 ln.(p n Sub1 C)
Nu iu kin l rcdA product code > rcdB product code th ta c file C s c ghi nh sau:
rcdA stsA rcdB stsB C
1 100 0 150 0 (100 < 150 -> doc B) (150)
2 100 0 250 0 (100 < 250->doc B) (250)
3 100 0 350 0 (100doc B) (350)
4 100 0 xxx 1 (doc A ) (100)
5 200 0 xxx 1 (doc A) (200)
6 xxx 1 xxx 1 -> stop; endf = 1
p n Sub2 a- F.
Vi iu kin thay i u vo, ta c file C s c ghi nh sau:rcdA stsA rcdB stsB C
1 200 0 150 0 (200 > 150 -> doc B) (150)
2 200 0 250 0 (200 < 250->doc A) (200)
3 100 0 250 0 (100doc A) ( 100)
4 xxx 1 250 0 (doc B ) (250)
5 xxx 1 350 1 (doc B) (350)
6 xxx 1 xxx 1 -> stop; endf = 1
p n Sub2-b-E
Q4. Carefullyreadthefollowingexplanationofdatabasecommitmentcontrol, andthen answerthesub-question.
In a centralizeddata base, consistencyofthedata ismaintainedthroughcommitmentcontrol,
whichdetermineswhethertoperform all ornoneoftheprocessing associatedwith a transaction.
8/6/2019 1999_ExamPM With My Answers
15/93
15
Thispreventspartial execution of theprocessing (Fig. 1). In the following diagram, m and n
represent data, m' and n' represent the respective values after being updated, andparentheses
indicatethattheupdatingofthedata valueshasnotyet beenfinalized.
In a distributeddata base, theprocessingfor one transactionfrom the mainsite (therequest
originator)updatesthedata bases atmultiplesites. Thisgivesriseto thefollowingproblem: If
commitmentprocessingisperformedforeachofthedata bases atsite A andsite B inresponseto a
commitmentrequestformthemainsite (in Fig. 2), buttheprocessingendsnormally atsite A and
ends abnormally atsite B, thedata atthetwositeswill no longerbein agreement as a resultofthe
updateprocessing.
TimeTransaction 1 Transaction 2
Data base
Fault
Update Commitment Update Rollback
Fig.1 Centralized Data Base Update
Mainsite
Update
Time
Site A
Fault
Commitment
Site B
Fig.2 Distributed Data Base Update 1
Rollbackafterrecoverin
8/6/2019 1999_ExamPM With My Answers
16/93
16
To addressthisproblem, consideran arrangementinwhicheachsitedoesnotfinalizetransaction
processingimmediately. Instead, eachsiteestablishes anintermediatestateinwhichcommitment
androllbackarestill bothpossible, andthenexecutesfinalizationprocessing later. (Fig. 3) Thisis
called "two-phasecommitmentcontrol."
Sub-question. Selectthecorrect answerstoinsertinthe in Figs. 2 and 3 fromthechoices
provided.
Answergroupfora:
A. n B. (n) C. n D. (n) E.n
Answergroupforb andc:
A. 200 B. 300 C. 400 D. 500 E. 600
F. 700 G. 800 H. 900
Mainsite
Update
Intermediate stateconfirmation
Commitment
Site BSite ATime
Rollback
Intermediatestateconfirmation
Update
Fault
"ok" and "no" in thisdiagram indicate thesuccess and failure,respectively, of anupdate.
Fig. 3 Distributed Data Base Update 2
8/6/2019 1999_ExamPM With My Answers
17/93
17
Ans: p n a-A, b-C, c-E. V phn a, ta thy khi xy ra li th DB s c rollback li gi tr
c trc khi xy ra li, a y l n (p n a-A). Cn phn b, th gi tr s l gi tr s ca
transaction trc = 400 (p n b-C). Tng t, gi tr khi rollback s l gi tr t1, v t1
y = t + 200 -> t = 600( p n c-E).
Q5. Carefullyreadthefollowingexplanationofparallel processingofaprogram, andthen answer
thesub-question.
Consideraprogramthatprocessesimagedata consistingof600 lines, with 800 dotsperline. This
programprocessestheimageinunitsoflines, withtheresultofprocessingforone linehavingno
effect on theprocessing of any of the other lines. The overall time needed to execute can be
reduced bydividingthetaskofprocessingeachofthese 600 mutuallyindependent lines among
multiplecomputers andprocessing the lines inparallel. System X is a singlecomputerwith aprocessorwith 200MFLOPS processingcapability, memory, anddiskdrive. System Y consistsof
fourcomputerswiththesameprocessingcapability assystem X, all runninginparallel. Asshown
in Fig. 1, eachofthefourcomputershasitsownprocessorandmemory, but all fourshare a single
diskdrive.
Sub-question.Selectthecorrect answertoinsertinthe inthefollowingdescriptionfrom
thechoicesprovided.
Theprogramconsistsofthreeparts: animagedata readingsection, theone-linecomputation
Disk Processor
Bus
Shareddisk
Processor
Parallel ComputerSystem Y
Processor
Processor
Processor
Mem r
Fig.1 System Configuration
System X
Memor
Memor
Mem r
8/6/2019 1999_ExamPM With My Answers
18/93
18
section, a resultoutputsection (Fig. 2).requires 40 mstoexecute.requires 120mstoexecute.
requires execution time equivalent to 400,000 floatingpoint operations. The computation
sectionneedsto beexecutedfor600 linesinordertoprocesstheimage. Runningtheprogramon
system X will require a mstoexecute.
Ifweexecutethesameprogramonsystem Y, sections andcannot beperformedinparallel,
sotheywill beperformed bycomputerNo. 1. Section, whichneedsto beexecuted 600 times,
can beprocessedinparallel sincetheprocessingforeachofthe 600 linesisindependentofall theother lines. Therefore, thisprocessingcan bedividedequally among thefourcomputers. The
timeneeded bycomputer1 toexchangedata withtheotherthreecomputers (thecommunications
time)is 150mstodistributethedata to all ofthecomputers, and 150mstocollecttheresultsfrom
all ofthecomputers. Runningtheprogramonsystem Y will require b mstoexecute.
It is possible that if the amount of arithmetic operations that need to be performed in
sectionissmall, thecommunicationstime becomes longon a comparative basis, sothatparallel
processing actually requires more time to execute. Converting the processing in
sectiontofloatingpointoperations, ifthenumberoffloatingpointoperationsisfewerthan
c operations, runningtheprogramonsystem Y will actuallytake longerthanrunningthe
programonsystem X.Answergroupfora and b:
A. 300 B. 340 C. 460 D. 610 E. 760
F.1,200 G. 1,320 H. 1,360
Answergroupforc:
Start
Imagedatareadingsection
Imageprocessing
One-linecomputationsection
Imageprocessing
Fig.2 Processing Procedure
End
Resultoutputsection
Repeat 600 times
(can beexecutedinparallel)
8/6/2019 1999_ExamPM With My Answers
19/93
19
A. 5 B. 10 C. 13 D. 30 E. 6,000
F.8,000
Ans: p n a-H, b-E, c-C. 1 giy thc hin c 200 triu lnh, thc hin 400000 lnh trongthi gian l 400000/ 200000000 = 4/2000 = 2ms. Thi gian thc hin h thng X s l 40 +
120 + 2*600 = 1200 + 160 = 1360 ms (p n a-H). Do h thng Y chy song song v cc dng
c phn b u trn cc my nn s lng dng mi my thc hin l 600/4 = 150 dng.
Nh vy thi gian thc hin in cc dng trn mi my l 150 * 2 = 300 ms. Thi gian thchin trn h thng X = thi gian thc hin cng vic 1 + thi gian thc hin cng vic 3 +
thi gian cng vic 2 trn mi my + thi gian phn phi v tp hp d liu = 40 + 120 + 300+ 150 + 150 = 760 ms (p n b-E). Thi gian tng ng vi s cu lnh ca phn 2 ca h
thng X l y * 600 (ms)+ 160 (ms), cn vi h thng Y l y * 150 + 460 (ms). Thi gian trn h
thng X nh hn thi gian trn h thng Y khi y * 600 + 460 > y * 150 + 160 -> 450 * y y < 2/3 (ms) -> s lnh thc hin = 400000 /2 * 2/3 = 400000/3 ~ 13 vn lnh (pn c-C)
Q6. Carefully read the following explanation of inventory management, and then answerSub-questions 1 and 2.
Theplant where Mr. Y works recently decided to revamp its inventory management systems,whichpreviouslydependedontheexperience andhunchesofthemanagerinchargeofinventory.Mr. Y has been askedforhisrecommendationsconcerningtherawmaterialsorderingsystem.
Sub-question 1. There are 100 differentrawmaterialsused attheplantwhere Mr. Y works. Mr.Y decided to select the most vital items and propose a review of inventorymanagement for those items. Afterstudying various documents, it became clearthatthe best approachwould betocloselymanage (asvital items)thosematerialsforwhich theplant's annual expenditures (unitcostof theraw material x amountconsumedyearly)werehigh, whileexpending littleoninventory managementforthose materials for which annual expenditures were low. After researching theannual expendituresforeachrawmaterial, Mr. Yproducedthefollowingtable.
No. Itemcode Unitcost Annual consumption Annual expenditure1 AA01 30 56,380 1,691,4002 AA07 200 1,500 300,0003 AC01 1,500 23,400 35,100,000
100 ZQ80 10 2,875 28,750Total annual expenditure 231,730,960
Next, inordertoselectfromthetable asvital itemsthosematerialsthat accountedforthe largestpercentageofannual expenditures, Mr. Y analyzedthedata accordingtothefollowingprocedure:
8/6/2019 1999_ExamPM With My Answers
20/93
20
Hesorted all ofthematerials by annual expenditure, startingfromthehighest. He determined the cumulative annual expenditure for the list, position byposition, starting
fromthetop. He drew a bar graph with the position of each material on the x axis, and the annual
expenditureonthey axis. Heplotted a graph, indicatingthecumulative annual expenditurefrompositiontoposition.
Fromthechoicesprovided, selectthecorrect answerforthenameofthistypeofchartorgraph.
Answergroup
A. Arrowdiagram B. Ganttchart C. Control chart
D. Paretodiagram E. Portfoliograph
8/6/2019 1999_ExamPM With My Answers
21/93
21
Sub-question 2. Typical inventory management systems include the "periodic reordering
system" andthe "fixed-orderquantitysystem." Inordertoconsiderwhichofthesesystemsmight
be best suited for the list of vital items he created in Sub-question 1, Mr. Y summarized the
characteristics of each system. From the choicesprovided, select the correct answers to be
insertedinthe inthedescription below.
Inordertoselect anorderingmethod, itisnecessarytoconsidernumerousfactors, including
theunitcostoftherawmaterials, the amountofconsumptionofrawmaterialsin a giventime, the
sizeoffluctuationsinconsumption andtheeasewithwhichsuchfluctuationscan beforecast, the
lengthoftheprocurementinterval (thetimefromwhen a material isordereduntil itis accepted
intoinventory), costs associatedwithordering (such asthetransportcosts and administrativecosts
incurredforoneorder), andthecostofmaintaininginventory.
Becausethe "periodicreorderingsystem" requiresdetermining a regularinterval fororderingbasedontherawmaterialprocurementtime, forecastingtheconsumptionoftherawmaterial over
theperiod following each regular interval for ordering, and then determining a on
the basisofthatinformation, it becomespossibletomanageinventoryveryclosely. Thismethod
carries littleriskofrunningoutofmaterial evenwhenthere are largefluctuationsinconsumption.
Thismethodiseffectiveifthere are largechangesindemandinthemarketforaproduct, resulting
infrequentchangestotheproductionplan. Thismethodis alsoeffectiveformanaginginventories
ofrawmaterialsthatcarry a highunitcost.
The "fixed-order quantity system" orders quantities (predetermined on the basis of the
procurement interval) of materials that have fallen to b . Compared to the "periodic
reorderingsystem," thismethodissimpler. However, thereis a dangerofrunningoutofa materialthatundergoes a largefluctuation inconsumption. This method issuitableformanagementof
materialswhenthereisproductdemand andtherawmaterialprocurementinterval arestable, and
whenitispossibleto accuratelyknowthecurrentinventory level at anytime.
Answergroup
A. thesafeinventory level B. 50% ofthesafeinventory level C. theorderingtime
D. theorderingpoint E. theordering quantity F. the averageinventory level
Ans: p n Sub1 D, Sub 2 a E, b D. Vic s dng biu dng tng tch ly ca cc
item c gi tr t cao n thp l s dng lc Parero (p n Sub1 D). Phn 2 hi v
h thng t hng nh k v h thng t hng s lng c nh. Cu a l E, s lng thng. Cn cu b l D, im t hng.
Selectone questionfromQuestion 7toQuestion 10, andmarkwhich questionyouhave
8/6/2019 1999_ExamPM With My Answers
22/93
22
selectedonyour answersheet.
Ifyouselecttwoormore questions, onlythefirst questionwill begraded.
Q7. Carefullyreadtheexplanationofthefollowing C program, andthen answerthesub-question.
[ExplanationofProgram]
This program orders and outputs in ascending order the array "Stu" in the structure
"STUDENT", using "Height" asthekey.
Theprogramcreates a binarytreethatindicatestheorderwithoutsortingthe arraydata. The
following arrayvariables aredefinedtorepresentthe binarytree.
Fig. 1 illustrates thecasewhere theelements are arranged in ascendingorder, withtheelement
numbers in thesequence 3, 1, 0, 5, 2, 4. Fig. 2 shows thecontentsof the arrays "Lower" and
"Upper". Thevalue "1" indicatesthatthereisnoelementconnectednext.
Initially, theelements areconnectedonthe "Upper" sideintheorderinwhichthey appeared
inthedefinitionofthestructure array "Stu", creatingthe binarytreeshownin Fig. 3.
Root
Fig.1 Example of the
Element
Element No. Lower Upper
0 1 21 3 1
2 5 4
3 1 1
4 1 1
5 1 1
Fig.2 Contents of Arrays
Representing
C
Name
Age
Height
Weight
8/6/2019 1999_ExamPM With My Answers
23/93
23
Next, theprogramcallstherecursivefunction "BinTreeSort " andsortstheelementsinthe
binarytree accordingtoheightin ascendingorder. Theparameteristheelementnumberofthe
root. Theprototypeforthefunction "BinTreeSort " is asfollows:
Lastly, theprogramcallstherecursivefunction "DisplayData" andoutputsthecontentsof
the structure array in ascending order according to height, following the binary tree. The
parameteristheelementnumberoftheroot. Theprototypeforthefunction "DisplayData" is
asfollows:
[Program]
Root
Fig. 3 Connection Status Prior to Sorting
Root
C
Name
Age
Height
Weight
AikawaTaro
Ito Shiro
Kato Goro
TanakaSaburo
Yamanaka Jiro
8/6/2019 1999_ExamPM With My Answers
24/93
24
Name Age Height Weight
8/6/2019 1999_ExamPM With My Answers
25/93
25
C
8/6/2019 1999_ExamPM With My Answers
26/93
26
Sub-question: Select thecorrect answer to insert inthe in theprogram from thechoices
provided.
Answergroup
A. 1 B. Data C.Lower[Data]
D. Lower[Root] E.Next F. Root
G. Upper[Data] H. Upper[Root]
Ans: p n a G; b H; c B; d D. T tng ca thut ton ny l xt tt c cc nt bn
phi nt ROOT, nu n ln hn nt ROOT th chn vo nt con bn phi nt ROOT, cnkhng th chn vo nt con bn tri nt ROOT. Sau khi sp xp ht, ta s xt quy cc nt
con ca n.
Q8. Carefully read the explanation of the following COBOL program, and then answer the
sub-question.
[ExplanationofProgram]
Thisprogramcreates a salesperformancefilefromsalesfilesinwhichthedepartmental sales
amountsgenerated byeachstore andeachdepartment arerecordedseparately. Theprogram
thenrankseachdepartment accordingtothesizeofitsdepartmental sales amounts.
(1) Theformatofeachrecordinthesalesfileisshown below.
Storecode Departmental sales amounts
Department A Department B Department C Department D Department E
5 digits 9 digits 9 digits 9 digits 9 digits 9 digits
Eachstorehasfivedepartments, A through E.
Assumethatthere arenorecordsthathaveduplicatestorecodeswithinthesalesfile.
Assumethatthedepartmental sales amountswill notexceedninedigits.
Assumethatthesalesfiledoesnotcontainmorethan 9,999 records.
(2) Theformatofeachrecordinthesalesperformancefileisshown below. Storecode
Department A Department B Department E
Departmentrank
Departmentalsales amount
Departmentrank
Departmentalsales amount
Departmentrank
Departmentalsales amount
5 digits 4 digits 9 digits 4 digits 9 digits 4 digits 9 digits
Thedepartmentrank (with "1" as thehighest) is assigned according to thesales amountof the
C
COBOL
8/6/2019 1999_ExamPM With My Answers
27/93
27
departmentcomparedtothesamedepartmentsintheotherstores.
Ifthere areseveral storeswiththesamedepartmental sales amount, theyeachgetthesamerank.
Afterthesamedepartmentrankhas been assigned, thenextrankisonegreaterthanthenumberof
storesthathave beenrankeduptothatpoint.
(3) A workfileisusedtodeterminethedepartmental sales amountrankofeachdepartment.
[Program]
8/6/2019 1999_ExamPM With My Answers
28/93
28
COBOL
8/6/2019 1999_ExamPM With My Answers
29/93
COBOL
8/6/2019 1999_ExamPM With My Answers
30/93
30
Sub-question: Selectthecorrect answertoinsertinthe intheprogramfromthechoices
provided.
Answergroupfora andd:A. BANGO-BAN B. BANGO-SOR C. BUMON-BAND. BUMON-SOR E. GAKU-BAN F. GAKU-SORG.TENPO-BAN H.TENPO-SOR
Answergroupforb:A.MOVE BANGO-REC TO SORT-RECB.MOVE GAKU-WRKTO GAKU-SORC.READSORT-FILED.RELEASESORT-RECE.RETURN SORT-FILE
F. WRITESORT-REC
Answergroupforc:A.MOVE BUMON-SORTO LCN B.MOVE LCN TO BUMON-SORC.MOVE X TO BANGO-BAN D.MOVE X TO YE.MOVE Y TO BANGO-BAN F. MOVE Y TO X
Answergroupfore:A.TENPO-SEI = TENPO-BAN B.TENPO-SEI NOT = TENPO-BANC.TENPO-SEI = TENPO-SOR D.TENPO-SEI NOT = TENPO-SORE.TENPO-SOR = TENPO-BAN F. TENPO-SOR NOT = TENPO-BAN
COBOL
8/6/2019 1999_ExamPM With My Answers
31/93
31
Q9. Carefully read the explanation of the following Fortran program, and then answer the
sub-question.
[ExplanationofProgram]
A problem with the handling of matrices in the field of computing is that the volume of
calculations andthe amountofmainmemoryusedincreaseswiththesizeofthematrix. Herewe
will considera methodforcompressing a bandmatrix, a typeofsparsematrix thatcontai ns a large
numberofzeroelements, forstorage byomittingzeroelements.
Thisprogramdeterminesthe bandwidthofthe bandmatrix, storesthe bandwidthdata foreach
line in an array, and thenoutputs the contentsof that array. Here, a "band matrix" is a square
matrix withnon-zeroelementsdistributedinthevicinityoftheoppositecorners, asshownin Fig.
1.
Matrix dimension
Fig.1 Sample Input Data
(1) A bandmatrix withnon-zeroelementsdistributedinthevicinityoftheoppositecornersisinputin
the array "wa". Theprogramdeems anyelementwith an absolutevaluegreaterthan 10 -6 as being
a non-zeroelement.
(2) Theprogramdeterminesthe bandwidthofthematrix.
Fortherownumbered "row":
Theprogram searches from the left edge to the "row1" column, and assigns the column
numberofthefirstnon-zeroelementthatitencountersto "kl".
Theprogram searches from theright edge to the "row+1" column, and assigns the column
numberofthefirstnon-zeroelementthatitencountersto "kr".
Theprogram assignsthe largerof"rowk1" and "krrow" as "length".
The bandwidthisderived bydoublingthe largest "length" value and addingonetotheresult,
usingthe "length" valuesderivedforeachrow asdescribed above. Forexample, inthethird
lineofthe bandmatrix shownin Fig. 1, row = 3, kl = 1, andkr= 5, sorowkl = 2 andkrrow
= 2. Inthecaseofthis bandmatrix, the largest "length" valueforall oftherowsis "2," sothe
bandwidthis "5."
(3) Theprogram then allocates an area for the array wb(number of rows, bandwidth) to store a
numberofelementsequal tothe bandwidth.
(4) Theprogramstores a numberofelementsequal tothe bandwidthin "wb", orderingthemsothat
thediagonal elementof"wa" will becomethecentercolumnof"wb". A "wb" elementissetto 0
(nought), ifnowa elementcorresponds.
Matrix
Fortran
8/6/2019 1999_ExamPM With My Answers
32/93
8/6/2019 1999_ExamPM With My Answers
33/93
33
Sub-question: Selectthecorrect answertoinsertinthe in theprogram from the choicesprovided.
Answergroupfora and b:A. krow .or. right==0
Answergroupforc:A. row B. row+maxC. row+wmax-1 D. row-wmaxE. row-wmax+1 F. row-wmax-1
Answergroupford:A. indexna B. indexnaC. index>1 .and. index1 .or. index1 .and. k1 .or. k
8/6/2019 1999_ExamPM With My Answers
34/93
34
Q10. Carefullyreadtheexplanationofthefollowing assembly lineprogram andtheprogramitself,
andthen answerthesub-question.
[ExplanationofProgram]
Thisprogram treats data stored in sixteen consecutive words as a 16 x 16-bit graphic. The
subprogramROTATErotatesthegraphic 90 degrees.
(1) Thestarting addressofthegraphicisstoredin GR1, whichispassedfromthemainprogram.
(2) Either"1" or"1" isstoredin GR3, whichispassedfromthemainprogram. When GR3 is "1," the
graphicisrotated 90 degreestotheright; when GR3 is "1," thegraphicisrotated 90 degreesto
the left.
(3) Theprogramstorestherotatedgraphicinthe area specified by GR2.
(4) Assumethatthe areasspecified by GR1 and GR2 donotoverlap.
(5) Fig. 1 shows anexampleoftheexecutionofthesubprogram ROTATE.
Fig.1 Execution Example of the Subprogram ROTATE
Original graphicOriginal graphic
Bit
When GR3 = 1
When GR3 = 1
Bit
Bit
Resultinggraphic
Resultinggraphic
Assembler
8/6/2019 1999_ExamPM With My Answers
35/93
35
(6) Whenrotatingthegraphictotheright by 90 degrees, asshownin Fig. 2, the bitstrin ginthefirst
wordintheoriginal graphicisshiftedinthedirectionindicated bythe arrowone bit at a time
tothe bitcolumn "a" (attherightedgeoftheresultinggraphic). Similarly, isthenshiftedto
"b," isshiftedto "c," etc. Whenrotatingthegraphictothe left by 90 degrees, asshownin Fig.
3, the bits areshiftedstartingfromthe lastword, whichisshiftedto bitcolumn "a," thenis
thenshiftedto "b," isshiftedto "c," etc.
Fig.2 Sequence of Processing WhenRotating to the Right
(7) When control returns to the mainprogram, the contents of the general-purpose registers GR1
through GR3 arereturnedtotheiroriginal states.
Assembler
Fig. 3 Sequence of Processing WhenRotating to the Left
8/6/2019 1999_ExamPM With My Answers
36/93
36
[Program]
Register save
Bit position initialization
Wordcounter
Word1 in original graphicp GR1
Word1 in resulting graphicp GR0
Sets bit in word1 of result
Bit counter
Bit check in original graphic
Clears bit that was set
Stores in resulting graphic
Next wo rd in resulting graphic p
GR0
Sets bit in word1 of result
Bit check in original graphic
Next word address in original
graphicp GR1
Bit position update
Address of resulting graphic p GR2
Registerrestore
Increment (+1 or 1)
Assembler
8/6/2019 1999_ExamPM With My Answers
37/93
37
Sub-question: Selectthecorrect answertoinsertinthe in theprogram from the choices
provided.
Answergroupfora andc:A.AND GR0,0,GR2 B.AND GR0,BITPOSC. EOR GR0,0,GR2 D. EOR GR0,BITPOSE. LEA GR0,0 F. LEA GR0,32768G. SLL GR0,1 H. SRL GR0,1
Answergroupforb andd:A. JMI LOOP1 B. JMI LOOP2C. JMP LOOP1 D. JMP LOOP2E. JNZ LOOP1 F. JPZ LOOP2G. JZE LOOP1 H. JZE LOOP2
Assembler
8/6/2019 1999_ExamPM With My Answers
38/93
38
Select one question fromQuestion 11 toQuestion 14, and mark which question you have
selectedonyouranswersheet. Ifyouselecttwoormore questions, onlythefirst q uestionwill be
graded.
Q11. Carefullyreadtheexplanationofthefollowing C program, andthen answerSub-questions 1
and 2.
[ExplanationofProgram]
Thefunction "wordwrap" outputs Englishtextsothat a wordisnotdividedinthemiddle attheend
ofa line.
(1) Theparametersforthefunction "wordwrap" are: "str[]", an arrayfortheinputstringinwhich
the English text isstored; and "max", the maximum number ofcharactersper output line (notincludingthe linefeedcharacter).
(2) Wordsintheinputstring aredelimited by a singlespace. There arenospaces atthe beginning and
endofthestring.
(3) Ifthemaximumnumberofcharactersperlineisgoingto beexceededinthemiddleofa word, that
wordisoutput atthe beginningofthenext line.
(4) Assuming "wx" asthemaximumword length and "sx" asthe lengthoftheinputstring, assume
thatthefollowingrelationshipistrue:
0 < wx < 16 < max < sx < 1024
Sampleinputstring:
Maximumnumberofcharactersper line: 30
Output:
((: spacecharacter)
C
8/6/2019 1999_ExamPM With My Answers
39/93
39
[Program](Linenumber)
/***Divides the character string into words ***/
output
C
8/6/2019 1999_ExamPM With My Answers
40/93
40
Sub-question 1. Select thecorrect answer to insert in the in the following description
fromthechoicesprovided.
Giventheinputcharacterstring andthemaximumnumberofcharactersper lineshown below,
line 21 isexecuted a times. Thevalueofthevariable "pos" whentheprogramendsis
b .
Inputcharacterstring:
Maximumnumberofcharactersper line:18
Answergroup
A. 5 B. 7 C. 8 D. 12 E. 13
F. 15 G. 16 H. 22 I. 27
Sub-question 2. Selectthecorrect answertoinsertinthe inthefollowingdescriptionfrom
thechoicesprovided.
Wewill nowchangetheprogramsothatitwill include any leadingspacesinthecharacter
string aspartofthefirstword (sothatspaces atthestartofthecharacterstring areoutput asis),
andsothatitwill outputonlyonespace betweenwordsevenifthere aremultiplespaces.
Thischangeis accomplished byinserting "E" immediately before line 12, and byinserting
"F" immediately before line 18.
Answergroup
A. Cnt++ B.cnt-- C.i D.i++ E.i--
F. i+1 H.i-1 I. idx++ J.idx--
Ans: p n Sub1 a H, b E Sub 2 c A, d-D, e-F. cnt ng vai tr m s k t trong 1 t
-> trong ton b chng trnh dng 21 c thc hin = s k t khc trng trong xu input
= 22 (p n Sub1- a-H). Bin pos y ng vai tr l ch s ca k t ang c c vo
C
8/6/2019 1999_ExamPM With My Answers
41/93
41
buffer output. D thy output ra s l:
Dng 1: AAAA_BBBBB_CCC
Dng 2: DDDD_EEE_FFF\0 (pos 1 = \0 -> pos l s k t trong dng cui cng khi kt thc
chng trnh = 13) (p n Sub1 b E)
Vi phn 2 th ta s cho cc du trng u vo xu u tin, y c-A, d-D. Khi kim tra ta s
loi b cc k t trng tip theo c th do e- F.
Q12. Carefully read the explanation of the following COBOL program, and then answer
Sub-questions 1 and 2.
[ExplanationofProgram]
Thisprogramoutputs a bargraphthatindicatesthenumberofstudents at a givenschool thathave
selectedeachoftheforeign languagesoffered.
(1) Thenumberofstudentsthathaveselectedeach languagecan beobtained bycalling a programnamed "KEISAN"; theresults arethenstoredinSENTAKU-T inthefollowingorder:
French (F), German (G), Chinese (C), Russian (R), Spanish (S)
(2) Theprintingformatforthe bargraphis asfollows:
The languages are listedonthe Y axis, andthenumberofstudentsisplottedonthe X axis.
Thenumberofstudentscanrangefrom 0 to 30; one asterisk"*" representsonestudent.
Thefollowingoutputsampleshowsthat 30 studentsselected French, 15 selected German, 20
selected Chinese, 0 selected Russian, and 5 selected Spanish.
Fig. Output Sample forNumber of Students Selecting Each Language
[Program]
C
OBOL
8/6/2019 1999_ExamPM With My Answers
42/93
42
8/6/2019 1999_ExamPM With My Answers
43/93
43
Now the school modifies theprogramso that the bar graph is oriented vertically instead of
horizontally. Thedata sectionischanged asshown below, andthethree alternatives a, b, andcshowninthetable areconsideredforlines 27 through 35 intheproceduresection.
COBO
L
8/6/2019 1999_ExamPM With My Answers
44/93
44
Table Changes to the Procedure Section (Substitutions for Lines 27 through 35)
8/6/2019 1999_ExamPM With My Answers
45/93
45
Sub-question 1. Howshouldthe "IF" statementenclosedinthe box inthetable bechangedso
thattheconditionwould be "whenthevalueis a multipleo f10"? Selectthecorrect answerfrom
thechoices below.
C
OBOL
Statements
8/6/2019 1999_ExamPM With My Answers
46/93
46
AnswergroupA. COMPUTE K = S/10
IF K = 0 THEN MOVESTO KOMOKU END-IF
B. COMPUTE K = S/10 IF S = K*10THEN MOVESTO KOMOKU END-IF
C. COMPUTE K = S/10 COMPUTE K = S/ K
IF K = 10 THEN MOVESTO KOMOKU END-IF
D. COMPUTE K = S/10 COMPUTE K = K*10
MOVE KTO KOMOKU
Sub-question 2. Whichgraphwill beprintedwhenthechangesmadein a, b, andc, respectively,
are incorporated into theprogram? Selectonegraphfor a, b, andcfrom thechoicesprovided.
Assumethatthestudentdata fromthesampleoutput (item (2)intheexplanationoftheprogram)
isused.
Answergroup
A A A. B.
C. D.
COBO
L
8/6/2019 1999_ExamPM With My Answers
47/93
47
8/6/2019 1999_ExamPM With My Answers
48/93
48
Q13. Carefully read the explanation of the following Fortran program, and then answer
Sub-questions 1 through 3.
[ExplanationofProgram]
A survey on food preferences was conducted. This program determines the correlation
coefficientforpreferences amongdifferentfoods andprintsouttheresults.
(1) Thenumberofrespondentsis between 2 and 100.
(2) Thesurvey asked therespondents toratehowmuch they likedninedifferentfoodson a
scalefrom 1 to 10.
(3) Table 1 showssamplesurveyresults. Thesurveyresultsfilecontainseachrespondents
numberandthescoretheygavetoeachoftheninefooditems.
Table 1 Survey Results
Respondent No. Food 1 Food 2 Food 3 Food 4 Food 5 Food 6 Food 7 Food 8 Food 9
001 5 3 7 6 8 2 7 2 5
002 10 3 7 10 10 3 6 4 6
003 7 3 1 7 4 2 7 9 2
(4) Theprogramcalculatesthecorrelationcoefficientforpreferences amongfooditems asdescribed
below.
Assumingthe averagescoreforfoods as Hs, thescoresthatrespondentn assignedtofood j and
foodkas Pnj and Pnk, andthenumberofrespondents as M, then Cjkiscalculated asfollows:
The correlation coefficient Rjk for food j and food k is calculated according to the following
formula. Assumethatthevalues Cjj and Ckk arenotzero.
(5) Sampleoutputresults areshown below.
Fortran
8/6/2019 1999_ExamPM With My Answers
49/93
49
[Program]
(Linenumber)
Fortran
8/6/2019 1999_ExamPM With My Answers
50/93
50
Sub-question 1. Whatwouldhappenifdata from 101 peoplewasgiventothisprogram? Select
thecorrect answerfromthechoices below.
Answergroup
A. Whendata for the 101st andsubsequentpeople is input, thedata thatwill bediscarded is
undefined. Therefore, itwill beunclearwhichrespondents'data wasusedtocalculatethe
correlationcoefficient.
B. The calculation of the correlation coefficient will include the data from the 101st and
subsequentrespondents.
C. Becausethedata fromthe 101st andsubsequentrespondentswill bestoredoutsidethe area
thatwas allocatedforthe array, theresultscannot beforecasted.
D. The correlation coefficient will be calculated on the basis the data from the last 100respondents.
E. The correlation coefficient will be calculated on the basis the data from the first 100
respondents.Fortran
8/6/2019 1999_ExamPM With My Answers
51/93
51
Sub-question 2. Selectthe answerthatwill produceresultsequivalentto lines 27 through 32 in
theprogramfromthechoicesprovided.
Answergroup
Fortran
8/6/2019 1999_ExamPM With My Answers
52/93
52
Sub-question 3. Assumethatthetwochangesdescribed below aremadetotheprogram. Select
B.
A.
C.
D.
8/6/2019 1999_ExamPM With My Answers
53/93
53
thecorrect answertoinsertin in Table 2 fromthechoicesprovided.
(1) Assumes the correlation coefficient between the same food items is 1.0 instead of
calculatingit.
(2) Usesthesymmetryoftheresultmatrix toskipcalculatingthecorrelationcoefficientfora
combinationoffoodsinwhichtheitems aresimplyreversedfrom anearlierpair, substituting
the appropriateresultinstead.
Table 2 Program Changes
Position Afterchange
Line 28 do k=l, j
Lines 32 to 36
Answergroup
FortranB.
A.
C.
D.
8/6/2019 1999_ExamPM With My Answers
54/93
54
Q14. Carefullyreadtheexplanationofthefollowing assembly languageprogram andtheprogram
itself, andthen answerSub-questions 1 and 2.
[ExplanationofProgram]
Thesubprogram ADDP acceptstwointegers a and b (Eu, bu0)in BCD notationfromthemain
program, andthencalculatesthesumofa and b in BCD notation.
(1) BCD notation expresses each digit of a decimal number as a four-digit binary number. For
example, thedecimal number5973 would beexpressedin BCD notation asfollows:
Thousandsdigit Hundredsdigit Tensdigit Onesdigit
5 9 7 3
q q q q
0101 1001 0111 0011
(2) a and b are bothfour-digit (16-bit)numbers. They arestoredin GR1 and GR2 respectively, andarepassedfromthemainprogram.
(3) AnexampleoftheexecutionofthesubprogramADDPisshown below.
Res ult
Fig. Sup-program ADDP Execution Example
(4) Whencontrol returnstothemainprogram, thecontentsofthegeneral-purposeregisters GR2 and
GR3 arereturnedtotheiroriginal states.
Assembler
8/6/2019 1999_ExamPM With My Answers
55/93
55
[Sub-program ADDP]
Extractfourbitsformintegera
Initialize results area
Extract four bits form integer a
Extract four bits from integer b
Four-bit addition
Resultu10?
Subtract 10 fromresult
Set carry
Store result of four-bit addition in bit position
Merge intermediate results
All digits completed?
Store intermediate result
Addcarry
Shift next four bits of integer to right
Shift next four bits of integer to right
Assembler
8/6/2019 1999_ExamPM With My Answers
56/93
56
Sub-question 1. Selectthecorrect answertoinsertinthe inthefollowingtextfromthe
choicesprovided.
IfthecontentsofGR1 and GR2passedfromthemain program are asfollows, then afterADDP
isexecutedthe bitstring a will besetin GR0 andthe bitstring b will besetin GR1 and
passed backtothemainprogram.
GR1 = 0101 0010 1001 1000
GR2 = 0100 1000 0101 0011
Answergroup
A. 0000 0000 0000 0000 B. 0000 0000 0000 0001
C. 0000 0001 0101 0001 D. 0100 1000 0101 0011
D. 0101 0010 1001 1000 E. 1001 1001 1001 1001
F. 1010 0001 0101 0001 G. 1111 1111 1111 1111
Sub-question 2. Using thesub-programADDP, a sub-programCALCwascreated toperform a
certainoperationontwointegersm andnexpressedin BCD notation (andwheremu0, nu 0).
(1)m andn arestoredin GR1 and GR2, respectively, and arepassedfromthemainprogram.
(2)Theoperationresultisstoredin GR1.
(3) Whencontrol returnstothemainprogram, thecontentsofthegeneral-purposeregisters GR2
and GR3 arereturnedtotheiroriginal states.
Thefollowingtableshowsthevaluesofm andnpassedfromthemainprogram, thevaluein GR1
thatisreturnedtothemain program, andthenumberoftimesthesub-programADDPwascalled.Notethat all valuesshowninthetable andinthe answergroup aregivenindecimal notation.
Selectthecorrect answertoinsertin inthetablefromthechoicesprovided.
Table Correspondence of Each Value
Valuepassedfromthemainprogram ValueofGR1 returned
fromthemainprogram
NumberoftimesADDP
iscalledm n
123 45 c d
51 3579 e f
Assem
bler
8/6/2019 1999_ExamPM With My Answers
57/93
57
[Sub-programCALC]
Answergroupforc ande
A. 0 B. 70 C. 78 D. 168
F. 737 G. 2529 H. 3528 I. 3579
J. 5535 K. 7158
Answergroupford andfA. 0 B. 1 C. 2 D. 3
F. 6 G. 9 H. 45 I. 51
J. 123 K. 3579
Register save
Initialize results
Loopcount
Overflow
Overflow
Restore register
Asse
mbl
er
8/6/2019 1999_ExamPM With My Answers
58/93
58
Selectone questionfromQuestion 15toQuestion 17, andmarkwhich questionyouhaveselected
onyour answersheet. Ifyouselecttwoormore questions, onlythefirst questionwill begraded.
Q15. Read thefollowingdescriptionconcerning internal design and then answer Sub-questions 1
through 3.
Intherelational data base logicdesignstage, a normalizeddata structureisthedata structure
thatdata analysis leadsto logically, butdoesnottakeintoconsiderationhowthedata basewill be
used bytheuserorapplicationprogram. Therefore, itisnecessarytore-examinenormalizeddata
structures in the construction of data bases that arepractical and efficient from a processing
standpoint byconsideringhowthedata basewill actually beused.
Forexample, ifa tableisintegrated, integrationprocessingisno longerneededwhensearching
for data, reducing the amount ofprocessing that must beperformed, but this is offset by an
increase in the processing that must be performed in order to maintain the consistency ofduplicateddata inthedata basewhenthedata isupdated. Whenre-examining a data structure, itis
sometimesnecessarytoconfirmwhetherthetableisoneinwhichsearchprocessingisfrequently
conductedornot andwhetherthetableisonethatisfrequentlyupdatedornot, andthentofocus
oneliminatingnormalizationinthosetablesinwhichsearch processingisfrequentlyconducted.
Company M isdeveloping anorderinputsystem andis attemptingtoimprovetheefficiencyof
orderinputwork. Company M hasotherworksystems, andhasdecidedtoutilizedata basetables
thatcan beshared. Thefollowingtables aretheresultofdata base logicdesignrelatingtoorder
inputwork.
[Resultofdata base logicdesign]
(1)Customer tableCustomercode Customername Address Telephone Statecode
(2)Order table
Ordernumber Customercode Orderdate Delivery Departmentcode
(3)Order details table
Ordernumber Productcode Orderquantity
(4)Product table
Productcode Productname Unitprice Closingdate
(5)Department table
Departmentcode Departmentname Numberofstaff
(6)Region code table
Regioncode Regionname
(7)State code table
Statecode Statename Regioncode
(8)Inventory table
8/6/2019 1999_ExamPM With My Answers
59/93
59
Productcode Inventory quantity
The following tables are used only by the order taking system: customer table, order table,
orderdetailstable, regioncodetable, andstatecodetable. Inordertakingwork, formanagement
purposesorders aredividedintonineregions, andtheseregions arefurtherdivided accordingto
theirstates.
Theproducttableisupdatedonceperweekbythesalessystem.
Thedepartmenttableisupdatedonceperyearbythepersonnel system.
Theinventorytableisupdatedfrequently bytheinventorymanagementsystem.
Inorderto betterunderstandtheprocessinginvolvedinordertaking andhoweachtableisused,
thecompanycreatedthefollowingtableshowingtherelationships betweenprocessing andeach
table.
Relationships between Processing and Each Table
Processingname
Processingtype
Frequencyof
processing
Tablename
Customer
Order
Orderdetails
Product
Department
Regioncode
Statecode
Inventory
Ordertaking Online 100times/
day
Ref App App Ref Ref Ref Ref Updt
Ordersearch Online 200times/
day
Ref Ref Ref Ref Ref Ref Ref _
Customersearch
Online 130times/
day
Ref Ref _ _ Ref Ref Ref _
Inventorysearch
Online 150times/
day
_ _ _ Ref _ _ _ Ref
Customerlistoutput
Batch 2times/
week
Ref _ _ _ _ Ref Ref _
Customertablemaintenance
Online 20times/
day
App,Updt,Del
_ _ _ _ Ref Ref _
Ref: Reference; App: Append; Updt: Update; Del: Delete
Sub-question 1. If the company wants to intentionally reduce normalization and integrate two
tablesintoonetableinordertoreduceintegrationprocessing, while alsokeepingmindtheneedto
minimizeincreasesinthe amountofdata, whichtwotables arethe bestcandidatesforintegration?
Select TWO answersfromthechoicesprovided.
8/6/2019 1999_ExamPM With My Answers
60/93
60
Productname QuantityU
Answergroup
A. Customertable B. Inventorytable C. Ordertable
D. Orderdetailstable E. Producttable F. Departmenttable
G. Regioncodetable H. Statecodetable
Sub-question 2. Order searchprocessing generates the mostprocessing requests in a day, and
demands thefastest response time. Fig. 1 shows theordersearch resultsdisplay screen. This
screenisdisplayedwhen anordernumberisinput.
Whichdata structureisthe bestcandidateforre-examinationinordertospeeduptheresponse
time? Selectthecorrect answerfromthechoicesprovided.
OrderSearch Results ScreenXx/xx/xxxx
OrderNo. Departmentname
Customername
Regionname Statename
Orderdate Delivery
Fig.1 Order Search Results Screen
8/6/2019 1999_ExamPM With My Answers
61/93
61
Ordernumber Dateoforder Delivery DepartmentnameU
Answergroup
A. Addthestatenametothedata itemsinthecustomertable.
B. Addthestatename andtheregionnametothedata itemsinthecustomertable.
C. Addthecustomernametothedata itemsintheordertable.
D. Addthecustomername andthedepartmentnametothedata itemsintheordertable.
E. Addtheproductnametothedata itemsintheorderdetail table.
F. Addtheproductname, unitprice, andclosingdatetothedata itemsintheorderdetail tabl e.
Sub-question 3. Selectthecorrect answertoinsertinthe inthefollowingtextfromthe
choicesprovided.
Fig. 2 shows the customer search results screen that was designed for customer search
processing. Thisscreenisdisplayedwhen a customercodeisinput.
Thisscreendisplaysthenumberofordersthatwerereceivedfromthatcustomer'sstateinthe
previousmonthinthefield "Previousmonth'sorders" andthecurrentnumberofcustomersinthecustomer'sstateinthefield "Currentnumberofcustomers."
CustomerSearch Results Screen
xx/xx/xxxx
Customercode Telephone
Customername
Address
Regionname Statename
Numberoforders
Previousmonth'sorders Currentnumberofcustomers
Fig.2 Customer Search Results Screen
The company seeks to speed up the response to online queries by studying methods for
calculatingdata itemsthatcan bederivedfromotherdata items.
8/6/2019 1999_ExamPM With My Answers
62/93
62
Thecompanystudiedthefollowingthreemethodsforcalculatingderivativedata items:
(1) Calculation atthetimeofreference
Derivativedata items arecalculated atthetimeofreference. Theresultsproduced bythese
calculations arenotstoredinthedata base.
(2) Calculation atthetimeofupdating
Derivativedata items arecalculatedwhenthedata itemsfromwhichthey arederived areupdated.
Theresultsproduced bythesecalculations arestoredinthedata base.
(3) Asynchronouscalculation
Derivativedata items arecalculated atsomepredeterminedtime, and arestoredin thedata base.
Evenifthedata itemsfromwhichthey arederived areupdated, thederivativedata items arenot
recalculated.
Thederivativedata item "Previousmonth'sorders" is a .Thederivativedata item "Currentnumberofcustomers" is b .
Answergroup
A. calculated atthetimeofupdating
B. calculated atthetimeofreference
C. calculated asynchronously
8/6/2019 1999_ExamPM With My Answers
63/93
63
Ans: p n Sub1 G, H, Sub2 B, Sub 3 a C, b - A . D thy cc bng Region code v State code
ch c dng tham chiu trong cc nghip v c s lng bn ghi c nh c lin quan
n nhau bi trng Region code. Chnh v vy, khi kt hp 2 bng , chng s khng lm
tng nhiu s lng data theo thi gian.(p n Sub 1 G,H). Phn 2, d thy phn ny n
tham chiu 6 bng theo th t sau:
+ Order (1)
+ Order details (1)
+ Customer (2)
+ Department (2)
+ Product (2)
+ State code (3)
+ Region code (4)
Nh vy, ta thy 2 bng state v region c tham chiu cui cng, lm tn thi gian, do vy ta
s a cc trng state v region vo bng customer. (p n Sub2 B)
Phn 3 ta thy gi tr ca Previous month's orders c xc nh theo 1 thi im xc nh,
do n l tnh ton khng ng b (p n Sub3 a C) cn Current number of
customers c tnh ton khi bng Customer c update, do n l tnh ton khi
update( p n Sub3 b A).
Q16. Read thefollowing description ofprogram design and then answer Sub-questions 1 and 2.
Company N isdeveloping a programtoperform job X thathandlesonlinetransactionprocessing
inreal time. Fig. 1 showsthesystemconfigurationinwhichthe job Xprogramruns.
11) Fig. 1 System ConfigurationforJob X Program
Fig.1 System Configuration for Job X Program
[ExplanationofFlowofTransaction Processing]
(1) The online control program receives a message from a terminal through the communications
control program.
Job XprogramTerminal
Serverusedforjobs
Terminal
Onlinecontrolprogram
Databasemanagement
program
Job Yprogram
Logfiles
Data base
Communications
controlprogram
8/6/2019 1999_ExamPM With My Answers
64/93
64
(2) Theonlinecontrol program analyzesthemessagethatitreceived andstartsupthe job program
thatisneededinordertoperformtherequestedprocessing.
(3) Ifthe jobprogramin questionrequires any I/O transactionswiththedata base, itsearchesforthe
locationwheretherequireddata isstored andperformsread/writeprocessingthroughthedatabase
managementprogram.
(4) Whenthe jobprogramin questioncompletesitsprocessing, theonlinecontrol programsendsthe
response message from the job program to the terminal through the communications control
program.
8/6/2019 1999_ExamPM With My Answers
65/93
65
Thefollowingdata bases andfile areused bythe job X program:
(1) Data bases
Customerattributedata base
Customeraccountdata base
Special customerdata base
(2) Logfile
Thedata directoryforthecustomerattributedata baseismaderesidentinmainmemory bythe
databasemanagementprogram. Beforereadingrecordsfromthecustomer accountdata base and
the special customer data base, input is required once from the disk in order to load the data
directory. The logfileis a sequential file, andmust beoutputtothediskoncepertransaction.
[Overviewofthe Job X Program](1) Theprogram reads the customer attribute data base, using as a key the customer code that is
includedinthemessage.
(2) Ifthecorrespondingcustomerrecordisnotfoundinthecustomerattributedata base, theprogram
generates anerrormessage andterminates.
(3) Ifthecorrespondingcustomerrecordisfound, theprogrameditsthemessageusingtheitemsfrom
thecustomer attributedata base.
(4) Usingthemessagethatit justedited, theprogramupdatesthecustomer'srecordinthecustomer
accountdata base.
(5) Iftheitemsinthecustomer attributedata baseinclude a flagthatindicatesthatthecustomeris a
special customer, theprogramuses themessage thatit justedited to alsoupdate thecustomer'srecordinthespecial customerdata base.
(6) Theprogramwritesthe loginformationinthe logfile.
(7) Theprogramgenerates a responsemessage andterminates.
8/6/2019 1999_ExamPM With My Answers
66/93
66
Sub-question 1. Fig. 2 shows a flowchartforthe job Xprogram. Selectthecorrect answerto be
insertedinthe intheflowchartwhenitiscompleted, selectingyour answerfromthe
choicesprovided.
Start
Customer'srecordfound?
Writetocustomer
accountdata base
Specialcustomer?
Createresponsemessage
End
End
Special
customerdatabase
8/6/2019 1999_ExamPM With My Answers
67/93
67
Fig.2Flow Chart for Job X Program
Answergroupfora andc
A. Createerrormessage.
B. Readcustomerattributedata base, usingcustomercode askey.
C. Readcustomeraccountdata base, usingcustomercode askey.
D. Editmessageusingitemsfromcustomerattributedata base.
E. Writetospecial customerdata base.
F. Readspecial customerdata base.
G. Usemessagetoeditcustomer accountrecord.
H. Usemessagetoeditspecial customerrecord.
I. Create loginformation.
J. Write loginformationin logfile.
Answergroupforb
A. Customerattributedata base B. Customeraccountdata base
C. Special customerdata base D. Logfile
Sub-question 2. Assume that thefollowing tableconcerningdisk I/O counts involving thefile
anddata bases listedhas beenfilledinforthecasewhere a messageconcerns a special customer
andnoerroroccurs. Selectthecorrect answersto beinsertedin fromthechoicesprovided.
Table Table of Disk I/O Counts for Each Data Base and file
Data base/filename Data directoryinput
Data base/fileinput
Data base/fileoutput
Total
Customer attribute data
base0
Customer account data
base1
Special customer data
based
Logfile
Total e
Answergroup
A. 1 B. 2 C. 3 D. 4 E. 5
F. 6 G. 7 H. 8 I. 9
8/6/2019 1999_ExamPM With My Answers
68/93
68
Ans: p n Sub1 a D, c J, b-B Sub 2 d- C, e - H. Phn 1 t s lung cng vic ta d thy
a-D, c J, b B. Phn 2, ta thy data directory input u cn phi c trong trng hp s
dng cc database, ta c bng nh sau:
Data base/file name Data
directory
input
Data base/file
input
Data base/file
output
Total
Customer attribute data
base
1 10
2
Customer account data
base
11
0 2
Special customer data
base
1 1 1 3
Log file 0 0 1 1
Total 3 3 2 8
Nh vy tng cng trong s lung ca chng trnh ta thy s ln cp nht I/O s l 8 ln.
p n Sub2 d C, e-H.
Q17. Read the following description of a microcontroller-controlled fan and then answer
sub-questions 1 through 3.
Fig. 1 showsthesystemconfigurationofthefan, and Table 1 liststhekeyfunctionsofthefan.
Table 2 describestheoperatingstatetransitionsofthefan, indicatingwhichoperatingstatethefan
will shifttofromitscurrentstatewhencertainconditions aremet. Forexample, ifthe ON/OFF
buttonispressedwhilethefanisinthe "continuousoperation" state, thefanwill shifttothe "off"
state. Table 3 liststhe LED lightingstatesforeachoperatingstate.
8/6/2019 1999_ExamPM With My Answers
69/93
69
COMET extensioninterruptrequestinput Timer
"On/Off"button
"Rest Timer"button
Inputport
Input/outputport Motorcontrol circuit
Bus
1Table 1.Button Functions
Buttonname Function
On/Off Switches betweencontinuousoperation andoff.
Rest Timer Sets/cancels the rest timer 30-minute mode and
60-minutemodesettings.
1Table 2.Fan Operating State Transition Table
OperatingstateCondition Off
Continuousoperation
30-minutemode
60-minutemode
"On/Off" buttonpressed Continuous
operationOff Off Off
"Rest Timer" buttonpressed 30-minutemode
60-minutemode
Continuousoperation
Rest timer remaining time = 0minutes Off
Rest timer remaining time = 30minutes
30-minutemode
Fig.1Fan System Configuration
8/6/2019 1999_ExamPM With My Answers
70/93
70
Note: A blankspaceindicates a conditionthatisnotpossibleorwhichhasnoeffect.
Table 3. LED Lighting States for Each Operating State
OperatingstateOff
Continuousoperation 30-minutemode 60-minutemodeLED
ON-LED On On On
30-LED On
60-LED On
A blankspaceindicatesthatthe LED isoff.
Sub-question 1. Table 4 explainstheinput/outputport. Thissystem allowsthemicrocontroller
toreaddata thatiswrittentotheinput/outputport. Selectthecorrect answertoinsertin inthe
text belowfromthechoicesprovided.
When answering, note that in the case of the COMET extension, bit 0 is the MSB (most
significant bit).
1Table 4.Explanation of the Input/Output Port
Bit No. Connectedto Remarks
0 ON - LED 0: Off
1: On1 30 - LED
2 60 - LED
3 Motorcontrol
circuit
0: Off 1: On
4~15 Unused Always "0"
Inorder tomanipulate the bits in the input/outputport, a programwaswrittenthatreads the
data in the input/output port, changes the target bit, and writes the new data back to the
input/outputport.
Forexample, inordertoturnoffthe 30-LED andturnonthe 60-LED, thisprogramwill AND
thedata fromtheinput/outputportwiththehexadecimal value a andthen ORthedata withthe
hexadecimal value b , andthenwritetheresult backtotheinput/outputport.
Answergroupfora
A. 7000 B. B000 C. D000 D. E000 E. F000
Answergroupforb
A. 1000 B. 2000 C. 4000 D. 6000 E. 8000
8/6/2019 1999_ExamPM With My Answers
71/93
71
Sub-question 2. Fig. 2 shows a flow chartfor the mainprogram. From thechoicesprovided,
insertthecorrect answersinthe in Fig. 2, assumingthatinterruptprocessinghasnoeffecton
theprogram.
Mainprogram
0 p TCStopp MODEOtherinitializationprocessing
MODE is a variablethatexpressesthecurrentoperatingstate. TCindicatesthenumberofsecondsuntil thefanshutsoff; TC is avariablethatiscounteddown bythetimerinterruptprocessing.
Wasthe"Rest Timer" button
pressed?
MODE= off
Continuousoperationp MODE Offp MODE
30-minutemodepMODE
60-minutepMODE
ON-LED onMotoron
All LEDsoffMotoroff
0 p TC
30-LED on60-LED off
1800 p TC
30-LED on60-LED off
3600 p TC
30-LED on60-LED off
0 p TC
Offp MODE
Fig.2 Main Program Flow Chart
Answergroupforc
A. Eitherbuttonwaspressed.
B. Neitherbuttonwaspressed.
C. Both buttonswerepressed.
D. "On/Off" buttonwaspressed.
E. "On/Off" buttonwasnotpressed.
AnswergroupfordthroughfA. 30-minutemode B. 60-minutemode
C. Off D. Continuousoperation
8/6/2019 1999_ExamPM With My Answers
72/93
72
Sub-question 3. Fig. 3 shows the flow chart for the timer interrupt processing. The timer
interruptisgeneratedevery 100ms. Selectthecorrect answerstoinsertinthe in Fig. 3 from
thechoicesprovided.
TimerinterruptCNT is a varia
lethatisinitialized
y themainprogram andisused as an interruptcounter. TCindicatesthenumberofsecondsuntil thefanshutsoff, andisdecrementedby oneeverysecond.
Offp
ODE
ff
M t roff
E
30-mi te modepMODE
30-
ED on
0-
ED off
i
Fig. 3 Timer Interrupt Processing Flow Chart
Answergroupforg
A. 6 B. 10 C. 60 D. 100 E. 1000
Answergroupforh
A.
30 B.
60 C.
180 D.
1800 E.
3600AnswergroupforI
A. 30 - LED B. 30 - LED and 60 - LED
C. 30 - LED and ON - LED D. 60 - LED
E. 60 - LED and ON - LED
8/6/2019 1999_ExamPM With My Answers
73/93
73
Ans: p n Sub 1 a- B, b B; Sub 2 c D, d D, e A, f B Sub 3 g B, h D, I - cS. Vi
phn 1, gi s ta c trng thi bit i l x -> mun bt bit th ta s OR vi 1, tt bit th ta
AND vi 0, gi nguyn bit th ta AND vi 1 hoc OR vi 0. Nh vy, y ta cn thay i
trng thi input x1x2...x16 , output l x101x40000...0. S a y s l 1011000000000000 hay
B000 cn b y l 0010000000000000 hay 2000. Vi phn 2, ta c c l p n D, n l
iu kin kim tra xem qut c bt khng? d l p n D, t ch chy lin tc chuyn
sang ch 30 minutes, e l p n A t ch 30 minutes sang ch 60 minutes, f l p
n B t ch 60 minutes chuyn sang ch continues. Vi phn 3, ta c CNT y
c m n g th s khi to li v TC s gim i 1 giy, vy g y tng ng vi 1
giy/100ms = 10. p n B. TC y c so snh vi h trc khi chuyn sang ch 30
minutes, vy h y chnh l chuyn t ch 60 minutes sang ch 30 minutes, hay h =
30 pht = 1800. p n D. Cn I y l chuyn t ch 30 minutes sang ch OFF, c
n ON v 30-LED u tt. p n C.
Assembly Language Specifications
1. COMET Hardware Specifications1.1 Processor
(1) COMET is a one-word/16-bitcomputer, ableto access an addressspacefrom 0 to 65535.
(2) The bitformatofa wordinthe COMET computeris asfollows:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
(3) Numericvalues areexpressed as 16-bit binarynumbers. Negativenumbers areexpressedin
two'scomplement.
(4) Control issequential. COMET utilizes a two-wordinstructionword.
(5) The COMET hasthreetypesofregisters: GR (16 bits), PC (16 bits), and FR (2 bits).
There arefive GR (General Register)registers, GR0 through GR4. Thesefiveregisters are
usedfor arithmetic, logical, compare andshiftoperations. Of these, GR1 through GR4 are
alsoused asindex registers. GR4 isfurtherused asthestackpointer.
Thestackpointeris a registerthatisusedtostorethe addresscurrently atthetopofthestack.
The PC (Program Counter) stores thefirst address of the instruction word that iscurrently
beingexecuted. Oncethecurrentinstructionfinishesexecuting, thefirst addressofthenextinstructionwordissetinthe PC. Generally, when aninstructionsfinis hesexecuting, the PC is
incremented by two by meansof "address addition" (note); in thecaseof a branch, call, or
returninstruction, thenew addresstowhichcontrol branchesissetinthe PC.
The FR (Flag Register) stores information on whether data stored in a GRregister (as a
Bit No.Sign (Negative: 1, Positive: 0)
8/6/2019 1999_ExamPM With My Answers
74/93
74
resultofexecuting a load address instructionor anyof various arithmetic, logical, andshift
operationinstructions)isnegative, zero, orpositive, and alsostoresinformationresultingfrom
theexecutionofa compareoperationonthecomparativesizeoftwonumbers.
In other words, the bits in the FR register can be set as shown in the following chart,
depending on the result generated by certain
operation instructions. (In the case of compare
operations, however, refer to section 1.2(4),
"Compare Operation Instructions.")
Inthechartshown atright, whenthesign bitinthe GRregisteris "1," thevaluein questionis
negative. When all ofthe bitsinthe GRregisterare "0," thevalueiszero. Whenthesign bitin
the GRregisteris "0," and at leastoneofthedata bitsis "1," thevaluein questionispositive.
Thefirst (leftmost) bitinthe FRregistershowsthevalueinthe GRsign bit. Thesecond bit
indicateswhetherthevalueinthe GRregisteriszeroornot.Thevaluein FRisreferenced byconditional branchinstructions.
Theexecutionofinstructionsotherthanthosementioned abovedoesnotchangethevaluein
the FRregister.
(6) Instructionwordformat
The COMET utilizes a two-wordinstructionword. Thedetailedformatofinstructionsisnot
defined.
(7) Instructionnotation
Thefollowingnotationisusedinthedescriptionoftheinstructions.
GR General-purposeregisterwiththevalueofGR asitsnumber(where 0 eGRe4).
XR Index registerwiththevalueofXR asitsnumber(where 1 e XRe 4).SP Stackpointer(general-purposeregister4)
adr Label name (representing thatcorresponds to the label)or a decimal constant
(where
32768e adre65535 ; adrcanhave a valuefrom 0 to 65535, butthevaluesfrom 32768 to
65535 can also beusedtoexpressnegativedecimal numbers).
Effective address A valueproduced by adding, through "address addition," adrandthe
contentsofXR, orthe addresspointed at bythatvalue.
(X) Thecontentsofaddress X; ifX is a register, thenthecontentsofthatregister.
[ ] Square brackets ([ ])indicatethattheinformationcontainedinthe bracketsmay
beomitted.IfXRisomitted, modification bytheindex registerisnotperformed.
(Note) "Address addition": Treats the data to be added as unsigned data; the result is the
Data setinthe GRregister
Negativ
Zero Positi
8/6/2019 1999_ExamPM With My Answers
75/93
75
remainderthatisobtained by addingthetwovalues andthendividingthesum by 65536. (In
otherwords, theresultisthevalueofthe 16 lower bitsofthesum.) "Addresssubtraction" is
definedin a similarfashion.
8/6/2019 1999_ExamPM With My Answers
76/93
76
1.2 Instructions
Instructions andtheirfunctions aredescribedinthefollowingchart. Instructions aredescribedin
assemblernotation.
InstructionFormat
DescriptionofinstructionsOpcode
Operand
(1) Load, storeinstructionLoaD LD GR,adr
[,XR]
Sets (effective address)in GR.
STore ST GR,adr
[,XR]
Stores (GR)inthe addressindicated bytheeffective address.
(2) Load addressinstructionsLoad Effective Address LEA GR,adr
[,XR]
Setstheeffective addressin GR.
Sets FRin accordancewiththevalueofGR.
(3) Arithmetic and logical operationinstructions
ADD arithmeticADD GR,adr
[,XR]
Performsthespecifiedoperationon (GR) and(effective address), andsetstheresultin GR. Notethatinthesubtractionoperation, (effectiveaddress)issubtractedfrom (GR). Sets FRin accordancewiththevalueoftheoperationresult.
SUBtract arithmeticSUB GR,adr
[,XR]
ANDAND GR,adr
[,XR]
OROR GR,adr
[,XR]
Exclusive OREOR GR,adr
[,XR]
(4) CompareoperationinstructionsComPare Arithmetic CPA GR,adr
[,XR]
Performs an arithmeticcompareorlogicalcompareoperationon (GR) and (effectiveaddress), andsets FR asfollows, accordingtotheresultofthecompareoperation.
ComPare Logical CPL GR,adr
[,XR]
(5) ShiftoperationinstructionsShift Left Arithmetic SLA GR,adr
[,XR]
Shifts GR (exceptforthesign bit) leftorright bythenumberofbitsspecified bytheeffectiveaddress.When a leftshiftisperformed, those bitsthat are
Compareresult FR bitvalue(GR) > (effective address) 00(GR) = (effective address) 01(GR) < (effective address) 10
8/6/2019 1999_ExamPM With My Answers
77/93
77
Shift Right Arithmetic SRA GR,adr
[,XR]
leftvacant bytheshiftoperation arefilledwithzeroes. When a rightshiftisperformed, those bits
that are leftvacant bytheshiftoperation arefilledwiththesamevalue asthesign bit.Sets FRin accordancewiththevalueoftheshiftoperationresult.
Shift Left Logical SLL GR,adr
[,XR]
Shifts GR (includingthesign bit) leftorright bythenumberofbitsspecified bytheeffectiveaddress.Those bitsthat are leftvacant bytheshiftoperation arefilledwithzeroes.Sets FRin accordancewiththevalueoftheshiftoperationresult.
Shift Right Logical SRL GR,adr
[,XR]
(6) BranchinstructionsJumpon PlusorZero JPZ adr[,XR] Branchestotheeffective address, dependingon
thevalueofFR. Ifcontrol doesnot branchto a
new address, executioncontinueswiththenextinstruction.J
umpon MInus JMI adr[,XR]
Jumpon Non Zero JNZ adr[,XR]
Jumpon ZEro JZE adr[,XR]
unconditional JuMP JMP adr[,XR] Branchesunconditionallytotheeffective address.
(7) StackoperationinstructionsPUSH effective address PUSH adr[,XR] After subtracting (by means of "address
su
btr
action
")
one
from
SP,this
instruction
stores
theeffective addressin address (SP).POP up POP GR Aftersettingthecontentsofaddress (SP)in GR,
thisinstruction adds (bymeansof"addressaddition")oneto SP.
Instruction ValueofFRinorderto branch JPZ 00, 01JMI 10JNZ 00, 10JZE 01
8/6/2019 1999_ExamPM With My Answers
78/93
78
(8) Call andreturninstructionsCALL subroutine CALL adr[,XR] After subtracting (by means of "address
subtraction") one from SP, this instructionstores
the value resulting from adding (by means of
"address addition")twotothecurrentvalueofthe
PC in address (SP), and then branches to the
effective address.RETurnfromsubroutine RET Afterfetchingthecontentsofaddress (SP), this
instruction adds (bymeansof"address addition")onetothe SP andthen branchestothe addressthatisindicated bythepreviouslyfetchedcontents.(Thefetchedcontents aresetinthe PC.)
1.3 Character SetCOMET supports a JIS X0201 Romaji/katakana charactersetthatuses 8-bitcodes. Partofthe
charactersetisshowninthetable below. Ifanycharactersnot listedinthis areneededtosolveone
oftheproblems, the bitconfigurationforthatcharacterwill begivenintheproblem.
[ExplanationofTable]
Eight bits are used to represent one
character; the upper four bits indicate the
column in the table, and the lower four bits
indicate the row. For example, the
hexadecimal codes for the space character,
"3," "F," and "Z" are 20, 33, 46, and 5A,
respectively.
The characters that correspond to the
hexadecimal codes 21 to 5F, 60 to 7E, and A1
to DF are called "graphics characters." This
table omits the characters corresponding to
codes 60 through 7E (defined as lower-case
letters) andcodes A1 through DF (defined as
kana, etc.).
Graphics characters can be displayed
(printed) as characters on an output device
such as a monitorora printer.2. Specifications of the CASL Assembly Language
Assembly language for the COMET is
called "CASL." ThespecificationsforCASL
aredescribed below.2.1 Instruction Types
Column
8/6/2019 1999_ExamPM With My Answers
79/93
79
Pseudoinstruction FunctionSTART Definesthetopofa program.
Defines thestarting addressforexecutionofa program.Defines the entry for linking with other
programs.END Definestheendofa program. DS Allocates an area. DC Defines a constant.
CASL consists of four pseudo instructions(START,END ,DS,and DC),threemacroinstructions (IN,OUT,and EXIT) and machine language instructions
(COMET instructions).
(1) Pseudo Instructions
Pseudo instructions are used for tasks
such as assembler control, definition of
constants, and creating data needed to link
theprogram. The functions of thepseudo
instructions are listedinthetable atright.
(2) Macroinstructions
Macro instructions use a pre-defined
groupofinstructions andoperanddata togenerate a group of instructions that
performs a desiredfunction.
CASLprovides macro instructionsforperforming I/O, terminating a program, etc. Because
machine language I/O instructions, etc., arenotdefined in CASL, suchprocessing is left to the
operatingsystem. When a macro instruction is
encountered, CASL generates a group of
instructions that calls the operating system.
Assumethatthenumberofwordsinthegroupof
instructionsthatisgeneratedisundefined.
When a macroinstructionisexecuted, thecontentsofthe GRregisters aresaved butthecontentsofFR
areundefined.
Thefunctionsofthemacroinstructions are listedinthetable atright
(3) Machine languageinstructions
There are 23 machine languageinstructions, as
describedinsection 1.2, "Instructions."
Macroinstruction FunctionIN InputOUT OutputEXIT Terminatesprogramexecution.
8/6/2019 1999_ExamPM With My Answers
80/93
80
2.2 Instruction Format
Pseudo instructions, macro instructions, and machine language instructions all have a label
field, anopcodefield, anoperandfield, and a commentfield. Eachfieldisdefi ned below.Label field The label consistsofuptosix characters, startingfromthefirstcharacter.
Opcodefield When there is no label: Starts from the second or any other subsequent
characterposition.
Whenthereis a label: Startsfrom anycharacterpositionfollowing at least
one space
character afterthe label field.
Operandfield Startsfrom anycharacterpositionfollowing at leastonespacecharacterafter
theopcodefield, uptothe 72ndcharacter. Thisfieldcannot becontinuedon
thenext lineintheprogram.
Commentfield When a semicolon (;) isencountered in a line, everything thatfollowsuntiltheendofthe lineistreated as a comment. (Thisdoesnot applytosemicolons
(;)encounteredin a characterstringfora DC instruction, however.)
Notethatifthefirstnon -spacecharacterin a lineis a semicolon, theentire line
istreated as a comment.
Anycharacter (thatis allowed bytheprocessingsystem)can bewrittenin a
commentfield.
The format of each
instructionin CASL isshownin
thetable atright.When "blank" isindicatedfor
a field, that field must not be
described.
(1) Registerspecification
In the operand field of a machine language
Label Instructioncode Operand Howtoreadlabel START Executionstart address STARTBlank END Blank END[label] DC Constant Define Constant[label] DS Lengthofarea inwords Define Storage [label] IN Input area,
inputstring length INput
[label] OUT Output area,
outputstring length
OUTput
[label] EXIT Blank EXIT[label] Machine languageinstruction (Referto 1.2, "Instructions.")
Specification byregistersymbol
General-purposeregisternumber
GR0 0GR1 1GR2 2GR3 3GR4 4
8/6/2019 1999_ExamPM With My Answers
81/93
81
instruction, thenumbers 0 through 4 areused to
specify a general register, butthesymbolsshown
inthetable atrightcan also beused.
(2) Label field
"label" inthe label fieldrepresents a label. A label canconsistofuptosix characters; thefirst
charactermust be anupper-case letter. Subsequentcharactersmay beeitherupper-case lettersor
numbers. The labels assigned to DC, DS, IN, OUT, EXIT andmachine language instructions
indicate the address of the first word of the associated area or instruction word (or group of
instructions, inthecaseofa macroinstruction).
The label that is assigned to a START instruction can bereferenced as anentry name from
anotherprogram.
2.3 Pseudo Instructions
(1) START [Executionstart address]
Thispseudoinstructionindicatesthetopofaprogram. Inotherwords, thispseudoinstruction
must bewritten atthevery beginningofa program.
The label namethatisdefinedwithinthisprogramspecifiestheexecutionstart address. Ifthe
label isomitted, execution begins atthestartoftheprogram.
(2) END
Thispseudo instruction indicates the end of theprogram. Thispseudo instruction must be
written attheveryendoftheprogram.(3) DC Constant
Thispseudo instructionstoresconstantdata thathas beenspecified as a constant. There are
fourtypesofconstants: decimal constants, hexadecimal constants, characterconstants and address
constants.
8/6/2019 1999_ExamPM With My Answers
82/93
82
Typeof
constant
Format
DescriptionofinstructionOpco
de
Operand
Decimal
constant
DC n This instructionstores the decimal value specified by "n" as
onewordofbinarydata. Ifnisoutsideoftherangeof32768
to 32767, justthe lower16 bitsofn arestored.
Hexadeci
mal
constant
DC #h Assume "h" is a four-digit hexadecimal number.
(Hexadecimal notationuses 0 through 9 and A through F.) This
instructionstoresthehexadecimal valuespecified by "h" asone
wordofbinarydata. (0000 ehe FFFF)
Characte
r
constant
DC 'character
string'
This instructionstoreseach character in the character string,
startingfromthe leftendofthestring, inthe lowereight bitsof
consecutivewords. Inotherwords, thefirstcharacterisstored
in bits 8 through 15 of the first word, the second character is
storedin bits 8 through 15 ofthesecondword, andsoon, sothat
the character data for each character in the string is stored
sequentiallyinmemory. Bits 0 through 7 ofeachword arefilled
withzeroes. Spaces and anyofthegraphicscharacters (referto
1.3, "Character Set") can be written in a character string.
Apostrophes (')cannot bewrittenincharacterstrings, however.
A character string can not have a length of zero (i.e., the
characterstringcannot beempty).
Address
constant
DC Label name This instructionstores an addressvaluecorresponding to the
label name asonewordofbinarydata. Ifthe label nameisnot
defined within this program, the assembler refrains from
determining the address and entrusts that task to theoperating
system. (Referto 3.1, "Undefined Labels.") (4) DS Area word length
Thispseudoinstruction allocates an area ofthespecifiedword length.
Theword lengthofthe area isspecified by a decimal number (u 0). If"0" isspecifiedforthe
word lengthofan area, the area isnot allocated, butthe label nameinthe label fieldisvalid. 2.4 Macro Instructions
(1) IN Input area, inputcharacterlength
This macro instruction inputs one record of data (character data) to the input area from a
previously assigned input device. (For details on assigning an input device, refer to 3.1(3),
"Input/outputdevice assignment.")
Write label names for the input area and the input character length operands in theoperand
8/6/2019 1999_ExamPM With My Answers
83/93
83
field.
Theinput area operandshould bethe label nameofan 80-wordworkarea (whichissufficient
for 80 characters). The input data is input in this area (beginning at the starting address), one
characterperword. Zeroes arestored in bits 0 through 7 ofeachword (in thesamemanner as
characterconstantswiththe DC instruction).
The lengthofthedata thatwasinput (thenumberofcharactersintheinputrecord)isstored as
binary data in the area (one word) specified by the input character length operand. No record
delimitercode (such as a linereturncode, whenusing a keyboard)isstored.
If the inputdata is less than 80 characters long, thepreviousdata (thedata thatwas already
there beforethismacrowasexecuted)is left asisintheremainingportionoftheinput area. Ifthe
inputdata exceeds 80 characters, theexcesscharacters areignored.
"0" and "1" arestored astheinputcharacter lengthinthefollowinginstances:
0: Wheninputting anemptyrecord (forexample, whenonlythereturncodewasinputfromthetypewriterterminal).
1: When EOF (endoffile)wasdetected (whenusing a cardreader, etc.)
(2) OUT Output area, outputcharacterlength
This macro instruction outputs data stored in the output area as one record of data to the
previously assigned output device. (For details on assigning an output device, refer