?login_element?

Subversion Repositories NedoOS

Rev

Rev 634 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;
  2. ; cc2e.asm:
  3. ; Non-text utility routines:
  4. ;
  5.  
  6. ;
  7. ; Complement HL register:
  8. ; (Good 'ole simple subroutine. Aint too many like this one
  9. ;  around anymore...)
  10. ;
  11.  
  12. cmh:    push af
  13.         ld a,h
  14.         cpl
  15.         ld h,a
  16.         ld a,l
  17.         cpl
  18.         ld l,a
  19.         inc hl
  20.         pop af
  21.         ret
  22.  
  23. ;
  24. ; Generate a new label number:
  25. ;
  26.  
  27. glbl:   lhld lbln
  28.         inc hl
  29.         shld lbln
  30.         dec hl
  31.         ret
  32.  
  33. ;
  34. ; Get a label and put it in sr0:
  35. ;
  36.  
  37. glblr0: push hl
  38.         call glbl
  39.         shld sr0
  40.         pop hl
  41.         ret
  42.  
  43.  
  44. ;
  45. ; Given symbol number in HL, assume that the given
  46. ; st entry is a structure, and return the size of
  47. ; the structure in HL. Note that if the value has
  48. ; high order byte set to FF, then the structure was
  49. ; never properly defined and using it constitutes an
  50. ; error.
  51. ;
  52.  
  53. getsz:  push de
  54.         add hl,hl
  55.         add hl,hl
  56.         add hl,hl
  57.         ld de,st+4
  58.         add hl,de
  59.         ld a,(hl)
  60.         inc hl
  61.         ld h,(hl)
  62.         ld l,a
  63.         pop de
  64.         ld a,h
  65.         cp 255
  66.         ret nz
  67.         push de
  68.         ld de,stg17a
  69.         call perr
  70.         pop de
  71.         ret
  72.  
  73. ;
  74. ; Generate a byte of code given in A:
  75. ;
  76.  
  77. genb:   push af
  78.         call genb1
  79.         pop af
  80.         ret
  81.  
  82. genb1:  push hl
  83.         push bc
  84.         ld b,a          ;save byte in B
  85.         lda codflg      ;code generation enabled?
  86.         or a
  87.         jp z,genb3      ;return if not
  88.         lhld pshpp      ;need to push some prior value
  89.         ld a,(hl)
  90.         and 0a0h        ; in a register?
  91.         call nz,genpsh  ;if so, go do it.
  92.         lhld codp
  93.         ld (hl),b
  94.         inc hl
  95.         shld codp
  96.  
  97. ;
  98. ; Check for memory overflow:
  99. ;
  100.  
  101. genb1a: lda cdp+1       ;get high byte of CCI text ptr
  102.         ld l,a
  103.         ld a,h          ;get high byte of code area pointer
  104.         cp l            ;less than CCI pointer?
  105.         jp c,genb3
  106.  
  107.         if 1==0
  108.         IF MARC
  109.         lda maxmd       ;maxmem call done?
  110.         or a
  111.         jp z,genb2      ;if not, go try it...
  112.         ENDIF
  113.  
  114.         IF CPM
  115.         lda ccpok       ;CCP still intact?
  116.         or a
  117.         jp nz,genb2     ;if so, go get rid of it
  118.         ENDIF
  119.         endif
  120.  
  121. genb1b: ld de,stgom     ;if all that can be done has been done, error...
  122.         jp perrab
  123.        
  124.         if 1==0
  125. ;
  126. ; Now get more memory by calling maxmem (MARC) or overwriting the shell (CP/M):
  127. ;
  128.  
  129. genb2:
  130.         IF CPM
  131.         xor a
  132.         sta ccpok       ;CCP not intact anymore
  133.         push de
  134.         push hl
  135.         call nudge      ;lde code up a bit
  136.  
  137.         ld hl,NEDOOSMEMTOP;lhld bdosp
  138.         ld l,0
  139.         shld curtop     ;new current top of memory
  140.         pop hl
  141.         pop de
  142.         ENDIF
  143.         endif
  144.  
  145. genb3:  pop bc          ;wrap up and return
  146.         pop hl
  147.         ld a,b
  148.         ret
  149.  
  150.         if 1==0
  151. ;
  152. ; lde cci text up into the memory space just vacated by making
  153. ; the shell go away:
  154. ;
  155.  
  156. nudge:  lhld cdp        ;compute size of block to be lded
  157.         call cmh
  158.         ex de,hl
  159.         lhld curtop     ;get EOF address in HL
  160.         dec hl
  161.         dec hl          ;this was the destination of the "mvup" lde
  162.         add hl,de               ;subtract starting address
  163.         inc hl          ;add one to get block size
  164.  
  165.         ld b,h          ;lde to BC
  166.         ld c,l
  167.  
  168.         ld hl,NEDOOSMEMTOP;lhld bdosp   ;put destination address in DE
  169.         ld l,0
  170.  
  171.         dec hl
  172.         push hl         ;save for later computations
  173.         ex de,hl
  174.         lhld curtop     ;put eof address (source area pointer) in HL
  175.         dec hl
  176.         dec hl
  177.         ld a,2          ;check if we're on a Z80 or 8080
  178.         inc a
  179.         jp pe,nudge80
  180.         db 0edh, 0b8h   ;Z80: do block lde     
  181.         jp nudge2
  182.  
  183. nudge80:ld a,(hl)
  184.         ld (de),a
  185.         dec hl
  186.         dec de
  187.         dec bc
  188.         ld a,b
  189.         or c
  190.         jp nz,nudge80  
  191.        
  192. nudge2: pop de          ;pop curtop-1 into DE
  193.         lhld curtop     ;get old eof address
  194.         dec hl
  195.         dec hl
  196.         call cmh
  197.         add hl,de               ;HL now equals the offset for the block lde.
  198.         ex de,hl                ;put offset in DE
  199.         lhld cdp        ;bump cdp by the offset
  200.         add hl,de
  201.         shld cdp
  202.         lhld stgad      ;and bump the string address by the offset
  203.         add hl,de
  204.         shld stgad
  205.         ret             ;all done
  206.         endif
  207.  
  208.  
  209. ;
  210. ; This is the main code generation routine. Given a macro pointed
  211. ; to by DE, it decodes special bytes and uses the genb routine to
  212. ; actually generated bytes of code:
  213. ;
  214.  
  215. mcrog:  push af
  216.         call mcrog1
  217.         pop af
  218.         ret
  219.  
  220. mcrog1: lda codflg      ;code generation enabled?
  221.         or a
  222.         ret z           ;if not, don't generate any code!
  223.         push hl
  224.         push bc
  225. mg1:    ld a,(de)
  226.         cp 38h          ;end of macro?
  227.         jp nz,mg1a
  228.         pop bc          ;yes. return.
  229.         pop hl
  230.         ret
  231.  
  232. mg1a:   cp 0cbh ;code to enter relocation parameter
  233.         jp nz,mg2               ;for current code location?
  234.         call entr       ;yes. Enter in ref table
  235.         inc de          ;and go for next macro byte.
  236.         jp mg1
  237.  
  238. mg2:    cp 0efh ;code to enter symbolic reference?
  239.         jp nz,mg2a
  240.         call entr       ;yes. Enter relocation parameter
  241.         inc de          ;get following sr code
  242.         ld a,(de)
  243.         push de         ; (note: sr means `special register')
  244.         call tstsr
  245.         call cnvsr      ;get the value in the sr
  246.         ex de,hl
  247.         call entrf      ;and enter symbolic reference
  248.         pop de          ;restore macro text pointer
  249.         jp mg1          ;and go for next byte
  250. mg2a:   cp litrl        ;do we take the next 2 bytes literally?
  251.         jp nz,mg3
  252.  
  253.         push hl
  254.         push bc
  255.         inc de          ;yes. get them, add them to cccadr and generate...
  256.         ld a,(de)
  257.         ld c,a
  258.         inc de
  259.         ld a,(de)
  260.         ld b,a
  261.         lhld cccadr
  262.         add hl,bc
  263.         ld a,l
  264.         call genb
  265.         ld a,h
  266.         call genb
  267.         pop bc
  268.         pop hl
  269.  
  270.         inc de
  271.         jp mg1
  272.  
  273.                
  274. mg3:    call tstsr      ;sr code?
  275.         jp c,mg4
  276.         push de         ;yes. Convert to value in sr and generate
  277.         call cnvsr
  278.         ld a,l
  279.         call genb
  280.         ld a,h
  281.         call genb
  282.         pop de
  283.         inc de
  284.         jp mg1
  285.  
  286. mg4:    ld b,a          ;symbolic label definition?
  287.         or 38h
  288.         inc a
  289.         ld a,b
  290.         jp nz,mg6
  291.         cp 0e8h
  292.         jp nc,mg6               ;yes. Figure out which sr to get label
  293.         ccf             ;value from...
  294.         rra
  295.         rra
  296.         rra
  297.         and 7
  298.         push de
  299.         call cnvsr      ;get the value
  300.         ex de,hl
  301.         call entl       ;enter in label table
  302.         pop de
  303.         inc de
  304.         jp mg1
  305.  
  306. mg6:    call genb       ;if none of the above, take the
  307.         inc de          ;value literally
  308.         jp mg1
  309.  
  310. ;
  311. ; Tests if the value in A is a special register (sr) code; i.e.,
  312. ;  8 or 10h or 18h or 20h or 28h or 30h.
  313. ; If not, returns C set.
  314. ; If so, return 0 for sr0, 1 for sr1, 2 for sr2, etc.
  315. ;
  316.  
  317. tstsr:  ld b,a
  318.         and 38h
  319.         cp b
  320.         ld a,b
  321.         scf
  322.         ret nz
  323.         or a
  324.         scf
  325.         ret z
  326.         cp 31h
  327.         ccf
  328.         ret c
  329.         rra
  330.         rra
  331.         rra
  332.         dec a
  333.         ret
  334.  
  335. ;
  336. ; Given A equal to the return value of a successful tstsr
  337. ; call, returns (in HL) the value of the corresponding sr:
  338. ;
  339.  
  340. cnvsr:  push de
  341.         ld e,a
  342.         ld d,0
  343.         ld hl,sr0
  344.         add hl,de
  345.         add hl,de
  346.         ld a,(hl)
  347.         inc hl
  348.         ld h,(hl)
  349.         ld l,a
  350.         pop de
  351.         ret
  352.  
  353. ;
  354. ; Enters the value of the code-generation PC into the relocation
  355. ; table, so that a relocation parameter gets generated for the
  356. ; location:
  357. ;
  358.  
  359. entr:   push hl
  360.         push de
  361.         ;jr $
  362.         lhld cdstrt
  363.         call cmh
  364.         ex de,hl
  365.         lhld codp
  366.         add hl,de
  367.         ex de,hl
  368.         lhld relp
  369.         ld (hl),e
  370.         inc hl
  371.         ld (hl),d
  372.         inc hl
  373.         shld relp
  374.         lhld relc
  375.         inc hl
  376.         shld relc
  377.         pop de
  378.         pop hl
  379.         ret
  380.  
  381. ;
  382. ; Enters the current code generation PC as the value for the
  383. ; symbolic label given in DE:
  384. ;
  385.  
  386.  
  387. entl:   push hl
  388.         push de
  389.         lhld lblp
  390.         ld (hl),e
  391.         inc hl
  392.         ld (hl),d
  393.         inc hl
  394.         ex de,hl
  395.         lhld codp
  396.         ex de,hl
  397.         push hl
  398.         lhld cdstrt
  399.         call cmh
  400.         add hl,de
  401.         ex de,hl
  402.         pop hl
  403.         ld (hl),e
  404.         inc hl
  405.         ld (hl),d
  406.         inc hl
  407.         shld lblp
  408.         lhld lblc
  409.         inc hl
  410.         shld lblc
  411.         pop de
  412.         pop hl
  413.         ret
  414.  
  415. ;
  416. ; Enters, in the symbol reference table, a reference
  417. ; to the symbolic label given in DE:
  418. ;
  419.  
  420. entrf:  push hl
  421.  
  422.         push de         ;save label code
  423.         ld hl,0         ;check for table overflow by seeing
  424.         add hl,sp               ;if the ref table pointer has approached
  425.         ex de,hl                ;the stack...
  426.         lhld lbrp
  427.         push hl
  428.         inc hl          ;if lbrp+4 isn't greater than the current SP,
  429.         inc hl          ;then complain and abort.
  430.         inc hl
  431.         inc hl
  432.         call checkb     ;this function checks HL against DE (HL must be < DE)f
  433.         pop hl          ;no problem.   
  434.         pop de          ;restore label code and go ahead with the table entry
  435.  
  436.         ld (hl),e
  437.         inc hl
  438.         ld (hl),d
  439.         inc hl
  440.         ex de,hl
  441.         lhld codp
  442.         ex de,hl
  443.         ld (hl),e
  444.         inc hl
  445.         ld (hl),d
  446.         inc hl
  447.         shld lbrp
  448.         lhld lbrc
  449.         inc hl
  450.         shld lbrc
  451.         pop hl
  452.         ret
  453.  
  454. ;
  455. ; Process a function:
  456. ;
  457.  
  458. dofun:  ld hl,pshptb    ;initialize pushop table so genb's won't
  459.         shld pshpp      ;cause stray D5's and E5's all over
  460.         ld (hl),0               ;the place during pre-statement code generation!
  461.  
  462.         call idir       ;insert the name in the directory
  463.         call ifun       ;build the list of needed function names
  464.         ld hl,relt      ;initialize the relocation parameter table
  465.         shld relp
  466.         ld hl,lblt      ;and the label definition table
  467.         shld lblp
  468.         ld hl,lbrt      ;and the label reference table
  469.         shld lbrp
  470.  
  471.         ld hl,0
  472.         shld relc       ;and the relocation parameter count,
  473.         shld lblc       ;       the label count,
  474.         shld lbrc       ;       and the label reference count.
  475.         shld strtb      ;and clear the string table
  476.  
  477.         lhld codp       ;do some more nitty-gritty initialization
  478.         shld modsa      ;to make the crufty flush routine work
  479.         inc hl          ;correctly (once it did, I completely forgot
  480.         inc hl          ;how it works and don't know what most of these
  481.         shld codp       ;values do. And it really doesn't matter anyway...)
  482.         call insjl      ;insert the jump vector list.
  483.         call paslst     ;pass formal parameter list
  484.         call fentry     ;generate upon-entry-to-function code segment
  485.         call glbl       ;get function-exit location label
  486.         shld fexlab     ;save for use by "return" processor
  487.         lhld cdp
  488.         call igsht
  489.         cp lbrcd        ;function body begin with a `{' ?
  490.         jp z,dofun1     ;if so, Ok
  491.  
  492.         ld de,stgmlb    ;else bitch
  493.         call perr
  494.  
  495. dofun1: call state0     ;generate code for the body of the function (actually
  496.         shld cdp        ;  a function is just a big compound statement)
  497.         call fexit      ;generate exit code
  498.         call flshst     ;flush string texts onto end of the function
  499.         call cktbf      ;check for table overflows
  500.         call rslvl      ;resolve label references
  501.         lhld cdstrt
  502.         call cmh
  503.         ex de,hl
  504.         lhld codp
  505.         add hl,de               ;get length of function code
  506.         ex de,hl                ;put into DE
  507.         lhld modsa      ;store following list of needed functions
  508.         ld (hl),e
  509.         inc hl
  510.         ld (hl),d
  511.         call insrd      ;and append relocation parameter list
  512.         ret
  513.  
  514. ;
  515. ; Pass formal parameter list:
  516. ;
  517.  
  518. paslst: lhld cdp
  519.         call igsht
  520.         cp varcd
  521.         call nz,ierror
  522.         inc hl
  523.         inc hl
  524.         inc hl  ;pass over function name
  525.         call igsht
  526.         inc hl          ;pass over open paren
  527.         xor a
  528.         sta nofrmls     ;clear no-formals flag
  529.         call igsht      ;first thing a close paren?
  530.         cp close
  531.         jp nz,pasl2
  532.         sta nofrmls     ;yes: set no-formals flag to optimize entry code
  533. pasl0:  call igsht
  534. pasl1:  cp close        ;close paren (end of arg list)?
  535.         jp nz,pasl2
  536.         inc hl          ;yes. pass it and return.
  537.         call igsht
  538.         shld cdp
  539.         ret
  540.  
  541. pasl2:  call lookup
  542.         cp comma        ;if not comma,
  543.         jp nz,pasl1     ;check for close
  544.         inc hl
  545.         jp pasl0
  546.  
  547. ;
  548. ; Generate code to handle function entry (this goes at top of
  549. ; every function to allocate local stack space and set new BC,
  550. ; saving old BC on stack:
  551. ;
  552.  
  553. fentry: ld de,mfntry
  554.         lhld sfsiz      ;null stack frame size?
  555.         ld a,h
  556.         or l
  557.         jp nz,fntry2    ;if not, go handle that case.
  558.  
  559.         lda nofrmls     ;we have null frame. null formal param list also?
  560.         or a
  561.         ret nz          ;if so, don't generate any code
  562.         ld de,mfntr2    ;else like normal, except no "ld sp,hl" (big deal)
  563. ;       jp fntry3       ;go try for -z optimized entry sequence
  564.         jp fntry4       ;woops...doesn't quite work if sfsiz = 0; do bulky
  565.  
  566. fntry2: ld a,h          ;ok, we have at least some stack frame to deal with
  567.         or a            ;more than 255 bytes?
  568.         jp nz,fntry4    ;if so, handle with normal bulky code sequence
  569.  
  570. fntry3: lda optimf      ;doing function entry optimization?
  571.         and 1
  572.         jp z,fntry4     ;if not, go handle with normal code sequence   
  573.  
  574.         ld a,0cfh       ;else generate rst 1 followed by negated
  575.         call genb       ;       8-bit stack offset
  576.         ld a,l
  577.         cpl    
  578.         inc a
  579.         call genb
  580.         ret
  581.  
  582. fntry4: call cmh
  583.         shld sr0
  584.         call mcrog
  585.         ret
  586.  
  587.  
  588. ;
  589. ; Generate function exit code (this goes at end of every function
  590. ; to de-allocate local stack space and restore old BC):
  591. ;
  592.  
  593. inxsp:  equ 33h         ;"inc sp" op
  594.  
  595. fexit:  lhld fexlab     ;ready to define exit sequence label
  596.         shld sr1
  597.  
  598.         ld de,mfex1     ;define exit label
  599.         call mcrog
  600.  
  601.         lhld sfsiz      ;set up stack size to reset SP
  602.         shld sr0
  603.  
  604.         ld a,h
  605.         or l            ;was stack frame size 0?
  606.         jp nz,fexit2    ;if so, go handle simple cases
  607.  
  608.         ld de,mfex4     ;OK, frame size is 0...
  609.         lda nofrmls     ;null formal parameter list?
  610.         or a
  611.         jp nz,mcrog     ;if so, use trivial exit sequence
  612.  
  613.         ld de,mfex3     ;0 frame size w/formal parms exit sequence
  614.         jp mcrog
  615.  
  616. fexit2: ld de,mfex2     ;non-0 frame size.
  617.         ld a,h          ;frame size > 255?
  618.         or a
  619.         jp nz,mcrog     ;if so, handle with bulky exit sequence
  620.  
  621.         lda optimf      ;-z optimizing exit sequence
  622.         and 2  
  623.         jp z,fexit3     ;if not, use in-line code
  624.         ld a,0d7h       ;rst 2
  625.         call genb
  626.         ld a,l          ;SP offset value
  627.         call genb
  628.         ret
  629.  
  630. fexit3: ld de,6         ;cmpdh compares d to h
  631.         call cmpdh      ;return Cy set if stack size less than 7
  632.         ld de,mfex2
  633.         jp c,mcrog      ;if frame size >= 7, go do long exit sequence
  634.        
  635. fexit4: ld a,inxsp      ;generate "inc sp" n times, where n is stack
  636.         call genb       ;frame size
  637.         dec l
  638.         jp nz,fexit4
  639.         ld de,mfex3     ;generate final pop bc and return
  640.         call mcrog
  641.         ret
  642.  
  643. ;
  644. ; Flush string constants that have been built up in strtb
  645. ; onto the tail end of the function:
  646. ;
  647.  
  648. flshst: ld hl,strtb
  649. flst1:  ld e,(hl)               ;get label code (or terminating 0000)
  650.         inc hl
  651.         ld d,(hl)
  652.         inc hl
  653.         ld a,d          ;all done?
  654.         or e
  655.         ret z           ;if so, return
  656.         call entl       ;else register the label code for this string
  657.         ld e,(hl)               ;get text pointer into DE
  658.         inc hl
  659.         ld d,(hl)
  660.         inc hl
  661.         ld a,(de)               ;get length byte
  662.         ld b,a          ;store in B
  663.         inc b
  664. flst3:  dec b           ;done with body of text?
  665.         jp z,flst4
  666.         inc de          ;no. get and generate next byte
  667.         ld a,(de)
  668.         call genb
  669.         jp flst3
  670.  
  671. flst4:  xor a           ;generate trailing null byte
  672.         call genb
  673.         jp flst1        ;and go for next string
  674.  
  675.  
  676. ;
  677. ; This routine looks at all the table pointers and
  678. ; makes sure we didn't have an overflow; if we did,
  679. ; complain and abort.
  680. ;
  681.  
  682. cktbf:
  683.         ld de,lblt
  684.         lhld relp
  685.         call checkb     ;check that HL < DE
  686.         ld de,lbrt
  687.         lhld lblp
  688.         call checkb
  689.         ret             ;no overflows.
  690.  
  691. checkb: ld a,h
  692.         cp d
  693.         ret c
  694.         jp nz,ftberr
  695.         ld a,l
  696.         cp e
  697.         ret c
  698. ftberr: call pmodnc
  699.         ld de,stgftb
  700.         call pstg
  701.         lhld namsav     ;print name of bad function
  702. pnamlp: ld a,(hl)
  703.         cp 9dh          ;main?
  704.         jp z,pmain      ;if so, handle specially
  705.         and 7fh
  706.         call outch
  707.         ld a,(hl)
  708.         inc hl
  709.         or a
  710.         jp p,pnamlp
  711.  
  712. pnam2:
  713.         ld de,stgtb2    ;print rest of message
  714.         call pstg
  715.         jp errab        ;and abort
  716.  
  717. ;
  718. ; The representation of "main" is a keyword, so we
  719. ; have to kludge it:
  720. ;
  721.  
  722. pmain:  ld de,stgmn
  723.         call pstg
  724.         jp pnam2
  725.  
  726. stgmn:  db 'main',0
  727.  
  728.  
  729. ;
  730. ; Enter the name of the function in the CRL directory:
  731. ;
  732.  
  733. idir:   lhld nlcnt
  734.         push hl
  735.         lhld cdp
  736.         call igsht
  737.         cp varcd
  738.         call nz,ierror
  739.  
  740.         push hl         ;initialize for Kirkland interrupt generation
  741.         lhld nlcnt
  742.         shld kblin      ;save line number where function begins
  743.         ld hl,0
  744.         shld kllin      ;null out last line value
  745.         pop hl
  746.  
  747.         inc hl
  748.         ld e,(hl)
  749.         inc hl
  750.         ld d,(hl)
  751.         pop hl
  752.         shld nlcnt
  753.         push de
  754.         call lookp2
  755.         xor a
  756.         sta ftypec
  757.         lda indc1
  758.         or a
  759.         jp nz,idirz
  760.         lda typ1
  761.         and 7
  762.         jp nz,idirz
  763.         inc a
  764.         sta ftypec
  765.  
  766. idirz:  lhld fntb
  767.         pop de
  768.         call ifntf
  769.         ex de,hl
  770.         lhld dirp
  771.         shld namsav     ;save pointer to name of function
  772. idir1:  ld a,(de)
  773.         call mapuc
  774.         ld (hl),a
  775.         inc hl
  776.         inc de
  777.         or a
  778.         jp p,idir1
  779.  
  780.         push hl
  781.         lhld codp
  782.         ex de,hl
  783.         lhld cdao
  784.         add hl,de
  785.         ex de,hl
  786.         pop hl
  787.         ld (hl),e
  788.         inc hl
  789.         ld (hl),d
  790.         inc hl
  791.         shld dirp
  792.         ld de,endir-3
  793.         call cmpdh      ;return Cy set if DE < HL
  794.         ld de,s2a       ;directory overflow
  795.         call c,perrab
  796.         ld h,b
  797.         ld l,c
  798.         add hl,hl
  799.         add hl,hl
  800.         add hl,hl
  801.         ld de,st+2
  802.         add hl,de
  803.         ld a,(hl)
  804.         inc hl
  805.         ld h,(hl)
  806.         ld l,a
  807.         shld sfsiz
  808.         ret
  809.  
  810. ifntf:  ld c,(hl)
  811.         inc hl
  812.         ld b,(hl)
  813.         inc hl
  814.         ld a,b
  815.         cp d
  816.         jp nz,ifnf2
  817.         ld a,c
  818.         cp e
  819.         ret z
  820. ifnf2:  ld a,(hl)
  821.         inc hl
  822.         or a
  823.         jp p,ifnf2
  824.         jp ifntf
  825.  
  826. ;
  827. ; Generate list of needed function names by going through
  828. ; the symbol table and sticking in the name of any function
  829. ; reference whose entry number is the same as that for the
  830. ; current function being processed:
  831. ;
  832.  
  833. ifun:   ld hl,st
  834.         shld stmp
  835.         ld hl,relt
  836.         shld relp
  837.         ld b,0
  838.         lhld stno
  839.         ex de,hl
  840. ifun1:  ld a,d
  841.         or e
  842.         jp z,ifun2
  843.         lhld stmp
  844.         ld a,(hl)
  845.         inc hl
  846.         and 3
  847.         cp 3
  848.         jp nz,ifun3
  849.         lda entn
  850.         ld c,a
  851.         ld a,(hl)
  852.         and 3fh
  853.         cp c
  854.         jp z,ifuni
  855.  
  856. ifun3:  push de
  857.         ld de,7
  858.         add hl,de
  859.         shld stmp
  860.         pop de
  861.         dec de
  862.         jp ifun1
  863.  
  864. ifun2:  lhld relp
  865.         ld (hl),0
  866.         inc hl
  867.         ld a,b
  868.         sta nfns
  869.         ex de,hl
  870.         ld hl,relt
  871.         call cmh
  872.         add hl,de
  873.         ld b,h
  874.         ld c,l
  875.         ld de,relt
  876.  
  877. ifun4:  ld a,(de)
  878.         call genb
  879.         inc de
  880.         dec bc
  881.         ld a,b
  882.         or c
  883.         jp nz,ifun4
  884.         ret
  885.  
  886. ifuni:  push hl
  887.         push de
  888.         lhld stno
  889.         ex de,hl
  890.         call cmh
  891.         add hl,de
  892.         ex de,hl
  893.         lhld fntb
  894.         push bc
  895.         call ifntf
  896.         ld a,(hl)
  897.         cp 9dh
  898.         jp z,ifuni3
  899.         ex de,hl
  900.         lhld relp
  901. ifuni2: ld a,(de)
  902.         call mapuc
  903.         ld (hl),a
  904.         inc hl
  905.         inc de
  906.         or a
  907.         jp p,ifuni2
  908.         shld relp
  909. ifuni3: pop bc
  910.         inc b
  911.         pop de
  912.         pop hl
  913.         jp ifun3
  914.  
  915. ;
  916. ; Insert a "jp 0" for each function in the list of needed functions:
  917. ;
  918.  
  919. insjl:  lhld codp
  920.         shld cdstrt
  921.         call glbl
  922.         push hl
  923.         shld sr0
  924.         lda nfns        ;if no functions, don't generate the
  925.         or a            ;  jump around non-existent jump list.
  926.         jp z,insjl2
  927.         ld de,mac37     ;generate jp around jump list
  928.         call mcrog
  929.         lda nfns
  930.  
  931. insj1:  push af
  932.         ld de,mac38
  933.         call mcrog      ;generate dummy jp instruction, the
  934.         pop af          ;operand of which is later filled in
  935.         dec a           ;by CLINK
  936.         jp nz,insj1
  937. insjl2: pop hl
  938.         ex de,hl
  939.         call entl       ;define beginning of actual function code
  940.         ret
  941.  
  942. ;      
  943. ; Generate the code for a single C statment (may be a single COMPOUND
  944. ; statment, of course) pointed to by HL:
  945. ;
  946.  
  947. levno:  ds 1
  948.  
  949. state0: xor a
  950.         sta levno       ;level number, so we know when at top level
  951.  
  952. state:  call igsht      ;pass by crap
  953.         cp lblcd        ;is it a label code?
  954.         jp z,st1
  955.  
  956.         cp labrc
  957.         jp nz,st2
  958.         call ierror     ;call, but never to return...
  959.  
  960. st1:    inc hl          ;yes. enter it into the label table
  961.         ld e,(hl)
  962.         inc hl
  963.         ld d,(hl)
  964.         inc hl
  965.         call entl
  966.         jp state        ;and go for the REAL statment
  967.  
  968. st2:    cp lbrcd        ;left curly-bracket?
  969.         jp nz,st4
  970.        
  971.         lda levno       ;bump level count
  972.         inc a
  973.         sta levno
  974.  
  975.         inc hl          ;yes. Keep doing statements until
  976. st2a:   call igsht      ;a matching right curly-bracket is found...
  977.         cp rbrcd
  978.         jp nz,st3
  979.         lda levno       ;debump level number
  980.         dec a
  981.         sta levno
  982.         inc hl          ;found it. all done.
  983.         ret
  984.  
  985. st3:    call state      ;inside curly brackets. Do a statement
  986.         jp st2a ;and loop
  987.  
  988. st4:    cp semi ;null statement?
  989.         jp nz,stgoto
  990.         inc hl          ;yes.
  991.         ret             ;don't do much in that case.
  992.  
  993. kirkli: push af ;save PSW while we take care of kirkland interrupt
  994.         lda cdbflg
  995.         or a
  996.         jp z,kirkdn     ;if not in Kirkland mode, don't generate interrupt
  997.  
  998.         push bc         ;save BC
  999.         push hl         ;save HL
  1000.         rlca            ;rotate interrupt number into bits 3-5
  1001.         rlca
  1002.         rlca
  1003.         or 0c7h ;make into restart op
  1004.         call genb       ;and generate the restart
  1005.  
  1006.         lhld kllin      ;get last line that had interrupt generated
  1007.         ex de,hl                ;put in DE
  1008.         lhld nlcnt      ;get current line number in HL
  1009.         call cmpdh      ;still on same current line?
  1010.         ld a,0
  1011.         jp nz,dok3      ;if not, clear count
  1012.         lda klcnt       ;else bump count of interrupts on this line
  1013.         inc a
  1014. dok3:   sta klcnt       ;save current line interrupt count
  1015.         shld kllin      ;make current line the last interrupt line     
  1016.        
  1017.         ex de,hl                ;put current line in DE
  1018.         lhld kblin      ;get function starting line
  1019.         call cmh        ;subtract from current line
  1020.         add hl,de
  1021.         inc hl          ;and bump for true line number (first = 1)
  1022.         ld a,l
  1023.         call genb       ;generate line number word
  1024.         lda klcnt       ;get current line interrupt count
  1025.         rlca            ;put in high order 4 bits
  1026.         rlca
  1027.         rlca
  1028.         rlca
  1029.         and 0f0h        ;keep only high bits
  1030.         add h           ;add to line number's high order byte
  1031.         call genb       ;and send it out
  1032.         pop hl          ;restore registers
  1033.         pop bc
  1034. kirkdn: pop af
  1035.         ret
  1036.  
  1037. stgoto: cp gotcd        ;goto?
  1038.         jp nz,stif
  1039.         call kirkli     ;handle kirkland interruprt
  1040.         inc hl          ;yes.
  1041.         call igsht
  1042.         cp labrc        ;must be followed by a label reference code
  1043.         call nz,ierror
  1044.         inc hl          ;OK, we found a label reference code. Enter
  1045.         ld e,(hl)               ;it in the label reference table.
  1046.         inc hl
  1047.         ld d,(hl)
  1048.         inc hl
  1049.         ex de,hl
  1050.         shld sr0
  1051.         ex de,hl
  1052.         ld de,mac37     ;and generate a jp instruction
  1053.         call mcrog
  1054.         call psemi      ;pass by semi
  1055.         ret
  1056.  
  1057. stif:   cp ifcd ;"if" statement?
  1058.         jp nz,stwhil
  1059.         call kirkli     ;handle kirkland interrupt
  1060.         call ltabmp     ;bump label table
  1061.         inc hl          ;yes.
  1062.         call igsht      ;look for open paren
  1063.         cp open
  1064.  
  1065.         push de
  1066.         ld de,stgeop
  1067.         call nz,perrab  ;internal error: missing {
  1068.         pop de
  1069.  
  1070.         inc hl          ;pass over it
  1071.         call rpshp
  1072.         call expr       ;evaluate condition
  1073.         call ppshp
  1074.         cp close        ;followed by close paren?
  1075.  
  1076.         push de
  1077.         ld de,stgecp
  1078.         call nz,perrab
  1079.         pop de
  1080.  
  1081.         inc hl
  1082.         call gncjf
  1083.         call ltabtd
  1084.         call state
  1085.         call igsht
  1086.         cp elscd
  1087.         jp z,stifel
  1088.         call ltabfd
  1089.         call ltabpp
  1090.         ret
  1091.  
  1092. stifel: call gfjp
  1093.         call ltabfd
  1094.         call ltabpp
  1095.         inc hl
  1096.         call state
  1097.         call plvdl
  1098.         ret
  1099.  
  1100.  
  1101. stwhil: cp whlcd        ;"while" statement?
  1102.         jp nz,stdo
  1103.         inc hl          ;yes.
  1104.         ld a,(hl)
  1105.         cp lblcd
  1106.         call nz,ierror
  1107.         inc hl
  1108.         ld e,(hl)
  1109.         inc hl
  1110.         ld d,(hl)
  1111.         inc hl
  1112.         call entl
  1113.         call ltabmp
  1114.         call igsht
  1115.         call igsht
  1116.         cp open
  1117.  
  1118.         push de
  1119.         ld de,stgeop
  1120.         call nz,perrab
  1121.         pop de
  1122.  
  1123.         call kirkli     ;insert kirkland interrupt
  1124.         inc hl
  1125.         call rpshp
  1126.         call expr       ;evaluate condition
  1127.         call ppshp
  1128.         cp close        ;close paren?
  1129.  
  1130.         push de
  1131.         ld de,stgecp
  1132.         call nz,perrab
  1133.         pop de
  1134.  
  1135.         inc hl
  1136.         call gncjf
  1137.         call ltabtd
  1138.         call state      ;generate code for the body of the statment
  1139.         call state      ;and eat up the trailing "goto" stuck in by CC1
  1140.         call ltabfd
  1141.         call ltabpp
  1142.         ret
  1143.  
  1144. stdo:   cp docd ;"do" statement?
  1145.         jp nz,stret
  1146.         inc hl
  1147.         call ltabmp
  1148.         call fltbtd
  1149.         call state      ;generate code for body
  1150.         call igsht
  1151.         cp whlcd        ;make sure there's a "while"
  1152.         call nz,ierror
  1153.         inc hl          ;ok, there is.
  1154.         call igsht
  1155.         cp lblcd
  1156.         jp nz,stdo1
  1157.         inc hl
  1158.         inc hl
  1159.         inc hl
  1160. stdo1:  call kirkli     ;insert kirkland interrupt
  1161.         call rpshp
  1162.         call expr       ;evaluate condition
  1163.         call ppshp
  1164.         call gncjt
  1165.         call ltabfd
  1166.         call ltabpp
  1167.         call igsht      ;check for trailing semicolon
  1168.         cp semi
  1169.  
  1170.         push de
  1171.         ld de,s4
  1172.         jp nz,perrab
  1173.         pop de
  1174.  
  1175.         inc hl          ;and pass over it if it is there (should be)
  1176.         ret
  1177.  
  1178. stret:  cp rencd        ;"return" statment?
  1179.         jp nz,stswit
  1180.  
  1181.         call kirkli     ;insert kirkland interrupt
  1182.         inc hl          ;yes.
  1183.         call igsht
  1184.         cp semi ;does it have an argument?
  1185.         jp z,stret2     ;if not, go handle trivial case
  1186.  
  1187.         call ltabmp     ;bump ltab with dummy entry
  1188.         ld a,81h
  1189.         sta val         ;MUST have value, at all costs.
  1190.         call rpshp
  1191.         call expr0      ;else evaluate argument.
  1192.         call ppshp
  1193.         call flshh1     ;make sure we get a value
  1194.         call ltabtd     ;define true and false
  1195.         call ltabfd     ;ltab locations
  1196.         call ltabpp     ;and pop ltab entry
  1197.  
  1198.         lda ftypec      ;and zero out the high-
  1199.         or a            ;order byte if either the type
  1200.         jp z,stret1     ;of the function is char, or...
  1201.         ld de,mac61
  1202.         call mcrog
  1203.         jp stret2
  1204.  
  1205. stret1: call tschr
  1206.         jp nz,stret2
  1207.         ld de,mac61     ;the type of the function is int and
  1208.         call mcrog      ;the type of the return value is char.
  1209.  
  1210. stret2: push hl
  1211.         lhld fexlab     ;get exit label
  1212.         shld sr0
  1213.         pop hl
  1214.         call psemi
  1215.         call peeknxt    ;peek at next token
  1216.         cp rbrcd        ;next token a close curly brace?
  1217.         jp nz,stret3
  1218.         lda levno       ;yes. are we at top level of function?
  1219.         cp 1
  1220.         ret z           ;if so, don't generate any jumps or exit code
  1221.        
  1222. stret3: push hl
  1223.         lhld sfsiz      ;if sfsiz is non-zero
  1224.         ld a,h
  1225.         or l
  1226.         pop hl
  1227.         jp nz,stret4    ;then go handle that case
  1228.  
  1229.         ld de,mfex4     ;else frame size is 0...
  1230.         lda nofrmls     ;null formal parameter list?
  1231.         or a
  1232.         jp nz,mcrog     ;if so, use trivial exit sequence
  1233.  
  1234.         ld de,mfex3     ;0 frame size w/formal parms exit sequence
  1235.         jp mcrog
  1236.  
  1237. stret4: push hl
  1238.         lhld sfsiz      ;get frame size again
  1239.         ld a,h
  1240.         or a            ;if frame size > 255,
  1241.         jp nz,stret5    ; go use bulky sequence
  1242.         lda optimf      ;else check for -z function exit optimization
  1243.         and 2
  1244.         jp z,stret5
  1245.         ld a,0d7h       ;rst 2
  1246.         call genb
  1247.         ld a,l          ;SP offset byte
  1248.         call genb
  1249.         pop hl          ;and all done
  1250.         ret
  1251.  
  1252. stret5: ld de,mac36     ;use this for "jp fexlab"
  1253.         call mcrog      ;use "jp fexlab" if non-zero stack frame size
  1254.         pop hl
  1255.         ret
  1256.  
  1257.  
  1258. stswit: cp swtcd        ;"switch" statment?
  1259.         jp z,st11               ;if so, go process
  1260.         cp rbrcd        ;right curly bracket?
  1261.         ret z           ;if so, ignore it
  1262.         call kirkli     ;insert kirkland interrupt for expression statement
  1263.         call ltabmp
  1264.         call rpshp
  1265.         call exprnv     ;else must be expression statment. Evaluate it
  1266.         call ppshp
  1267.         call igsht      ;without requiring a return value.
  1268.         cp semi ;followed by semi?
  1269.         jp z,stexp2     ;if so, normal. pass the semi
  1270.  
  1271.         ld de,stg10
  1272.         call perrsv     ;else print an error with saved line number
  1273.  
  1274.         call fsemi      ;and look for semi
  1275.  
  1276. stexp2: call psemi
  1277.         call ltabtd
  1278.         call ltabfd
  1279.         call ltabpp
  1280.         ret
  1281.  
  1282. st11:   inc hl          ;process switch statment.
  1283.         call kirkli     ;insert kirkland interrupt
  1284.         call opsin      ;init op stack
  1285.         call igsht
  1286.         ld b,0
  1287.         ld a,1
  1288.         sta val
  1289.         call rpshp
  1290.         call sprmp      ;evaluate switch value
  1291.         call ppshp
  1292.  
  1293.         call tschr      ;char value?
  1294.         jp nz,st11x
  1295.         lda sval1       ;yes. get it into A so we can do cp's later
  1296.         and 0c0h        ;value in L?
  1297.         ld a,7dh        ;do ld a,l if so
  1298.         jp z,st11w
  1299.         ld a,7bh        ;else do ld a,e
  1300. st11w:  call genb
  1301.  
  1302. st11x:  ld a,(hl)               ;skip newlines
  1303.         cp nlcd ; this is a special kludge to fix
  1304.         jp nz,st11y     ; an obscure bug
  1305.         inc hl
  1306.         ex de,hl
  1307.         lhld nlcnt
  1308.         inc hl
  1309.         shld nlcnt
  1310.         ex de,hl
  1311.         jp st11x
  1312.  
  1313. st11y:  ld a,(hl)
  1314.         inc hl
  1315.         cp swtbc        ;special switch table prefix code?
  1316.         jp nz,ierror    ;if not, we're not quite debugged...
  1317.  
  1318.         ld b,(hl)               ;else get case count byte
  1319.  
  1320. st12:   ld a,b
  1321.         or a            ;done with all case tests?
  1322.         jp z,st13
  1323.         ex de,hl                ;no. generate code for a test
  1324.         ld l,3eh
  1325.         inc de
  1326.         ld a,(de)
  1327.         ld h,a
  1328.         shld sr0
  1329.         inc de
  1330.         ld a,(de)
  1331.         ld h,a
  1332.         shld sr2
  1333.         inc de
  1334.         ld a,(de)
  1335.         ld l,a
  1336.         inc de
  1337.         ld a,(de)
  1338.         ld h,a
  1339.         shld sr3
  1340.         call glbl
  1341.         shld sr1
  1342.         ex de,hl
  1343.  
  1344.         call tschr      ;switch variable a char?
  1345.         jp nz,st12a     ;if not, go handle 16 bit value
  1346.         ld de,mac35c    ;yes. do the short version for chars,
  1347.         ld a,0feh       ;using 'cp' instead of the hairy test.
  1348.         sta sr0
  1349.         jp st12b
  1350.  
  1351. st12a:  lda sval1       ;else 16 bit value. In HL?
  1352.         and 0c0h
  1353.         ld de,mac35     ;do this if so
  1354.         jp z,st12b
  1355.         ld de,mac35d    ;else do this.
  1356.        
  1357. st12b:  call mcrog      ;high and low order bytes.
  1358.         dec b
  1359.         jp st12 ;go on to next case.
  1360.  
  1361. st13:   inc hl
  1362.         ld e,(hl)               ;handle default case
  1363.         inc hl
  1364.         ld d,(hl)
  1365.         inc hl
  1366.         ex de,hl
  1367.         shld sr0
  1368.         ex de,hl
  1369.         ld de,mac36
  1370.         call mcrog
  1371.         call state      ;evaluate body of switch
  1372.         ret
  1373.  
  1374.  
  1375. ;
  1376. ; Routine to resolve all "symbolic label" references in a function:
  1377. ;
  1378.  
  1379. rslvl:  lhld lblc
  1380.         ex de,hl
  1381.         ld hl,lblt
  1382.  
  1383. rslv2:  ld a,d
  1384.         or e
  1385.         ret z
  1386.         push de
  1387.         ld e,(hl)
  1388.         inc hl
  1389.         ld d,(hl)
  1390.         inc hl
  1391.         ld a,(hl)
  1392.         inc hl
  1393.         push hl
  1394.         ld h,(hl)
  1395.         ld l,a
  1396.         ex de,hl
  1397.         call scanr
  1398.         pop hl
  1399.         inc hl
  1400.         pop de
  1401.         dec de
  1402.         jp rslv2
  1403.  
  1404. scanr:  ld b,h
  1405.         ld c,l
  1406.         lhld lbrc
  1407.         push de
  1408.         ex de,hl
  1409.         ld hl,lbrt
  1410.  
  1411. scan0:  ld a,d
  1412.         or e
  1413.         jp nz,scan1
  1414.         pop de
  1415.         ret
  1416.  
  1417. scan1:  ld a,(hl)
  1418.         inc hl
  1419.         cp c
  1420.         jp nz,scan3
  1421.         ld a,(hl)
  1422.         cp b
  1423.         jp z,scan4
  1424.  
  1425. scan3:  inc hl
  1426.         inc hl
  1427.         inc hl
  1428.         dec de
  1429.         jp scan0
  1430.  
  1431. scan4:  ex de,hl
  1432.         ex (sp),hl
  1433.         push hl
  1434.         inc de
  1435.         ld a,(de)
  1436.         ld l,a
  1437.         inc de
  1438.         ld a,(de)
  1439.         ld h,a
  1440.         inc de
  1441.         ex de,hl
  1442.         ex (sp),hl
  1443.         ld a,l
  1444.         ld (de),a
  1445.         inc de
  1446.         ld a,h
  1447.         ld (de),a
  1448.         shld temp
  1449.         pop hl
  1450.         pop de
  1451.         dec de
  1452.         push hl
  1453.         lhld temp
  1454.         ex (sp),hl
  1455.         jp scan0
  1456.  
  1457. ;
  1458. ; Routine to tack on the relocation parameters to the function
  1459. ; just completed evaluating:
  1460. ;
  1461.  
  1462. insrd:  lhld relc       ;generate # of relocation parms value
  1463.         ld a,l
  1464.         call genb
  1465.         ld a,h
  1466.         call genb
  1467.  
  1468.         add hl,hl               ;byte count in HL
  1469.         ld bc,relt      ;list of parameters
  1470.  
  1471. insd1:  ld a,h
  1472.         or l
  1473.         ret z
  1474.         ld a,(bc)
  1475.         call genb
  1476.         inc bc
  1477.         dec hl
  1478.         jp insd1
  1479.  
  1480.         if 1==1
  1481. ;
  1482. ; Initialize operator stack and operand
  1483. ; information stack:
  1484. ;
  1485.  
  1486. opsin:  push hl
  1487.         ld hl,opstk
  1488.         shld opstp
  1489.         ld (hl),0ffh
  1490.         ld hl,infstk
  1491.         shld infsp
  1492.         pop hl
  1493.         ret
  1494.         endif
  1495.        
  1496. ;
  1497. ; Data Area:
  1498. ;
  1499.  
  1500.  
  1501. ;
  1502. ; Binary-to-Ascii conversion text area:
  1503. ;
  1504.  
  1505. ascb:   ds 4            ;the area in which the ASCII value of the current
  1506.         db ': ',0       ;line number is computed for error reports
  1507.  
  1508.  
  1509. ;
  1510. ; RED-related  stuff:
  1511. ;
  1512.  
  1513. redfcb:  db 0,'PROGERRS$$$',0,0,0,0
  1514.          ds 17  ;rest of fcb for RED error file
  1515. redbuf: ds 128  ;text buffer for RED error file
  1516. redbp:  ds 2    ;pointer into text buffer
  1517. errsin: ds 1    ;true if RED output is active
  1518.  
  1519. werrs:  ds 1    ;true to write out RED file, else false (default)
  1520.                 ;(set upon auto-chain from CC.COM)
  1521.  
  1522. ;
  1523. ; Module stack stuff:
  1524. ;
  1525.  
  1526. modstk: ds (fnlen + 2) * (nestmax + 1)
  1527. modstp: ds 2    ;pointer to currently active filename
  1528. modstc: ds 1    ;counter
  1529.  
  1530.  
  1531. ;
  1532. ; CDB control stuff:
  1533. ;
  1534.  
  1535. klcnt:  ds 1    ;count of interrupts on current line
  1536. kllin:  ds 2    ;last line where interrupt was generated
  1537. kblin:  ds 2    ;line on which function begins
  1538.  
  1539. ;
  1540. ; Flags used by new alugen:
  1541. ;
  1542.  
  1543. hbn1cf: ds 1
  1544. key:    ds 1
  1545. spval:  ds 2
  1546. spmac:  ds 2
  1547.  
  1548. ;
  1549. ; Other stuff:
  1550. ;
  1551.  
  1552. ssval:  ds 1            ;temporry storge
  1553. namsav: ds 2            ;name of func being processed
  1554. nlcnts: ds 2            ;save line # of start of include file
  1555. subval: ds 2            ;scratch space used by primb
  1556. sgflg:  ds 1
  1557. ftypec: ds 1
  1558. val:    ds 1            ;used for optimizing ++ & -- exprs
  1559. arith:  ds 1            ;used by bexpr
  1560. value:  ds 1
  1561. par2pf: ds 1
  1562. errf:   ds 1            ;tells if any fatal errors ocurred
  1563. entn:   ds 1            ;contains the number of the function being processed
  1564. argcnt: ds 1
  1565. simpf:  ds 1
  1566. op:     ds 1
  1567. faflg:  ds 1            ;true when evaluating arguments in a function call
  1568. lflg:   ds 1
  1569. eofad:  ds 2            ;contains address of end of file in memory
  1570. dirp:   ds 2            ;pointer to next space in CRL directory to be filled
  1571. stgad:  ds 2            ;address of string texts compiled by CC1
  1572. stno:   ds 2            ;number of symbols in symbol table (computed by CC1)
  1573. fntb:   ds 2            ;pointer to list function names created by CC1
  1574. nlcnt:  ds 2            ;new line count (keeps track of current line number)
  1575. savnlc: ds 2            ;save ine count for lines with long logical errors
  1576. lbln:   ds 2            ;symbolic label source (starts at 8000h for CC2)
  1577. prnsav: ds 2            ;temp store used to save addr of open parenthesis
  1578. prnflg: ds 1
  1579. sr0:    ds 2            ;the Special Registers
  1580. sr1:    ds 2            ;used for code generation by mcrog
  1581. sr2:    ds 2
  1582. sr3:    ds 2
  1583. sr4:    ds 2
  1584. sr5:    ds 2
  1585. modsa:  ds 2            ;the address at which the size of a function goes
  1586. sfsiz:  ds 2            ;size of the current function's stack frame
  1587. cdp:    ds 2            ;code pointer, used internally for code generation
  1588. cdao:   ds 2            ;       even more
  1589. nfns:   ds 1
  1590. stmp:   ds 2
  1591. temp:   ds 2
  1592. vext:   ds 1
  1593. codflg: ds 1            ;true if code generation enabled (only disabled
  1594.                         ;       during "sizeof" evaluation)
  1595. notklg: ds 1            ;flag used by sgen5 to fix Gary Kildall's bug
  1596.  
  1597. ;
  1598. ; The attributes of a sub-expression, as it is being evaluated, are
  1599. ; stored in one or the other of the two following blocks. The first
  1600. ; one is the primary block, and the second is used when a binary
  1601. ; expression is being processed:
  1602. ;
  1603.  
  1604. sval1:  ds 1            ;constant, flag and push-optimization data
  1605. sbmap1: ds 1            ;flag and misc bit info
  1606. svv1:   ds 2            ;constant value (if constant)
  1607. indc1:  ds 1            ;0=constant 1=lvalue 2=pointer 3=ptr-to-ptr
  1608.                         ;4=ptr-to-ptr-to-ptr etc.
  1609. typ1:   ds 1            ;0=char 1=int 2=uns 3-5 unused 6=struct
  1610. strsz1: ds 2            ;size of structure, if struct or pointer to struct
  1611. dimsz1: ds 2            ;if 0: scalar. if high byte=FF: 1-dim array.
  1612.                         ;       else: value is 1st dim of 2-dim array
  1613. frml1:  ds 1            ;true if formal parameter (formal arrays treated
  1614.                         ;       differently than non-formal arrays)
  1615.  
  1616. sval2:  ds 1
  1617. sbmap2: ds 1
  1618. svv2:   ds 2
  1619. indc2:  ds 1            ;attributes of alternate result of expreesion
  1620. typ2:   ds 1            ;evaluator. Each means same as counterpart above.
  1621. strsz2: ds 2
  1622. dimsz2: ds 2
  1623. frml2:  ds 1
  1624.  
  1625. ;
  1626. ; Values set by the "Analyze" routine, which, given the info in the
  1627. ; first block above, sets these values accordingly:
  1628. ;
  1629.  
  1630. asize:  ds 2            ;size of object, in bytes
  1631. aadrf:  ds 1            ;true (non-zero) if object has an address
  1632. asnokf: ds 1            ;true if object may be assigned to
  1633. amathf: ds 1            ;true if object may have math done on it
  1634. avar:   ds 1            ;true if object is a variable
  1635.  
  1636. ;
  1637. ; Misc. storge used by the more grungy parts of the compiler:
  1638. ;
  1639.  
  1640. opstp:  ds 2
  1641. infsp:  ds 2
  1642. nofrmls: ds 1
  1643. fncnt:  ds 1
  1644. start:  ds 2
  1645. relp:   ds 2
  1646. relc:   ds 2
  1647. lblp:   ds 2
  1648. lblc:   ds 2
  1649. lbrp:   ds 2
  1650. lbrc:   ds 2
  1651. codp:   ds 2
  1652. cdstrt: ds 2
  1653. klujf:  ds 1
  1654. fexlab: ds 2            ;symbolic label of exit code for current function
  1655. savtxt: ds 2            ;used by sargs routine
  1656. savcnt: ds 2            ;used by sargs also
  1657. prerrs: ds 1            ;true if printing errors
  1658. retadd: ds 2            ;used by label-generating stack-hacking routines
  1659.  
  1660.  
  1661.