2001PM
2001PM
Read the following description concerning program design and then answer sub-questions
1 through 4.
A subprogram that calculates the day of the week for a given date has been created and is
being tested.
[Description of Subprogram]
This subprogram calculates the day of the week for a date (given according to the western
calendar). If there is an error in the date that is entered, the program returns a
corresponding error code.
(1) The date is given in the format “yyyy, mm, dd” (yyyy: four digits for the year (in the
western calendar); mm: two digits for the month; dd: two digits for the day of the
month).
(2) If the date information is valid, the program returns the corresponding day of the
week (SUN, MON, TUE, WED, THU, FRI, SAT).
(3) If the date information is invalid, the program returns, as a return code, an error code
that corresponds to one of the three types of errors described in Table 1.
2
[Testing the Subprogram]
Based on the description of the subprogram, the test items were set and test data was
created with due consideration given to the boundary values. Table 2 shows the test data
and the expected correct results.
Note: 1996 and 2000 are leap years, 2001 and 2100 are not leap years.
Sub-question 1
From the answer group below, select the term which describes the type of test that is being
conducted with the test data shown in Table 2.
Answer group:
a) Integration test b) Performance test
c) Endurance test d) Black-box test
e) White-box test
Sub-question 2
From the answer group below, select the correct answer to be inserted in the box
in Table 2.
Answer group:
a) (2001,01,01; MON) b) (2001,01,33; E1) c) (2001,06,01; FRI)
d) (2001,00,99; E1) e) (2002,02,29; E3) f) (2010,13,14; E1)
3
Sub-question 3
When the subprogram was executed using the test data shown in Table 2, the response for
the year 2100 test data in the “February 29” test item was “2100, 02, 29; MON” instead of
the expected correct result indicated by the underlined data in the table. From the answer
group below, select the correct conclusion that we can draw from these results.
Answer group:
a) Because February 29 only comes once every four years, the impact from this problem
is small. Considering the effort that would be required to correct this error in the
program and the possibility that the correction could give rise to new problems, it is
not appropriate to attempt to correct this error.
b) Because the correct response is generated for non-leap years, it is best to change the
underlined test data to a non-leap year so that all of the test results will be correct
without reducing the amount of test data.
c) It is likely that there is an error in the leap year calculation processing. Therefore, to
correct the subprogram, the first step is to check the portion of the code that handles
leap-year processing.
d) Although the number of days varies from month to month, the range of values for the
month is always “1” to “12,” so there was no need to conduct a range test on the
month value.
e) Because the year 2100 is 100 years ahead in the future, there is no need to correct the
sub-program.
4
Sub-question 4
The figure below is a flowchart for calculating the date of the second Monday in October
in a given year (assume the year is 2000 or later) using the debugged subprogram.
From the answer group below, select the correct answers to insert in the boxes .
Fig. Flowchart for Obtaining the Date of the Second Monday in October
Answer group:
a) Day 31?
b) Day ≦ 31?
c) Is the return value an error code?
d) Is the return value “MON”?
e) Is the return value “SUN”, “TUE”, “WED”, “THU”, “FRI” or “SAT”?
f) Is the return value “SUN”, “MON”, “TUE”, “WED”, “THU”, “FRI” or “SAT”?
5
Select one of the following three questions (Q6, Q7, or Q8) to answer. Be sure to mark the
“Select” circle corresponding to the question that you select to answer on your answer sheet.
Note that if you select two or more questions, only the first question that you select will be scored.
Q6. Read the following description of a C program and the program itself, and then answer the
sub-question.
[Program Description]
The function CountColors is a program that scans the image data in a specified
rectangular region that is 320 pixels wide by 240 pixels high and counts the number of
colors that are actually used. A pixel is stored in the following RGB structure:
typedef struct {
unsigned char Red ; /* Red brightness; 256 levels, from 0 to 255 */
unsigned char Green ; /* Green brightness; 256 levels, from 0 to 255 */
unsigned char Blue ; /* Blue brightness; 256 levels, from 0 to 255 */
} RGB ;
The image data is stored in a two-dimensional array of the RGB structures. The definition
of the image data is shown below. The relationship between the image and the coordinate
system is shown in the figure.
After the image data is loaded into the array Image, the function CountColors is called
with the parameters that indicate the rectangular region in which the colors are to be
counted. The number of colors is then returned by the function as a return value.
6
The prototype for the CountColors function is as follows:
long int CountColors( int sx, int sy, int dx, int dy );
The figure shows the relationship between the parameters and the point coordinates.
[Program]
typedef struct {
unsigned char Red ;
unsigned char Green ;
unsigned char Blue ;
} RGB ;
long int CountColors( int sx, int sy, int dx, int dy )
{
int w, h ;
int px, py ;
long int Colors ;
int Counted[ Height ][ Width ] ;
Colors = 0 ;
for( py = sy ; py <= dy ; py++ )
for( px = sx ; px <= dx ; px++ ) {
if ( Counted[py][px] == FALSE ) {
;
Counted[py][px] = TRUE ;
7
Sub-question
From the answer groups below, select the correct answers to be inserted in the boxes
in the program.
8
Q7. Read the following description of a COBOL program and the program itself, and then
answer sub-questions 1 and 2.
[Program Description]
A manufacturer selects suppliers of each of the materials required for production and
manage the suppliers with a supplier-by-material file. Consider the process to delete from
this file those suppliers with whom the company is no longer dealing.
The file is an indexed file that uses the material code as a key.
The supplier count stores the number of suppliers registered in the file.
Up to five supplier codes (or no codes) are registered for each material code.
Supplier codes are registered starting from the first field; a space is stored in any field in
which no supplier code is registered.
(2) The format of records in the deletion instruction file is shown below:
Material code Supplier code
6 digits 4 digits
The program reads from the material-supplier file the record which corresponds to the
material code, deletes the corresponding supplier code, and reduces the supplier count by
one.
As part of the deletion processing, the program alters the supplier-by-material file so that
item under (1) above may be satisfied.
Assume that all of the data in the deletion instruction file is correct.
9
[Program]
(Line No.)
1 DATA DIVISION.
2 FILE SECTION.
3 FD SUPPLIER.
4 01 ORDER-R.
5 03 O-MATERIAL PIC X(6).
6 03 O-COUNT PIC 9.
7 03 O-TABLE.
8 05 O-ORDER OCCURS 5 PIC X(4).
9 FD INSTRUCT.
10 01 INSTRUCT-R.
11 03 I-MATERIAL PIC X(6).
12 03 I-ORDER PIC X(4).
13 WORKING-STORAGE SECTION.
14 01 END-SW PIC X VALUE SPACE.
15 01 CNT PIC 9.
16 01 W-CNT PIC 9.
17 PROCEDURE DIVISION.
18 START.
19 OPEN INPUT INSTRUCT I-O SUPPLIER.
20 PERFORM UNTIL END-SW = "Z"
21 READ INSTRUCT AT END MOVE "Z" TO END-SW END-READ
22 IF END-SW = SPACE
23 MOVE I-MATERIAL TO O-MATERIAL
24 READ SUPPLIER
25 INVALID DISPLAY "READ-ERROR I-MATERIAL = ", I-MATERIAL
26 NOT INVALID PERFORM SEARCH
27 PERFORM D-RTN
28 END-READ
29 END-IF
30 END-PERFORM.
31 CLOSE INSTRUCT SUPPLIER.
32 STOP RUN.
33 SEARCH.
34 PERFORM VARYING CNT FROM 1 BY 1 UNTIL
35 CONTINUE
36 END-PERFORM.
37 D-RTN.
38 PERFORM UNTIL CNT = O-COUNT
39 COMPUTE W-CNT = CNT + 1
40 MOVE O-ORDER(W-CNT) TO O-ORDER(CNT)
41 COMPUTE CNT = CNT + 1
42 END-PERFORM.
43 MOVE SPACE TO O-ORDER(O-COUNT).
44 COMPUTE O-COUNT = O-COUNT 1.
45 REWRITE ORDER-R
46 INVALID DISPLAY "REWRITE-ERROR", O-MATERIAL, I-ORDER.
10
Sub-question 1
From the answer group below, select the correct answer to insert in the box in
the program.
Answer group:
a) I-ORDER = O-ORDER(CNT)
b) I-ORDER = O-ORDER(O-COUNT)
c) I-MATERIAL = O-MATERIAL
Sub-question 2
Lines 38 to 42 in the program are being changed to avoid repetition. From the answer
groups below, select the correct answers to insert in the boxes in the modified
code below.
Note that W1, W2, and W3 are all defined as two-digit work areas, and W-TABLE is defined
as a 20 (alphanumeric)-character item.
Answer group:
a) CNT * 4 1 b) CNT * 4 + 1
c) (CNT 1) * 4 1 d) (CNT 1) * 4 + 1
e) (CNT + 1) * 4 1 f) (CNT + 1) * 4 + 1
g) (O-COUNT 1) * 4 + 1 h) (O-COUNT CNT) * 4 1
i) (O-COUNT CNT) * 4 j) (O-COUNT CNT) * 4 + 1
11
Q8. Read the following description of an assembler program and the program itself, and then
answer sub-questions 1 and 2.
[Program Description]
“n” consecutive words are regarded as a bit string consisting of 16 n bits. The sub-
program SHIFT shifts this bit string right by m positions.
(1) The main program stores the following values in GR1 through GR3, respectively, and
then passes these values to SHIFT.
GR1 : Address of the first word of the bit string
GR2 : m
GR3 : n
(2) Assume that 1 ≦ n ≦ 32767 and that 0 ≦ m ≦16.
(3) The shifted bit string is stored in the original area.
(4) “0” is stored in the empty bit positions before the left end of the string. The bits
removed from the right side of the register are discarded.
(5) The functions of the RPUSH and RPOP macro instructions used in the program are as
described below:
RPUSH : Saves the contents of GR1 through GR7 into the stack.
RPOP : Restores the contents of the stack into GR1 through GR7.
12
[Program]
(Line No.)
1 SHIFT START ;
2 RPUSH ; Save registers
3 ;
4 SUBA GR4,GR2 ; (16m)GR4
5 LAD GR5,0 ; ‘0’ bit string to be stored at the left end
6 LOOP SLL GR5,0,GR4 ; Move to the left end the remaining bit string from
the previous word
7 LD GR0,0,GR1 ; The bit string in the current wordGR0
8 ;
9 OR GR0,GR5 ; Catenate the left-over bit string
10 LD GR5,0,GR1 ; Save bit string in current word into GR5
11 ST GR0,0,GR1 ; Store catenated bit strings into the current word
12 LAD GR1,1,GR1 ; Obtain the address of the next word
13 SUBA GR3,=1 ;
14 ;
15 RPOP ; Restore registers
16 RET ;
17 END ;
Sub-question 1
From the answer groups below, select the correct answer to insert in the boxes
in the program.
13
Sub-question 2
The LAD instruction in line 5 has been replaced with the following three instructions in
order to store the bit substring removed from the right end in the open bit positions at the
left end of the string, as shown in Fig. 2. From the answer group below, select the correct
answer to insert in the box below.
LD GR5,GR1
ADDL GR5,GR3
Answer group:
a) LD GR5,1,GR5 b) LD GR5,0,GR5 c) LD GR5,1,GR5
d) ST GR5,1,GR1 e) ST GR5,0,GR1 f) ST GR5,1,GR1
14
Select one of the following three questions (Q9, Q10, or Q11) to answer. Be sure to mark the
“Select” circle corresponding to the question that you select to answer on your answer sheet.
Note that if you select two or more questions, only the first question that you select will be scored.
Q9. Read the following description of a C program and the program itself, and then answer
sub-questions 1 through 4.
[Program Description]
A function DrawCurve was created to draws a free curve between point S at coordinates
(sx, sy) and point E at coordinates (ex, ey) on the screen through approximation by using a
sequence of minute line segments. In order to determine the shape of the curve, two
control points are specified as parameters: C1 at coordinates (x1, y1) and C2 at coordinates
(x2, y2). The polygonal curve that is formed by the four points given as shown in the
figure is then divided recursively, and the final series of straight line segments are drawn
when the convergent condition determined by the parameter len (len > 2) is met.
(The enlarged dots are intended as a symbol that indicates the coordinates of a point,
15
The following two functions are provided for the purpose of drawing straight segment that
connect two points:
[Program]
void MoveTo( int sx, int sy ) ;
void LineTo( int ex, int ey ) ;
int CmpLine( int xs, int ys, int xe, int ye, int len ) ;
void DrawCurve( int sx, int sy, int x1, int y1, int x2, int y2,
int ex, int ey, int len )
{
int p1x, p1y, p2x, p2y, p3x, p3y ;
int p4x, p4y, p5x, p5y, p6x, p6y ;
if ( CmpLine( sx, sy, x1, y1, len ) &&
CmpLine( x1, y1, x2, y2, len ) &&
CmpLine( x2, y2, ex, ey, len ) ) {
MoveTo( sx, sy ) ; LineTo( x1, y1 ) ;
LineTo( x2, y2 ) ; LineTo( ex, ey ) ;
return ;
}
p1x = ( sx + x1 ) / 2 ; p1y = ( sy + y1 ) / 2 ;
p2x = ( x1 + x2 ) / 2 ; p2y = ( y1 + y2 ) / 2 ;
p3x = ( x2 + ex ) / 2 ; p3y = ( y2 + ey ) / 2 ;
p4x = ( p1x + p2x ) / 2 ; p4y = ( p1y + p2y ) / 2 ;
p5x = ( p2x + p3x ) / 2 ; p5y = ( p2y + p3y ) / 2 ;
p6x = ( p4x + p5x ) / 2 ; p6y = ( p4y + p5y ) / 2 ;
DrawCurve( sx, sy, p1x, p1y, p4x, p4y, p6x, p6y, len ) ;
DrawCurve( p6x, p6y, p5x, p5y, p3x, p3y, ex, ey, len ) ;
return ;
}
int CmpLine( int xs, int ys, int xe, int ye, int len )
{
int len1 = xe xs ;
int len2 = ye ys ;
if ( len1 < 0 ) len1 = len1 ;
if ( len2 < 0 ) len2 = len2 ;
if ( ( len1 < len ) && ( len2 < len ) )
return 1 ;
return 0 ;
16
}
17
Sub-question 1
In order to divide a polygonal curve into two, it calculates the coordinates of the midpoints
of three line segments, and then calculates the coordinates of the midpoints of additional
line segments. From the answer group below, select the figure that illustrates the method
for determining the four vertices of the new polygonal curve.
Answer group:
a) b)
c) d)
18
Sub-question 2
From the answer group below, select the correct condition for ending the recursive division
processing.
Answer group:
a) When each of the three line segments of the polygonal curve becomes longer than the
length given by the parameter len.
b) When each of the three line segments of the polygonal curve becomes shorter than the
length given by the parameter len.
c) When each of the three line segments of the polygonal curve becomes short enough to
fit within a square with sides of the length given by the parameter len.
d) When one of the three line segments of the polygonal curve becomes longer than the
length given by the parameter len.
e) When one of the three line segments of the polygonal curve becomes shorter than the
length given by the parameter len.
f) When one of the three line segments of the polygonal curve becomes short enough to
fit within a square with sides of the length given by the parameter len.
19
Sub-question 3
From the answer group below, select the correct responses to insert in the boxes
in the following description of the characteristics of this program.
In case a free curve was drawn with a value of “8” for the parameter len, a
caused the function LineTo (which draws straight lines) to be called the largest number
of times.
If the same curve were drawn with a value of “16” specified for the parameter len, the
number of times the function LineTo was called would be the number of times
the function LineTo was called when the value of Len is “8.”
a) b)
c) d)
20
Sub-question 4
From the answer group below, select the figure that correctly shows the results produced
by executing the following program.
int Lines ;
int cx1, cy1 ;
int cx2, cy2 ;
for ( Lines = 0, cx1 = 128, cy1 = 160, cx2 = 256, cy2 = 160 ;
Lines < 16 ;
Lines++, cx1 += 16, cy1 = 16, cx2 = 16, cy2 += 16 ) {
DrawCurve( 50, 160, cx1, cy1, cx2, cy2, 384, 160, 8 ) ;
}
Answer group:
a) b)
c) d)
21
Q10. Read the following description of a COBOL program and the program itself, and then
answer the sub-question.
[Program Description]
Assume that there is a seminar application file in which applications for seminars are
registered. Each individual can apply only once for a seminar, but can apply for up to 10
different seminars. This program flags as an error any application that requests more than
one seminar held on the same day, and then prints an error listing.
(1) The record format in the seminar application file is shown below.
Assume that the same seminar number will not be specified more than once.
The seminars being applied for are listed sequentially, starting from field 1; if there are
fewer than ten seminars requested, the remaining fields are left empty.
Assume that the seminar numbers are stored in the seminar schedule file.
(2) The record format in the seminar schedule file, in which the details of each seminar
are registered, is as follows.
Seminar number Scheduled date Room number
4 digits 8 digits 10 digits
This file is an indexed file, using the seminar number as the key.
All the seminars that are to be held are registered.
(3) The following is an example of the table CHK-TBL that is used by this program to
check each application for multiple seminars being held on the same day.
Example: Assume that the following data from the seminar application file and from
the seminar schedule file has been provided.
22
In this case, the contents of the table CHK-TBL are shown below.
As a result, it is clear that the shaded entries in the table CHK-SEM-NO, A001
and C003, are held on the same day.
(4) The printing format for the error listing is shown below.
Application Applicant Scheduled Seminar
No. No. date No.
XXXXX XXXXX XXXXXXXX XXXX XXXX XXXX XXXX
XXXXXXXX XXXX XXXX XXXX XXXX
XXXXX XXXXX XXXXXXXX XXXX XXXX XXXX XXXX
・
・ ・
・ ・
XXXXX XXXXX XXXXXXXX XXXX XXXX XXXX XXXX
XXXXX XXXXX XXXXXXXX XXXX XXXX XXXX XXXX
23
[Program]
DATA DIVISION.
FILE SECTION.
FD APPLY-FILE.
01 APPLY-REC.
02 APP-NO PIC X(05).
02 APP-PSN-NO PIC X(05).
02 APP-SEM-NO OCCURS 10 PIC X(04).
FD SEMINAR-FILE.
01 SEMINAR-REC.
02 SEM-NO PIC X(04).
02 SEM-YMD PIC X(08).
02 SEM-ROOM PIC X(10).
FD CHECK-FILE.
01 CHECK-REC PIC X(85).
WORKING-STORAGE SECTION.
01 INFILE-EOF PIC 9(01) VALUE 0.
01 PRINT-WRK.
02 PRI-NO PIC X(05).
02 PIC X(05).
02 PRI-PSN-NO PIC X(05).
02 PIC X(07).
02 PRI-YMD PIC X(08).
02 PIC X(01).
02 OCCURS 10.
03 PIC X(01).
03 PRI-SEM-NO PIC X(04).
01 CHK-TBL.
02 OCCURS 10.
03 CHK-NUM PIC 9(02).
03 CHK-YMD PIC X(08).
03 CHK-SEM-NO OCCURS 10 PIC X(04).
01 CHK-CNT PIC 9(02).
01 CHK-WK PIC 9(02).
01 CNT1 PIC 9(02).
01 CNT2 PIC 9(02).
01 CNT3 PIC 9(02).
PROCEDURE DIVISION.
MAIN-RTN.
OPEN INPUT APPLY-FILE SEMINAR-FILE OUTPUT CHECK-FILE.
PERFORM UNTIL INFILE-EOF = 1
READ APPLY-FILE AT END
MOVE 1 TO INFILE-EOF
NOT AT END
PERFORM CHECK-RTN
PERFORM PRINT-RTN
END-READ
END-PERFORM.
CLOSE APPLY-FILE SEMINAR-FILE CHECK-FILE.
STOP RUN.
24
CHECK-RTN.
INITIALIZE CHK-TBL CHK-CNT.
PERFORM VARYING CNT1 FROM 1 BY 1 UNTIL CNT1 > 10
OR APP-SEM-NO (CNT1) = SPACE
END-IF
END-PERFORM.
IF CNT3 = 0 THEN
COMPUTE CHK-CNT = CHK-CNT + 1
MOVE SEM-YMD TO CHK-YMD (CHK-CNT)
MOVE CHK-CNT TO CNT3
END-IF.
COMPUTE CHK-NUM (CNT3) = CHK-NUM (CNT3) + 1.
MOVE CHK-NUM (CNT3) TO CHK-WK.
MOVE APP-SEM-NO (CNT1) TO CHK-SEM-NO (CNT3 CHK-WK).
PRINT-RTN.
MOVE 0 TO CNT3.
PERFORM VARYING CNT1 FROM 1 BY 1 UNTIL
MOVE SPACE TO PRINT-WRK
IF THEN
IF CNT3 = 0 THEN
MOVE APP-NO TO PRI-NO
MOVE APP-PSN-NO TO PRI-PSN-NO
MOVE 1 TO CNT3
END-IF
MOVE CHK-YMD (CNT1) TO PRI-YMD
PERFORM VARYING CNT2 FROM 1 BY 1
UNTIL CNT2 > CHK-NUM (CNT1)
END-PERFORM
WRITE CHECK-REC FROM PRINT-WRK AFTER 1
END-IF
END-PERFORM.
25
Sub-question
From the answer groups below, select the correct answers to be inserted in the boxes
in the program.
26
Q11. Read the following description of an assembler program and the program itself, and then
answer sub-questions 1 and 2.
[Program Description]
This is a subprogram group that manages reserved seats in a movie theater. The movie
theater has 1,024 reserved seats, numbered from 0 to 1023. The subprograms include
INIT, which initializes the seat reservation table RSVTBL; RESERVE, which reserves a
seat; and CANCEL, which cancels a reserved seat. The structure of the seat reservation
table, which stores the status of each reserved seat, is shown in the figure below.
(1) The subprogram INIT sets all of the bits in the seat reservation table to the
“available” state.
(2) The subprogram RESERVE reserves one seat. The subprogram searches through the
seats, starting from seat 0, until it finds an “available” seat, and then changes the
status of that seat to “reserved” and stores the seat number in GR0. If all of the seats
are already reserved, the subprogram stores the value “1” in GR0.
(3) The subprogram CANCEL cancels the reservation of the seat number that is specified
by GR1. After confirming that the status of the specified seat is “reserved,” the
subprogram changes the status to “available.” If the cancellation processing ends
normally, the subprogram stores the value “0” in GR0. If there is an error in the seat
number specification, or if the seat specified by the seat number is already in the
“available” state, the subprogram stores the value “1” in GR0.
(4) Except for GR0, the contents of all the general-purpose registers that are used by the
subprograms are saved.
(5) The functions of the RPUSH and RPOP macro instructions used in the program are as
described below:
RPUSH : Saves the contents of GR1 through GR7 into the stack.
RPOP : Restores the contents of the stack into GR1 through GR7.
27
[Program]
MAIN START
·
·
·
28
AND GR0,GR3
JZE CERROR
; Inverts the bits
LD GR0,0,GR1
AND GR0,GR3
ST GR0,0,GR1
LAD GR0,0
JUMP CRET
CERROR LAD GR0,1
CRET RPOP
RET
;
RSVTBLSZ DC 64 ; Size of reservation table
RSVTBL DS 64 ; Reservation table
END
Sub-question 1
From the answer groups below, select the correct answers to be inserted in the boxes
in the program.
29
Sub-question 2
The locations labeled and in the program are changed as shown below. From the
answer group below, select the maximum number of reserved seats that can be handled by
this program as a result of this change.
Answer group:
a) 960 b) 1,440 c) 1,920
d) 2,400 e) 2,880
30
Assembly Language Specifications
(2) Main storage capacity is 65,536 words with address numbers 0 through 65,535.
(3) Numeric values are expressed as 16-bit binary numbers. Negative numbers are expressed in complements of two.
(4) Control is sequential. COMET II utilizes a one-word or two-word instruction word.
(5) The COMET II has four types of registers: GR (16 bits), SP (16 bits), PR (16 bits) and FR (3 bits).
There are eight GR (General Register) registers, GR0 through GR7. These eight registers are used for arithmetic, logical, compare and shift
operations. Of these, GR1 through GR7 are also used as index registers to modify addresses.
The stack pointer stores the address currently at the top of the stack.
The PR (Program Register) stores the first address of the next instruction.
The FR (Flag Register) consists of three bits: OF (Overflow Flag), SF (Sign Flag) and ZF (Zero Flag). The following values are set,
depending on the result generated by certain operation instructions. These values are referenced by conditional branch instructions.
When the result of an arithmetic operation instruction is out of the range of –32,768 to 32,767, the value is 1,
OF
and in other cases, the value is 0. When the result of a logical operation instruction is out of the range of 0 to
SF When the sign of the operation result is negative (bit number 15 = 1), the value is 1, and in other cases, the
value is 0.
ZF When the operation result is 0 (all bits are 0), the value is 1, and in other cases, the value is 0.
(6) Logical addition or logical subtraction: Treats the data to be added or subtracted as unsigned data, and performs addition or subtraction.
1.2 Instructions
Formats and functions of instructions are described in the following chart. When an instruction code has two types of operands, the upper
operand shows the instruction between registers and the lower operand shows the instruction between register and main storage.
Instruction Format FR
Description of instructions
Opcode Operand setting
(1) Load, store, load address instruction
r1,r2 r1 ← (r2)
LoaD LD *1
r,adr [,x] r ← (effective address)
STore ST r,adr [,x] Effective address ← (r)
Load ADdress LAD r,adr [,x] r ← effective address
(2) Arithmetic and logical operation instructions
r1,r2 r1 ← (r1) + (r2)
ADD Arithmetic ADDA
r,adr [,x] r ← (r) + (effective address)
r1,r2 r1 ← (r1) +L (r2)
ADD Logical ADDL
r,adr [,x] r ← (r) +L (effective address)
r1,r2 r1 ← (r1) (r2)
SUBtract Arithmetic SUBA
r,adr [,x] r ← (r) (effective address)
r1,r2 r1 ← (r1) L (r2)
SUBtract Logical SUBL
r,adr [,x] r ← (r) L (effective address)
r1,r2 r1 ← (r1) AND (r2)
AND AND
r,adr [,x] r ← (r) AND (effective address)
r1,r2 r1 ← (r1) OR (r2)
OR OR *1
r,adr [,x] r ← (r) OR (effective address)
r1,r2 r1 ← (r1) XOR (r2)
eXclusive OR XOR
r,adr [,x] r ← (r) XOR (effective address)
31
(3) Compare operation instructions
Performs an arithmetic compare or logical
r1,r2 compare operation on (r1) and (r2) or (r) and
(effective address), and sets FR as follows,
ComPare Arithmetic CPA according to the result of the compare operation.
r,adr [,x]
*1
r1,r2
32
Determine based on the effective address as the
SuperVisor Call SVC adr [,x] argument. After the execution, GR and FR are
undefined.
No OPeration NOP N/A
(Note) r, r1, r2 All of these represent GR. Values from GR0 to GR7 can be specified.
adr This represents the address. A value from 0 to 65,535 can be specified.
x This represents GR used as the index register. A value from GR1 to GR7 can be specified.
[ ] Square brackets ([ ]) indicate that the specification contained in the brackets may be
omitted.
Effective A value produced by adding, through "logical addition," adr and the contents of x, or the
← This means that the operation result is stored in the left part register or address.
+L, L Logical addition and logical subtraction.
setting *2 : Setting is performed, but the bit value sent from the register is set to OF.
(Note) [ ] Square brackets ([ ]) indicate that the specification contained in the brackets may be omitted.
33
Instruction
The description format is defined by instruction.
code
34
2.2 Instruction Types
CASL II consists of four assembler instructions (START, END, DS and DC), two macro instructions (IN and OUT) and machine language
instructions (COMET II instructions). The specifications are as follows:
Label START [Execution start address] Defines the starting address for execution of a
program.
Assembler
Defines the entry name for reference in other
instruction
programs.
END Defines the end of a program.
[label] DS Word length Allocates an area.
[label] DC Constant[, constant] Defines a constant.
[label] IN Input area, input Input character data from input devices.
Macro instruction
character length area
[label] OUT Output area, output Output character data from output devices.
character length area
Machine language [label] (See "1.2 Instructions")
instruction
(2) END
The END instruction defines the end of a program.
35
2.4 Macro Instructions
Macro instructions use a pre-defined group of instructions and operand data to generate a group of instructions that performs a desired
function (the word length is undefined).
2.6 Other
(1) The relative positions of the instruction words and areas generated by the assembler conform to the order of the descriptions in the assembly
language program. All DC instructions generated from literals are located just before the END instruction.
(2) The instruction words and areas that are generated occupy a continuous area in the main memory.
36