tables & arrays ch.9. single-level tables topic 1 page 225
TRANSCRIPT
Single-Level Table
Pay Class Pay Rate
01 4.21
02 4.39
03 4.58
04 4.77
05 4.97
06 5.17
07 5.38
08 5.60
09 5.81
10 6.03
PAYTABLE DS 0CL44 DC X’F0F1421C’ DC X’F0F2439C’ DC X’F0F3458C DC X’F0F4477C’ DC X’F0F5497C’ DC X’F0F6517C’ DC X’F0F7538C’ DC X’F0F8560C’ DC X’F0F8581C’ DC X’F1F0603C’ DC X’FFFFFFFF’
Another Coding Example
PAYTABLE DS 0CL44 DC C’01’ DC PL2’421’ DC C’02’ DC PL2’439’ DC C’03’ DC PL2’458’ DC C’10’ DC PL2’603’ DC X’FFFFFFFF’
p.226
*************************************************** * SEQUENTIAL SEARCH THE PAYRATE TABLE * *************************************************** OK LA 8,PAYTABLE ptr to pay table PACK HOURS,HRSWORKD hours worked SR 2,2 zero index reg FINDIT CLC 0(8),PAYCLASS found entry? BE FOUND yes CLC 0(8),X’FF’ end of table? BE NOENTRY yup – not found LA 8,4(8) check next entry B FINDIT loop til found ** FOUND ZAP PAYRATE,2(2,8) obtain payrate MP HOURS,PAYRATE calc total pay ** PAYCLASS DC C’06’ empl. pay class PAYRATE DS PL2 workarea DS 0F HOURS DS 0PL4 TOTPAY DS PL4 total pay PAYTABLE DS 0CL44 pay table DC X’F0F6517C’ 6th entry
But … Is all that really needed?
• Since the table variable (Payclass) is just a progression of numbers – we don’t really need that field–Save memory
–Save processing time
New Pay-table
PAYTABLE DS 0CL20 pay rate table DC PL2’421’ DC PL2’439’ DC PL2’458’ DC PL2’477’ DC PL2’497’ DC PL2’517’ DC PL2’538’ DC PL2’560’ DC PL2’581’ DC PL2’603’ DC XL2’FFFF’ end of table
Go Right to an Entry
p.229
************************************************* PACK HOURS,HRSWORKD hours worked CVB 4,HOURS * get PAYCLASS number we are looking for PACK WORKA(8),PAYCLASS(2) CVB 7,WORKA R7 = index reg SH 7,=H’1’ pt to right entry MH 7,TWO entry len = 2 * get PAYRATE from table using PAYCLASS as index
LH 5,PAYTABLE(7) get PAYRATE ST 5,WORKB+6 from PAYTABLE CVB 8,WORKB MR 8,4 payrate * hrs CVD 9, … convert back to char UNPK … PAYCLASS DC C’06’ empl. pay class PAYRATE DS PL2 workarea DS 0F HOURS DS PL8 from timecard TOTPAY DS PL4 total pay WORKA DS PL8 temp pay class WORKB DC D’0’ TWO DC H’2’ PAYTABLE DS 0CL22 pay table DC PL2’517C’ 6th entry
Men: Women:
Age Class 1 Class 2 Class 1 Class 2 18-34 $23.50 $27.05 $24.75 $28.45 35-39 24.00 27.55 25.80 29.50 40-44 24.60 28.15 27.10 30.80 45-49 25.30 28.85 29.10 32.80 50-54 26.30 29.85 31.55 35.25 55-59 28.00 31.55 35.00 38.70
Multi-level table (p.234)
Multi-level Table Defined
P.234
RATETAB DS 0CL112 INSURANCE RATE TABLE AGE1834 DC PL2’18’ Low age limit for group 1 DC PL2’34’ High age limit for group DC PL3’2350’ Class 1 rate for men (18-34) DC PL3’2705’ Class 2 rate for men DC PL3’2475’ Class 1 rate for women (18-34) DC PL3’2845’ Class 2 rate for women AGE3539 DC PL2’35’ Low age limit for group 2 DC PL2’39’ High age limit DC PL3’2400’ Class 1 rate for men (34-39) DC PL3’2755’ Class 2 rate for men DC PL3’2580’ Class 1 rate for women (34-39) DC PL3’2950’ Class 2 rate for women AGE4044 DC PL2’40’ Low age limit for men (40-44) -- -- ENDTAB DC PL2’99’ Low age limit for EOT test
LA 7,RATETAB PACK AGEWRK,INPAGE from input rec. CP AGEWRK,0(2,7) first entry BL AGEERR age < 18 is error AGELOOP CP 0,(2,7),=P’99’ end of table? BE AGEERR age > 99 is error CP AGEWRK,2(2,7) high age limit BNH AGEFOUND LA 7,16(7) pt to next entry B AGELOOP AGEFOUND LA 7,4(7) pt to men-class1 CLI INPSEX,C’M’ male? BE MALE yup! LA 7,6(7) pt to women rates MALE CLI INPJOBCL,C’1’ class 1 (m/f) BE RATEFND LA 7,3(7) must be class 2 RATEFND ZAP RATEWRK,0(3,7) get class 2 rate
Search the table… p.235
Tonight’s Problem
• Write an assembler program to perform a sequential search of a single-level table for specific entries.
• See the complete assignment on the h:drive
• Due date: next Thursday