1 /*
  2 
  3           The procedure cobol_start_gen generates code which realizes the COBOL
  4 start statement.
  5 
  6           START fn id eos
  7 
  8                     eos       b=0       no INVALID
  9                                  1      INVALID
 10 
 11                               a=000     no KEY
 12                                 001     KEY
 13 
 14                               d=00      =
 15                                 01      >=
 16                                 10      >
 17 
 18                               e         key number
 19 
 20                               f=00      no NOT
 21                                 01      NOT
 22 
 23           1 mp based(mp_ptr)
 24           2  n      fixed bin
 25           2  pt(0 refer(mp.n)) ptr
 26 
 27                     pt(1)     type-1("START")
 28                     pt(2)     type-12(file-name)
 29                     pt(3)     type-9(key, if end_stmt.a="1"b)
 30                     pt(n)     type-19(eos)
 31 
 32 Flow Chart
 33 
 34 TAG(ioerror.retry_tag):
 35 
 36           OP21(init_start,ntag);GEN_IOERROR
 37 
 38 TAG(ntag):
 39 
 40           if        file_table.external
 41                     |
 42                     file_table.open_out
 43 
 44           then      do;       INCR_NTAG
 45 
 46                               OP54(delete_error,ntag);GEN_IOERROR
 47 
 48 TAG(ntag):
 49 
 50                     end;
 51 
 52           alt_sw =  file_table.organization = 3
 53                     &
 54                     file_table.alternate_keys ^= 0
 55 
 56           seek_head_sw = "0"b
 57 
 58           if end_stmt.a ^= "0"b
 59           then      do;       if end_stmt.d = "00"b
 60                               then      if        WHOLE_KEY
 61                                         then;
 62                                         else      seek_head_sw = "1"b;
 63                               else      seek_head_sw = "1"b;
 64                     end;
 65 
 66           MOVE_KEY_TO_FSB
 67 
 68           if        ^seek_head_sw
 69           then      do;       if alt_sw then call alt_start
 70 
 71                               INCR_NTAG
 72 
 73                               SET_FSBPTR;OP67(read_seek_key,ntag);GEN_IOERROR
 74 
 75 TAG(ntag):
 76                     end;
 77           else      do;       if alt_sw then call alt_start
 78 
 79                               INCR_NTAG
 80 
 81                               SET_FSBPTR;
 82                               if alt_sw
 83                               then OP83(alt_start_control,ntag);
 84                               else OP23(start_control,ntag);
 85                               GEN_IOERROT;
 86 
 87 TAG(ntag):
 88                     end;
 89 
 90 
 91           if alt_sw then IO_UTIL$FILE_DESC;OP79(alt_start,0)
 92 
 93           return;
 94 
 95 alt_start:          proc;
 96 
 97           IO_UTIL$FILE_DESC
 98           IO_UTIL$KEY_NUM
 99           OP82(alt_seek_key,0)
100 
101 end;
102 
103 */
104 
105 %include cobol_opr_start;
106