?login_element?

Subversion Repositories NedoOS

Rev

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

  1.  
  2.  
  3. ;
  4. ; cc2d.asm:
  5. ;
  6. ; Utility routines for expression evaluator:
  7. ;
  8.  
  9. ;
  10. ; Lookup the identifier pointed to by HL in the
  11. ; symbol table, and set the following values
  12. ; according to the symbol table entry:
  13. ;       INDC1:  indirection count
  14. ;       TYP1:   type
  15. ;       STRSZ1: size of structure (if structure)
  16. ;       DIMSZ1: array information (if array), else
  17. ;               address of function (if function)
  18. ;       FRML1:  1 if formal argument, else 0
  19. ;       (DE):   relative address (relative to BC or extad)
  20. ;
  21.  
  22. lookup: ld a,(hl)
  23.         cp varcd
  24.         call nz,ierror
  25.         inc hl
  26.         ld e,(hl)
  27.         inc hl
  28.         ld d,(hl)
  29.         inc hl
  30.         call lookp2
  31.         call igsht
  32.         ret
  33.  
  34. lookp2: push bc
  35.         push hl
  36.         ex de,hl
  37.         add hl,hl
  38.         add hl,hl
  39.         add hl,hl
  40.         ld de,st
  41.         add hl,de
  42.         ld a,(hl)
  43.  
  44.         push af ;flag using structure types as expressions
  45.         and 3
  46.         cp 2
  47.         ld de,stg10
  48.         call z,perr
  49.         pop af
  50.  
  51.         rrca
  52.         rrca
  53.         rrca
  54.         rrca
  55.         and 87h
  56.         ld b,a
  57.         ld a,(hl)
  58.         rrca
  59.         rrca
  60.         push af
  61.         and 60h
  62.         or b
  63.         sta typ1
  64.         pop af
  65.         and 1
  66.         sta frml1
  67.         inc hl
  68.         ld a,(hl)
  69.         rlca
  70.         rlca
  71.         and 3
  72.         sta indc1
  73.         ld a,(hl)
  74.         and 3fh
  75.         ld a,1
  76.         jp z,lp3
  77.         dec a
  78. lp3:    sta vext
  79.         inc hl
  80.         ld e,(hl)
  81.         inc hl
  82.         ld d,(hl)
  83.         inc hl
  84.         push de
  85.         ld e,(hl)
  86.         inc hl
  87.         ld d,(hl)
  88.         inc hl
  89.         ex de,hl
  90.         shld strsz1
  91.         ex de,hl
  92.         ld e,(hl)
  93.         inc hl
  94.         ld d,(hl)
  95.         ex de,hl
  96.         shld dimsz1
  97.  
  98.         pop de
  99.         lda frml1       ;formal?
  100.         or a
  101.         jp z,lp3a               ;if not, displacement value is OK
  102.         lhld sfsiz      ;else add sfsiz+4 to it
  103.         add hl,de               ;HL = sfsiz + local_addr
  104.         ld de,4
  105.         add hl,de               ;HL = sfsiz + local_addr + 4
  106.         ex de,hl                ;put value back in DE
  107.  
  108. lp3a:   ld hl,0
  109.         add hl,de
  110.         add hl,de
  111.         add hl,de
  112.         lda typ1
  113.         and 40h
  114.         jp z,lp4
  115.         shld dimsz1
  116.  
  117. lp4:    pop hl
  118.         pop bc
  119.         ret
  120.  
  121. ;
  122. ; Push operator in A on operator stack:
  123. ;
  124.  
  125. oppsh:  push hl
  126.         lhld opstp
  127.         inc hl
  128.         ld (hl),a
  129.         shld opstp
  130.         pop hl
  131.         ret
  132.  
  133. ;
  134. ; Pop off top entry in operator stack; Error
  135. ; if no operators on it:
  136. ;
  137.  
  138. oppop:  push hl
  139.         lhld opstp
  140.         ld a,(hl)
  141.         cp 255
  142.         jp z,opop1
  143.         or a
  144.         jp nz,opop2
  145. opop1:  ld de,stg7
  146.         call perr
  147.         call fsemi
  148.         pop hl
  149.         ret
  150.  
  151. opop2:  dec hl
  152.         shld opstp
  153.         pop hl
  154.         ret
  155.  
  156. ;
  157. ; Pop off dummy op
  158. ;
  159.  
  160. oppops: push hl
  161.         lhld opstp
  162.         dec hl
  163.         shld opstp
  164.         pop hl
  165.         ret
  166.  
  167. ;
  168. ; Look at top of operator stack. Return Z set
  169. ; (Z true) if no operators on the stack:
  170. ;
  171.  
  172. tstops: push hl
  173.         lhld opstp
  174.         ld a,(hl)
  175.         or a
  176.         pop hl
  177.         ret z
  178.         cp 255
  179.         ret
  180.  
  181.  
  182. ;
  183. ; Push information about operand 1 on the
  184. ; operand information stack:
  185. ;
  186.  
  187. pshn1:  push hl
  188.         push af
  189.  
  190.         lhld indc1
  191.         ex de,hl
  192.         lhld infsp      ;the info-SP
  193.         ld (hl),e
  194.         inc hl
  195.         ld (hl),d
  196.         inc hl
  197.  
  198.         ex de,hl
  199.         lhld strsz1
  200.         ex de,hl
  201.         ld (hl),e
  202.         inc hl
  203.         ld (hl),d
  204.         inc hl
  205.  
  206.         ex de,hl
  207.         lhld dimsz1
  208.         ex de,hl
  209.         ld (hl),e
  210.         inc hl
  211.         ld (hl),d
  212.         inc hl
  213.  
  214.         ex de,hl
  215.         lhld sval1
  216.         ex de,hl
  217.         ld (hl),e
  218.         inc hl
  219.         ld (hl),d
  220.         inc hl
  221.  
  222.         ex de,hl
  223.         lhld svv1
  224.         ex de,hl
  225.         ld (hl),e
  226.         inc hl
  227.         ld (hl),d
  228.         inc hl
  229.  
  230.         lda frml1
  231.         ld (hl),a
  232.         inc hl
  233.  
  234.         shld infsp
  235.         call chkovn     ;check for info table overflow
  236.         pop af
  237.         pop hl
  238.         ret
  239.  
  240. ;
  241. ; Push information about operand 2 on the
  242. ; operand information stack:
  243. ;
  244.  
  245. pshn2:  push hl
  246.         push af
  247.  
  248.         lhld indc2
  249.         ex de,hl
  250.         lhld infsp      ;the info-SP
  251.         ld (hl),e
  252.         inc hl
  253.         ld (hl),d
  254.         inc hl
  255.  
  256.         ex de,hl
  257.         lhld strsz2
  258.         ex de,hl
  259.         ld (hl),e
  260.         inc hl
  261.         ld (hl),d
  262.         inc hl
  263.  
  264.         ex de,hl
  265.         lhld dimsz2
  266.         ex de,hl
  267.         ld (hl),e
  268.         inc hl
  269.         ld (hl),d
  270.         inc hl
  271.  
  272.         ex de,hl
  273.         lhld sval2
  274.         ex de,hl
  275.         ld (hl),e
  276.         inc hl
  277.         ld (hl),d
  278.         inc hl
  279.  
  280.         ex de,hl
  281.         lhld svv2
  282.         ex de,hl
  283.         ld (hl),e
  284.         inc hl
  285.         ld (hl),d
  286.         inc hl
  287.  
  288.         lda frml2
  289.         ld (hl),a
  290.         inc hl
  291.  
  292.         shld infsp
  293.         call chkovn     ;check for info table overflow
  294.         pop af
  295.         pop hl
  296.         ret
  297.  
  298. ;
  299. ; Check for info-table overflow by seeing if the pointer
  300. ; has overlapped into the relocation table area:
  301. ;
  302.  
  303. chkovn: ld a,h
  304.         cp relt/255     ;if info pointer (hi) is less than the addr of the
  305.         ret c           ;rel table (hi), then no overflow
  306.         jp nz,chkove    ;if not same, then it has overflown
  307.         ld a,l          ;if same, check low order byte
  308.         cp relt and 255
  309.         ret c           ;if not less than rel table low byte, error
  310.  
  311. chkove: ld de,stgetc    ;sub-expressions too deeply nested; complain and
  312.         jp perrab       ;give up.
  313.  
  314. ;
  315. ; Pop off operand information from the operand
  316. ; information stack; make it operand 1:
  317. ;
  318.  
  319. ppn1:   push hl
  320.         push af
  321.         lhld infsp
  322.         dec hl
  323.  
  324.         ld a,(hl)
  325.         sta frml1
  326.         dec hl
  327.  
  328.         ld d,(hl)
  329.         dec hl
  330.         ld e,(hl)
  331.         dec hl
  332.         ex de,hl
  333.         shld svv1
  334.         ex de,hl
  335.  
  336.         ld d,(hl)
  337.         dec hl
  338.         ld e,(hl)
  339.         dec hl
  340.         ex de,hl
  341.         shld sval1
  342.         ex de,hl
  343.  
  344.         ld d,(hl)
  345.         dec hl
  346.         ld e,(hl)
  347.         dec hl
  348.         ex de,hl
  349.         shld dimsz1
  350.         ex de,hl
  351.  
  352.         ld d,(hl)
  353.         dec hl
  354.         ld e,(hl)
  355.         dec hl
  356.         ex de,hl
  357.         shld strsz1
  358.         ex de,hl
  359.  
  360.         ld d,(hl)
  361.         dec hl
  362.         ld e,(hl)
  363.         shld infsp
  364.         ex de,hl
  365.  
  366.         shld indc1
  367.         pop af
  368.         pop hl
  369.         ret
  370.  
  371. ;
  372. ; Pop off information on operand 2:
  373. ;
  374.  
  375. ppn2:   push hl
  376.         push af
  377.         lhld infsp
  378.         dec hl
  379.  
  380.         ld a,(hl)
  381.         sta frml2
  382.         dec hl
  383.  
  384.         ld d,(hl)
  385.         dec hl
  386.         ld e,(hl)
  387.         dec hl
  388.         ex de,hl
  389.         shld svv2
  390.         ex de,hl
  391.  
  392.         ld d,(hl)
  393.         dec hl
  394.         ld e,(hl)
  395.         dec hl
  396.         ex de,hl
  397.         shld sval2
  398.         ex de,hl
  399.  
  400.         ld d,(hl)
  401.         dec hl
  402.         ld e,(hl)
  403.         dec hl
  404.         ex de,hl
  405.         shld dimsz2
  406.         ex de,hl
  407.         ld d,(hl)
  408.         dec hl
  409.         ld e,(hl)
  410.         dec hl
  411.         ex de,hl
  412.         shld strsz2
  413.         ex de,hl
  414.         ld d,(hl)
  415.         dec hl
  416.         ld e,(hl)
  417.         shld infsp
  418.         ex de,hl
  419.         shld indc2
  420.         pop af
  421.         pop hl
  422.         ret
  423.  
  424. ;
  425. ; lde operand 1 info into operand 2:
  426. ;
  427.  
  428. mvn12:  call pshn1
  429.         call ppn2
  430.         ret
  431.  
  432. ;
  433. ; lde operand 2 info info operand 1:
  434. ;
  435.  
  436. mvn21:  call pshn2
  437.         call ppn1
  438.         ret
  439.  
  440.  
  441. ;
  442. ; Analyze the expression characterized by the variables
  443. ;       indc1,typ1,strsz1,dimsz1,frml1
  444. ; by setting the following variables accordingly:
  445. ;       AADRF:  true (non-zero) if an address;
  446. ;       ASNOKF: true if it can be assigned to;
  447. ;       AMATHF: true if it can have math done on it;
  448. ;       ASIZE:  if a pointer, size of the object pointed at;
  449. ;       AVAR:   true if a variable address (but not a pointer)
  450. ;
  451.  
  452. analyz: push hl         ;save text pointer
  453.         call anal1      ;perform analysis
  454.         pop hl          ;restore text pointer
  455.         ret
  456.  
  457. anal1:  ld hl,1         ;assume simple things at first.
  458.         shld asize      ;size of 1 byte
  459.         shld subval     ;initialize mulitplication accumulator
  460.         xor a
  461.         sta avar        ;not a variable
  462.         inc a
  463.         sta amathf      ;can do math
  464.         sta asnokf      ;ok to assign to it
  465.         sta aadrf       ;has an address
  466.  
  467.         call tstar      ;is it an array?
  468.         jp z,anal6
  469.         call tptr       ;no. pointer?
  470.         jp z,anal6
  471.         call tsval      ;no. simple constant value?
  472.         jp nz,anal3
  473.         xor a           ;yes. can't assign to it...
  474.         sta asnokf
  475.         sta aadrf       ;and it aint an address.
  476.         jp anal5a       ;make size of it: 2
  477.  
  478. anal3:  call tsstr      ;is it a simple struct base?
  479.         jp nz,anal4     ;if so,
  480.         call anal8a     ;set asize = size of one structure
  481. anal3a: xor a           ;can't assign or do math to it.
  482.         sta asnokf
  483.         sta amathf
  484.         ret
  485.  
  486. anal4:  call tptrf      ;pointer to function?
  487.         ret z           ;all set if so.
  488.  
  489. anal5:  call tfun       ;is it a function?
  490.         jp z,anal11     ;if so, set stuff appropriately.
  491.         ld a,1          ;else, must be a variable address.
  492.         sta avar
  493.         lda typ1
  494.         or a
  495.         ret z           ;if char, return with asize = 1
  496. anal5a: ld hl,asize
  497.         inc (hl)                ;else bump asize to 2
  498.         ret
  499.  
  500. anal6:  call t2dim      ;2-dimensional array?
  501.         jp nz,anal7
  502.         lhld dimsz1     ;yes. scale size of obj by 1st dim size
  503.         shld subval
  504. anal7:  lda typ1
  505.         and 20h         ;pointer to function?
  506.         jp nz,anal7a
  507.         lda indc1       ;no.
  508.         cp 3            ;if pointer to pointer...
  509.         jp nc,anal7a
  510.         call tstar      ;array of pointers?
  511.         jp nz,anal8
  512.         lda indc1
  513.         cp 2
  514.         jp nz,anal8
  515. anal7a: ld hl,2         ;double object size
  516.         call mult
  517.         jp anal10
  518.  
  519. anal8:  lda typ1        ;structure?
  520.         cp 6
  521.         jp nz,anal9
  522.  
  523. anal8a: lhld strsz1     ;yes. scale obj size by size of struct
  524.         call getsz      ;look up size in symbol table
  525.         call mult       ;multiply by old object size
  526.         jp anal10
  527.  
  528. anal9:  or a            ;character?
  529.         jp z,anal10
  530.         ld hl,2         ;no. must be 2-byte object.
  531.         call mult
  532. anal10: lhld subval     ;at last we have a final size.
  533.         shld asize      ;(subval was just an accumulator for
  534.         call tstar      ; the mult routine.)
  535.         ret nz          ;if not array, all done.
  536.         lda frml1       ;if so, only allow it to be assigned to
  537.         or a            ;if it isn't a formal parameter.
  538.         ret nz
  539. anal11: xor a
  540.         sta asnokf      ;woops, its formal. Disallow assignment
  541.         ret
  542.  
  543. ;
  544. ; Perform same analysis for 2nd operand, leaving
  545. ; 1st operand info intact:
  546. ;
  547.  
  548. anal2:  call pshn1
  549.         call mvn21
  550.         call analyz
  551.         call ppn1
  552.         ret
  553.  
  554.  
  555. ;
  556. ; Perform internal indirection on the object as characterized
  557. ; above. By "internal" I mean that no code is generated;
  558. ; rather, pointers become lvalues, 2-dim arrays become 1-dim
  559. ; arrays, etc. Error if object isn't SOME kind of object that
  560. ; can have indirection performed on it; i.e, a constant.
  561. ;
  562.  
  563. indir:  push hl
  564.         call ind1
  565.         pop hl
  566.         ret
  567.  
  568. ind1:   call tstar      ;array?
  569.         jp nz,ind3
  570.         call t2dim      ;yes. 2-dim?
  571.         ld hl,0
  572.         jp nz,ind2
  573.         ld hl,0ff00h    ;yes. change into 1-dim
  574. ind2:   shld dimsz1
  575.         ret
  576.  
  577. ind3:   call tptrf      ;pointer to function?
  578.         jp nz,ind4
  579.         lda typ1        ;yes. make into an actual function
  580.         and 0dfh        ;strip off ptr to func bit
  581.         or 40h          ;turn on function bit
  582.         sta typ1        ;and store new type
  583.         xor a
  584.         sta simpf       ;NOT a simple function instance!
  585.         ret
  586.  
  587. ind4:   call tfun       ;is it a function?
  588.         jp z,ind5               ;if so, bad news.
  589.         call tptr       ; a pointer?
  590.         jp nz,ind5
  591.         lda indc1       ;yes. de-bump indirection count by 1.
  592.         dec a
  593.         sta indc1
  594.         ret
  595.  
  596. ind5:   ld de,stg21     ;something is screwy in the state of
  597.         jp perr ;confusion. (?)
  598.  
  599.  
  600. ;
  601. ; Type Testing functions....each of the following routines
  602. ; tests for some particular property, and returns Z true if
  603. ; the property is true for the expression described by
  604. ; INDC1,TYP1,etc...
  605. ;
  606.  
  607. tstar:  call tfun       ;is expr an array?
  608.         jp z,invrt      ;if function, then not array.
  609.         push hl         ;look at dim size.
  610.         lhld dimsz1
  611.         ld a,h
  612.         or l
  613.         pop hl          ; now Z set if NOT array
  614.  
  615. invrt:  jp z,invrt2     ;invert Z flag.
  616.         xor a           ; if wasn't zero,
  617.         ret             ; set zero and return.
  618. invrt2: xor a           ;else reset zero by clearing
  619.         inc a           ;and incrementing A.
  620.         ret
  621.  
  622. ;
  623. ; Test if expr is a 2 dimensional array
  624. ;
  625.  
  626. t2dim:  call tstar      ;array?
  627.         ret nz          ;if not, certainly not a 2-dim array.
  628.         lda dimsz1+1    ;else look at high byte of dim size
  629.         cp 0ffh ;this is special code for 1-dim array
  630.         jp invrt        ;if 1-dim, not 2-dim, and vice versa!
  631.  
  632. ;
  633. ; Test if expr is a pointer to function (special case)
  634. ;
  635.  
  636. tptrf:  call tstar      ;an array?
  637.         jp z,invrt      ;if so, not pointer to function
  638.         call tfun       ;if function,
  639.         jp z,invrt      ;not a pointer to one!
  640.         lda typ1        ;else look at the crucial bit
  641.         and 20h
  642.         jp invrt        ;if set, then is a pointer to function
  643.  
  644. ;
  645. ; Test if expr is any kind of pointer (including an array)
  646. ;
  647.  
  648. tptr:   call tfun       ;function?
  649.         jp z,invrt      ;if so, not a pointer.
  650.         call tptrf      ;pointer to function?
  651.         ret z           ;if so, definitely a pointer
  652.         call tstar      ;array?
  653.         ret z           ;if so, implicitly a pointer.
  654.         lda indc1       ;else check indirection count
  655.         cp 2
  656.         ret c           ;if <2, not pointer.
  657.         xor a           ;else is a pointer.
  658.         ret
  659.  
  660. ;
  661. ; Same as above for operand 2:
  662. ;
  663.  
  664. tptr2:  call pshn1
  665.         call mvn21
  666.         call tptr
  667.         call ppn1
  668.         ret
  669.  
  670. ;
  671. ; Test if expr is a simple pointer (not pointer-to-pointer)
  672. ;
  673.  
  674. tsptr:  call tfun       ;if function,
  675.         jp z,invrt      ;not pointer.
  676.         call t2dim      ;2-dim array?
  677.         jp z,invrt      ;if so, not simple pointer
  678.         call tstar      ;array?
  679.         ret z           ;if so, simple pointer.
  680.         call tptrf      ;pointer to function?
  681.         ret z           ;if so, simple pointer.
  682.         lda indc1       ;check indirection count
  683.         cp 2            ;if == 2, simple pointer.
  684.         ret
  685.  
  686. ;
  687. ; Test if expr is simple value (not address):
  688. ;
  689.  
  690. tsval:  call tstar      ;if array,
  691.         jp z,invrt      ;not value.
  692.         call tfun
  693.         jp z,invrt      ;no functions allowed.
  694.         call tptr
  695.         jp z,invrt      ;no pointer either.
  696.         call tsstr      ;structure?
  697.         jp z,invrt      ;if so, sorry.
  698.         lda indc1
  699.         or a            ;true only if no indirection.
  700.         ret
  701.  
  702. ;
  703. ; Same as above for 2nd operand:
  704. ;
  705.  
  706. tsval2: call pshn1
  707.         call mvn21
  708.         call tsval
  709.         call ppn1
  710.         ret
  711.  
  712. ;
  713. ; Test if simple character value
  714. ;
  715.  
  716. tschr:  call tsval      ;if not simple value, not likely to
  717.         ret nz          ;be simple char value!
  718.         lda typ1
  719.         or a
  720.         ret             ;else is only if type is char.
  721.  
  722. ;
  723. ; Same for 2nd operand
  724. ;
  725.  
  726. tschr2: call tsval2
  727.         ret nz
  728.         lda typ2
  729.         or a
  730.         ret
  731.  
  732.  
  733. ;
  734. ; Test if expr is structure base
  735. ;
  736.  
  737. tsstr:  call tstar
  738.         jp z,invrt      ;if array, not structure.
  739.         lda typ1
  740.         cp 6
  741.         ret nz          ;if not struct, no good.
  742.         lda indc1
  743.         cp 2
  744.         jp c,tstr1      ;pointer?
  745.         xor a           ;yes. no good.
  746.         inc a  
  747.         ret
  748. tstr1:  xor a           ;no pointer; ok.
  749.         ret
  750.  
  751.  
  752. ;
  753. ; Test if expr is a function
  754. ;
  755.  
  756. tfun:   lda typ1
  757.         and 40h         ;look at function bit.
  758.         jp invrt        ;if set, is a function.
  759.  
  760. ;
  761. ; Test if expr is simple pointer to characters
  762. ;
  763.  
  764. tsptrc: call tsptr      ;simple pointer?
  765.         ret nz          ;if not, no good.
  766.         call tptrf      ;pointer to function?
  767.         jp z,invrt      ;if so, not pointer to char.
  768.         lda typ1
  769.         or a
  770.         ret             ;true only if type == char.
  771.  
  772. ;
  773. ; Test if simple lvalue (as opposed to array or pointer)
  774. ;
  775.  
  776. tslv:   call tstar
  777.         jp z,invrt      ;arrays no good
  778.         call tptrf
  779.         jp z,invrt      ;neither are ptrs to funcs
  780.         lda indc1
  781.         dec a
  782.         ret nz          ;no good if not lvalue
  783.         lda typ1
  784.         cp 6
  785.         jp invrt        ;and no good if struct.
  786.  
  787. ;
  788. ; Test if simple character lvalue
  789. ;
  790.  
  791. tsclv:  call tslv
  792.         ret nz          ;no good if not simple lvalue
  793.         lda typ1
  794.         or a
  795.         ret             ;or if type not char
  796.  
  797. ;
  798. ; The following routines "check" for some property, and
  799. ; spew an error message if the property is found to be
  800. ; lacking...
  801. ;
  802.  
  803. ;
  804. ; Test to see if expr is a pointer or a value, and give
  805. ;   "Bad use of unary op" error if not. Obviously, this
  806. ;   routine is called from the unary operator processor.
  807. ;
  808.  
  809. ckaok:  call tptr       ;pointer?
  810.         ret z           ;if so, OK
  811.  
  812. ; This is the entry point for the check for "simple value only"
  813.  
  814. ckval:  call tsval      ;simple value?
  815.         ret z           ;if so, OK
  816.         ld de,stg13
  817.         jp perr
  818.  
  819.  
  820. ;
  821. ; If A==2, it means that an lvalue was called for from an
  822. ; operator which cannot provide it. Bad news.
  823. ;
  824.  
  825. ckvok:  cp 2
  826.         ret nz
  827.         ld de,stg8
  828.         call perr
  829.  
  830. ;
  831. ; Give an error if both operands are not simple values.
  832. ;
  833.  
  834. ckval2: call tsval      ;is 1st a value?
  835.         jp nz,ckv2e     ;if not, trouble.
  836.         call pshn1      ;save info on 1st operand
  837.         call mvn21      ;give 1st operand 2nd operand's info
  838.         call tsval      ;so we can call tsval.
  839.         call ppn1       ;restore 1st operand's info
  840.         ret z           ;return if 2nd operand was value
  841. ckv2e:  ld de,stg18     ;woops.
  842.         jp perr
  843.  
  844. ;
  845. ; Logical branch table handler routines:
  846. ;
  847.  
  848. ltabmp: push de         ;bump ltab with new entry
  849.         push hl
  850.         lhld ltabp      ;get logical table pointer  in HL
  851.         ex de,hl                ;put in DE
  852.  
  853.         ld hl,ltabp-5   ;get pointer to end of logical table in HL
  854.         call cmpdh      ;make sure pointer is well below end of table
  855.         jp c,ltbmp2     ;if so, no problem...
  856.         ld de,stgcsn    ;control structure too deeply nested
  857.         jp perrab
  858.        
  859. ltbmp2:
  860.         call glbl
  861.         ex de,hl
  862.         ld (hl),e
  863.         inc hl
  864.         ld (hl),d
  865.         inc hl
  866.         ex de,hl
  867.         call glbl
  868.         ex de,hl
  869.         ld (hl),e
  870.         inc hl
  871.         ld (hl),d
  872.         inc hl
  873.         ld (hl),0
  874.         inc hl
  875.         shld ltabp
  876.         pop hl
  877.         pop de
  878.         ret
  879.  
  880. ;
  881. ; Define true label at current position in code, if used bit
  882. ; for that entry is set:
  883. ;
  884.  
  885. ltabtd: push hl
  886.         push de
  887.         lhld ltabp
  888.         dec hl
  889.         ld a,(hl)
  890.         and 1
  891.         jp z,ltbtd1
  892. ltbtd0: dec hl
  893.         dec hl
  894.         dec hl
  895.         ld d,(hl)
  896.         dec hl
  897.         ld e,(hl)
  898.         call entl
  899. ltbtd1: pop de
  900.         pop hl
  901.         ret
  902.  
  903. ;
  904. ; Force definition of true ltab entry:
  905. ;
  906.  
  907. fltbtd: push hl
  908.         push de
  909.         lhld ltabp
  910.         dec hl
  911.         jp ltbtd0
  912.  
  913. ;
  914. ; Define false label entry if appropriate used bit is set:
  915. ;
  916.  
  917. ltabfd: push hl
  918.         push de
  919.         lhld ltabp
  920.         dec hl
  921.         ld a,(hl)
  922.         or a
  923.         jp p,ltbfd1
  924. ltbfd0: dec hl
  925.         ld d,(hl)
  926.         dec hl
  927.         ld e,(hl)
  928.         call entl
  929. ltbfd1: pop de
  930.         pop hl
  931.         ret
  932.  
  933. ;
  934. ; Force definition of false label entry:
  935. ;
  936.  
  937. fltbfd: push hl
  938.         push de
  939.         lhld ltabp
  940.         dec hl
  941.         jp ltbfd0
  942.  
  943. ;
  944. ; Pop last entry off the ltab:
  945. ;
  946.  
  947. ltabpp: push hl
  948.         push de
  949.         lhld ltabp
  950.         ld de,-5
  951.         add hl,de
  952.         shld ltabp
  953.         pop de
  954.         pop hl
  955.         ret
  956.  
  957. ;
  958. ; Convert logical flag setting to value in DE:
  959. ;
  960.  
  961. cvtlvd: lda sval1
  962.         and 4
  963.         ret z           ;ignore if no flag set
  964.         lda sval1       ;(just fixed:OK -lz)
  965.         and 20h         ;if already have a value, put into DE if not
  966.         jp z,cvtvd1     ;already there. so, do we have a value?
  967.         lda sval1
  968.         and 0c0h        ;yes. is it already in DE?
  969.         ret nz
  970.         call gexdehl    ;no, put it there
  971.         lda sval1
  972.         or 40h
  973.         sta sval1       ;tell that it's in DE
  974.         ret
  975.        
  976. cvtvd1: lda sbmap1      ;else get the flag setting
  977.         and 7
  978.         add a,6
  979. cvtvd2: push de
  980.         ld e,a
  981.         ld d,0
  982.         push hl
  983.         ld hl,flagct
  984.         add hl,de
  985.         add hl,de
  986.         ld e,(hl)
  987.         inc hl
  988.         ld d,(hl)
  989.         call mcrog
  990.         pop hl
  991.         pop de
  992.         ld a,1
  993.         sta typ1
  994.         lda sval1
  995.         or 60h          ;tell that we have a value in addition to
  996.         sta sval1       ;a flag setting.
  997.         ret
  998.  
  999. ;
  1000. ; Convert logical flag setting to value in HL:
  1001. ;
  1002.  
  1003. cvtlvh: lda sval1
  1004.         and 4
  1005.         ret z
  1006.         lda sval1       ;do we already have a value in a reg?
  1007.         and 20h
  1008.         jp z,cvtlh1
  1009.         lda sval1       ;yes. if in HL, leave it there
  1010.         and 0c0h
  1011.         ret z
  1012.         call gexdehl    ;else put into HL
  1013.         lda sval1
  1014.         and 3fh         ;tell that result is in HL
  1015.         sta sval1
  1016.         ret
  1017.  
  1018. cvtlh1: lda sbmap1
  1019.         and 7
  1020.         call cvtvd2
  1021.         and 3fh
  1022.         sta sval1
  1023.         ret
  1024.  
  1025. flagct: dw macf1,macf2,macf3,macf4,macf4a,macf4b
  1026.         dw macf5,macf6,macf7,macf8,macf8a,macf8b
  1027.  
  1028. cjoptb: db 0cah,0c2h,0dah,0d2h,0f2h,0fah,0c3h
  1029.  
  1030. ;
  1031. ; Generate conditional jump-on-true:
  1032. ;
  1033.  
  1034. gncjt:  push hl
  1035.         lhld ltabp
  1036.         dec hl
  1037.         ld a,(hl)
  1038.         or 1
  1039.         ld (hl),a
  1040.         dec hl
  1041.         dec hl
  1042.         dec hl
  1043.         ld d,(hl)
  1044.         dec hl
  1045.         ld e,(hl)
  1046.         ex de,hl
  1047.         shld sr0
  1048.         lda sval1               ;constant?
  1049.         and 1
  1050.         jp z,gncjt2
  1051.         lhld svv1               ;yes. do jump if true, else don't
  1052.         ld a,h
  1053.         or l
  1054.         pop hl
  1055.         ret z
  1056. gncjt1: ld a,6
  1057.         jp gncjt3
  1058.  
  1059. gncjt2: lda sval1               ;flag setting?
  1060.         and 4
  1061.         pop hl
  1062.         jp z,gncjt4
  1063.         lda sbmap1              ;yes. find which one and do it.
  1064.         and 7
  1065. gncjt3: push hl
  1066.         ld e,a
  1067.         ld d,0
  1068.         ld hl,cjoptb
  1069.         add hl,de
  1070.         ld a,(hl)
  1071.         call genb
  1072.         ld de,mac36a
  1073.         call mcrog
  1074.         pop hl
  1075.         ret
  1076.  
  1077. gncjt4: lda sval1               ;lvalue?
  1078.         and 2
  1079.         jp nz,gncjt1            ;if so, always generate a jump
  1080.         lda sval1               ;value in DE?
  1081.         and 0c0h
  1082.         jp nz,gncjt6            ;if so, go handle
  1083.         ld de,mac33             ;do "ld a,h - or l - jp nz,sr0" if not char
  1084.         call tschr
  1085.         jp nz,gncjt5
  1086.         ld de,mac7a             ;if char, do "ld a,l - or a - jp nz,sr0"
  1087. gncjt5: call mcrog
  1088.         ret
  1089.  
  1090. gncjt6: ld de,mac33d
  1091.         call tschr
  1092.         jp nz,gncjt5
  1093.         ld de,mac7ad
  1094.         jp gncjt5
  1095.  
  1096. ;
  1097. ; Generate conditional jump-on-false:
  1098. ;
  1099.  
  1100. gncjf:  push hl
  1101.         lhld ltabp
  1102.         dec hl
  1103.         ld a,(hl)
  1104.         or 80h
  1105.         ld (hl),a
  1106.         dec hl
  1107.         ld d,(hl)
  1108.         dec hl
  1109.         ld e,(hl)
  1110.         ex de,hl
  1111.         shld sr0
  1112.         lda sval1               ;constant?
  1113.         and 1
  1114.         jp z,gncjf2
  1115.         lhld svv1               ;yes. either jump or don't.
  1116.         ld a,h
  1117.         or l
  1118.         pop hl
  1119.         ret nz
  1120. gncjf1: ld a,6
  1121.         jp gncjt3
  1122.  
  1123. gncjf2: lda sval1               ;not a constant. flag setting?
  1124.         and 4
  1125.         pop hl
  1126.         jp z,gncjf4
  1127.         lda sbmap1              ;yes. do appropriate cond'l jp
  1128.         and 7
  1129.         xor 1
  1130.         jp gncjt3
  1131.  
  1132. gncjf4: lda sval1               ;not a flag or constant; must be value.
  1133.         and 2
  1134.         ret nz                  ;ignore if lvalue (can't be "false")
  1135.         lda sval1               ;value in DE?
  1136.         and 0c0h
  1137.         jp nz,gncjf6            ;if so, go handle
  1138.         ld de,mac0d             ;do "ld a,h - or l - jp z,sr0" if not char
  1139.         call tschr
  1140.         jp nz,gncjf5
  1141.         ld de,mac07             ;use "ld a,l - or a - jp z,sr0" if char
  1142. gncjf5: call mcrog
  1143.         ret
  1144.  
  1145. gncjf6: ld de,mac0dd
  1146.         call tschr
  1147.         jp nz,gncjf5
  1148.         ld de,mac07d
  1149.         jp gncjf5
  1150.  
  1151.  
  1152. ;
  1153. ; "Or" the current and last "false-label-used" bits:
  1154. ;
  1155.  
  1156. ltabfo: push hl
  1157.         lhld ltabp
  1158.         dec hl
  1159.         ld a,(hl)
  1160.         and 80h
  1161. ltbfo1: dec hl
  1162.         dec hl
  1163.         dec hl
  1164.         dec hl
  1165.         dec hl
  1166.         or (hl)
  1167.         ld (hl),a
  1168.         pop hl
  1169.         ret
  1170.  
  1171. ;
  1172. ; "Or" the current and last "true-label-used" bits:
  1173. ;
  1174.  
  1175. ltabto: push hl
  1176.         lhld ltabp
  1177.         dec hl
  1178.         ld a,(hl)
  1179.         and 1
  1180.         jp ltbfo1
  1181.  
  1182. ;
  1183. ; Routine to generate a forward jump and push the label value
  1184. ; used on the stack before returning:
  1185. ;
  1186.  
  1187. gfjp:   ex (sp),hl              ;put text pointer on stack, get HL = ret address
  1188.         shld retadd     ;save return address
  1189.         push af
  1190.         call glbl       ;get a label
  1191.         shld sr0
  1192.         pop af
  1193.         ex (sp),hl              ;put it on stack, get text pointer back in HL
  1194.         push af
  1195.         ld de,mac36
  1196.         call mcrog      ;generate the jump
  1197.         pop af
  1198.         push hl         ;save text pointer
  1199.         lhld retadd     ;get return address
  1200.         ex (sp),hl              ;put ret addr on stack, get HL=text pointer    
  1201.         ret             ;and all done. Tricky, huh?    
  1202.  
  1203. ;
  1204. ; Routine to pop label value off stack and define the label at the
  1205. ; current code position:
  1206. ;
  1207.  
  1208. plvdl:  ex (sp),hl              ;get return address in HL, put text pointer on stack
  1209.         shld retadd     ;save return address
  1210.         pop hl          ;get HL = text pointer
  1211.         pop de          ;get label value in DE
  1212.         push hl         ;put text pointer back on stack
  1213.         push af
  1214.         call entl       ;enter the label value
  1215.         pop af
  1216.         lhld retadd     ;get return addr back in HL
  1217.         ex (sp),hl              ;push ret address on stack, get HL = text ptr
  1218.         ret             ;all done.
  1219.  
  1220. ;
  1221. ; Routine to get a new symbolic label, define it at current position
  1222. ; in code, and push it on the stack for later use:
  1223. ;
  1224.  
  1225. glvdl:  ex (sp),hl              ;put text ptr on stack, get HL = ret addr
  1226.         shld retadd     ;save return address
  1227.         push af
  1228.         call glbl       ;get a new label
  1229.         ex de,hl                ;put in DE
  1230.         call entl       ;define it here
  1231.         ex de,hl                ;put label value back in HL
  1232.         pop af
  1233.         ex (sp),hl              ;push label on stack, get HL = text pointer
  1234.         push hl         ;push text pointer on stack
  1235.         lhld retadd     ;get return address
  1236.         ex (sp),hl              ;put ret addr on stack, get HL = text ptr
  1237.         ret             ;all done.
  1238.        
  1239. ;
  1240. ; Routine to pop a label value off the stack and generate a jump
  1241. ; to it:
  1242. ;
  1243.  
  1244. plvgj:  ex (sp),hl              ;get ret addr in HL, push text ptr on stack
  1245.         shld retadd     ;save return address
  1246.         pop de          ;get back text ptr in DE
  1247.         pop hl          ;get label value to generate jump to in HL
  1248.         shld sr0
  1249.         ex de,hl                ;put text pointer back in HL
  1250.         ld de,mac36
  1251.         call mcrog      ;generate the jump
  1252.         push hl         ;save text pointer on stack
  1253.         lhld retadd     ;get return address
  1254.         ex (sp),hl              ;put ret addr on stack, get text ptr back in HL
  1255.         ret             ;all done.
  1256.  
  1257. ;
  1258. ; Routine to flush info1 into HL; i.e, make sure that the object
  1259. ; evaluated into info1 has a value generated in the HL register:
  1260. ;
  1261.  
  1262. flshh1: push af
  1263.         push bc
  1264.         lda sval1
  1265.         ld b,a
  1266.         push hl
  1267.         lhld svv1
  1268.         shld sr0
  1269.         pop hl
  1270.         ld a,b          ;constant of some kind?
  1271.         and 3
  1272.         jp z,fls1a
  1273.         ld a,b          ;yes. simple constant?
  1274.         and 1
  1275.         jp z,fls0
  1276.         ld de,mac04     ;yes. do ld hl,sr0
  1277.         call mcrog
  1278. fls00:  xor a
  1279.         sta sval1
  1280.         jp fls1c
  1281.  
  1282. fls0:   ld a,b          ;relative lv const. local?
  1283.         and 8
  1284.         jp nz,fls0a
  1285.         call genllv     ;yes.
  1286.         jp fls00
  1287.  
  1288. fls0a:  ld de,mac6a     ;no: external
  1289.         call mcrog
  1290.         push hl
  1291.         lhld svv1
  1292.         ex de,hl
  1293.         call maddd
  1294.         pop hl
  1295.         jp fls00
  1296.  
  1297. fls1a:  ld a,b          ;flag setting?
  1298.         and 4
  1299.         jp z,fls1b
  1300.  
  1301. fls1v:  call cvtlvh     ;yes. turn it into a value in HL (if ;???
  1302.         jp fls00
  1303.  
  1304. fls1b:  ld a,b          ;value in DE ?
  1305.         and 0c0h
  1306.         jp z,fls1c
  1307.         call gexdehl    ;yes. do 'ex de,hl'
  1308.         jp fls00
  1309.  
  1310. fls1c:  pop bc          ;fine as it is.
  1311.         pop af
  1312.         ret
  1313.  
  1314.  
  1315. ;
  1316. ; Flush info1 into DE:
  1317. ;
  1318.  
  1319. flshd1: push af
  1320.         push bc
  1321.         lda sval1
  1322.         ld b,a
  1323.         push hl
  1324.         lhld svv1
  1325.         shld sr0
  1326.         pop hl
  1327.         ld a,b
  1328.         and 3
  1329.         jp z,flsd1a
  1330.         ld a,b
  1331.         and 1
  1332.         jp z,flsd0
  1333.         ld de,mac4a
  1334.         call mcrog
  1335.         jp flsd00
  1336.  
  1337. flsd0x: call gexdehl
  1338. flsd00: ld a,40h
  1339.         sta sval1
  1340.         jp flsd1c
  1341.  
  1342. flsd0:  ld a,b
  1343.         and 8
  1344.         jp nz,flsd0a
  1345.         call genllv
  1346.         jp flsd0x
  1347.  
  1348. flsd0a: ld de,mac6a
  1349.         call mcrog
  1350.         push hl
  1351.         lhld svv1
  1352.         ex de,hl
  1353.         call maddd
  1354.         pop hl
  1355.         jp flsd0x
  1356.  
  1357. flsd1a: ld a,b
  1358.         and 4
  1359.         jp z,flsd1b
  1360. flsd1v: call cvtlvd
  1361.         jp flsd00
  1362.  
  1363. flsd1b: ld a,b
  1364.         and 0c0h
  1365.         jp z,flsd0x
  1366. flsd1c: pop bc
  1367.         pop af
  1368.         ret
  1369.  
  1370. flshh2: call pshn1
  1371.         call mvn21
  1372.         call flshh1
  1373.         call mvn12
  1374.         call ppn1
  1375.         ret
  1376.  
  1377. flshd2: call pshn1
  1378.         call mvn21
  1379.         call flshd1
  1380.         call mvn12
  1381.         call ppn1
  1382.         ret
  1383.  
  1384. ;
  1385. ; Put info1 value into DE if currently in HL:
  1386. ;
  1387.  
  1388. pn1ind: push bc
  1389.         push af
  1390.         lda sval1
  1391.         ld b,a
  1392.         and 4
  1393.         jp nz,flsd1v
  1394.         ld a,b
  1395.         and 3
  1396.         jp nz,flsd1c
  1397.         jp flsd1b
  1398.  
  1399. ;
  1400. ; Put info1 value in HL if in DE:
  1401. ;
  1402.  
  1403. pn1inh: push bc
  1404.         push af
  1405.         lda sval1
  1406.         ld b,a
  1407.         and 4
  1408.         jp nz,fls1v
  1409.         ld a,b
  1410.         and 3
  1411.         jp nz,flsd1c
  1412.         jp fls1b
  1413.  
  1414.  
  1415. pn2ind: call pshn1
  1416.         call mvn21
  1417.         call pn1ind
  1418.         call mvn12
  1419.         call ppn1
  1420.         ret
  1421.  
  1422.  
  1423. ;
  1424. ; Push Optimization handlers:
  1425. ;
  1426.  
  1427. rpshp:  push hl
  1428.         push af
  1429.         push bc
  1430.         lhld pshpp
  1431.         ld a,(hl)               ;get pushop flag at current level
  1432.         and 8
  1433.         ld b,a          ;save masked off register designator bit in B
  1434.         ld a,(hl)               ;get back flag
  1435.         inc hl
  1436.         and 0a0h
  1437.         jp z,rpsh1
  1438.         ld a,20h
  1439.         or b
  1440. rpsh1:  pop bc
  1441. rpsh2:  ld (hl),a
  1442.         shld pshpp
  1443.         pop af
  1444.         pop hl
  1445.         ret
  1446.  
  1447. spshp:  push hl
  1448.         push af
  1449.         lhld pshpp
  1450.         ld a,(hl)
  1451.         and 3fh
  1452.         or 80h          ;set push bit, but preserve pushed bits (b4)
  1453.         call orincg     ;set b3 if DE holds value that needs to be pushed
  1454.         ld (hl),a               ;set current level push-op flag to "set"
  1455.         inc hl          ;now set next level for subordinate routine
  1456.         ld a,20h        ;lower-level "set push-op"
  1457.         call orincg     ;or in the register designation
  1458.         jp rpsh2        ;and go set in the pushop table.
  1459.  
  1460. orincg: push bc         ;set b3 if sval1 indicates DE holds value
  1461.         ld b,a
  1462.         lda sval1
  1463.         and 0c0h
  1464.         ld a,b
  1465.         pop bc
  1466.         ret z
  1467.         or 8
  1468.         ret
  1469.  
  1470. ppshp:  push hl
  1471.         push af
  1472.         lhld pshpp
  1473.         ld a,(hl)
  1474.         dec hl
  1475.         and 50h
  1476.         jp z,ppsh2
  1477.         ld a,(hl)
  1478.         and 80h
  1479.         jp z,ppsh1
  1480.         ld a,(hl)
  1481.         and 3fh
  1482.         or 40h
  1483.         jp rpsh2
  1484. ppsh1:  ld a,(hl)
  1485.         and 0c0h
  1486.         or 10h
  1487.         jp rpsh2
  1488. ppsh2:  ld a,(hl)
  1489.         and 7fh
  1490.         ld (hl),a
  1491.         shld pshpp
  1492.         pop af
  1493.         pop hl
  1494.         ret
  1495.  
  1496. tpshd:  push hl
  1497.         lhld pshpp
  1498.         ld a,(hl)
  1499.         pop hl
  1500.         and 40h
  1501.         jp invrt
  1502.  
  1503. genpsh: push bc
  1504.         ld b,(hl)
  1505.         cp 80h
  1506.         ld a,40h
  1507.         jp z,genp2
  1508.         ld a,10h
  1509. genp2:  ld (hl),a
  1510.         ld a,b
  1511.         and 08h
  1512.         ld a,0e5h
  1513.         jp z,genp3
  1514.         ld a,0d5h
  1515. genp3:  call genb
  1516.         pop bc
  1517.         ret
  1518.  
  1519. ;
  1520. ; Special hacks to generate come super-common op codes:
  1521. ;
  1522.  
  1523. gpushh: push af
  1524.         ld a,0e5h
  1525. gpshh1: call genb
  1526.         pop af
  1527.         ret
  1528.  
  1529. gpoph:  push af
  1530.         ld a,0e1h
  1531.         jp gpshh1
  1532.  
  1533. gpushd: push af
  1534.         ld a,0d5h
  1535.         jp gpshh1
  1536.  
  1537. gpopd:  push af
  1538.         ld a,0d1h
  1539.         jp gpshh1
  1540.  
  1541. gexdehl:        push af
  1542.         ld a,0ebh
  1543.         jp gpshh1
  1544.  
  1545. tcnst1: lda sval1
  1546.         and 3
  1547.         jp invrt
  1548.  
  1549. tcnst2: lda sval2
  1550.         and 3
  1551.         jp invrt
  1552.  
  1553.  
  1554. ;
  1555. ; The actual macros:
  1556. ;
  1557.  
  1558.         IF I80
  1559. mcend:  equ 38h         ;end of macro: mcend
  1560. mcerp:  equ 0cbh        ;enter relocation parameter: mcerp
  1561. mcesr:  equ 0efh        ;enter symbolic reference: mcesr <srn>
  1562.  
  1563. mcsr0:  equ 8h          ;substitute value in sr0
  1564. mcsr1:  equ 10h         ;                 in sr1
  1565. mcsr2:  equ 18h         ;                 in sr2
  1566. mcsr3:  equ 20h         ;                 in sr3
  1567. mcsr4:  equ 28h         ;                 in sr4
  1568. mcsr5:  equ 30h         ;                 in sr5
  1569.  
  1570. mcdr0:  equ 0c7h        ;define label   in sr0
  1571. mcdr1:  equ 0cfh        ;               in sr1
  1572. mcdr2:  equ 0d7h        ;               in sr2
  1573. mcdr3:  equ 0dfh        ;               in sr3
  1574. mcdr4:  equ 0e7h        ;               in sr4
  1575.  
  1576. ;litrl: equ 0f7h
  1577.         ENDIF
  1578.  
  1579.  
  1580.  
  1581.  
  1582. ;
  1583. ; The actual macros:
  1584. ;
  1585.  
  1586. ;
  1587. ; New macro sequeces added for the 1.4 optimizer (especially the
  1588. ; new alugen):
  1589. ;
  1590.  
  1591. macih4: inc hl
  1592. macih3: inc hl
  1593. macih2: inc hl
  1594. macih1: inc hl
  1595.         db mcend
  1596.  
  1597. macid4: inc de
  1598. macid3: inc de
  1599. macid2: inc de
  1600. macid1: inc de
  1601.         db mcend
  1602.  
  1603. macdh4: dec hl
  1604. macdh3: dec hl
  1605. macdh2: dec hl
  1606. macdh1: dec hl
  1607.         db mcend
  1608.  
  1609. macdd4: dec de
  1610. macdd3: dec de
  1611. macdd2: dec de
  1612. macdd1: dec de
  1613.         db mcend
  1614.  
  1615. mache5: dec hl
  1616. mache4: dec hl
  1617. mache3: dec hl
  1618. mache2: dec hl
  1619. mache1: dec hl
  1620. mache0: ld a,h
  1621.         or l
  1622.         db mcend
  1623.  
  1624. macde5: dec de
  1625. macde4: dec de
  1626. macde3: dec de
  1627. macde2: dec de
  1628. macde1: dec de
  1629. macde0: ld a,d
  1630.         or e
  1631.         db mcend
  1632.  
  1633. mchen5: inc hl
  1634. mchen4: inc hl
  1635. mchen3: inc hl
  1636. mchen2: inc hl
  1637. mchen1: inc hl
  1638.         ld a,h
  1639.         or l
  1640.         db mcend
  1641.  
  1642. mcden5: inc de
  1643. mcden4: inc de
  1644. mcden3: inc de
  1645. mcden2: inc de
  1646. mcden1: inc de
  1647.         ld a,d
  1648.         or e
  1649.         db mcend
  1650.  
  1651. mcddd1: ex de,hl
  1652.         add hl,hl
  1653.         db mcend
  1654.  
  1655. mcddd2: ex de,hl
  1656.         add hl,hl
  1657.         add hl,hl
  1658.         db mcend
  1659.  
  1660. mcddd3: ex de,hl
  1661.         add hl,hl
  1662.         add hl,hl
  1663.         add hl,hl
  1664.         db mcend
  1665.  
  1666. mcddd4: ex de,hl
  1667.         add hl,hl
  1668.         add hl,hl
  1669.         add hl,hl
  1670.         add hl,hl
  1671.         db mcend
  1672.  
  1673. mcddd5: ex de,hl
  1674. mcddh5: add hl,hl
  1675. mcddh4: add hl,hl
  1676. mcddh3: add hl,hl
  1677. mcddh2: add hl,hl
  1678. mcddh1: add hl,hl
  1679.         db mcend
  1680.  
  1681. mac0ca: add hl,de
  1682.         db mcend
  1683.  
  1684. macsb1: db 11h,mcsr2,19h,mcend          ;ld de,sr2-add hl,de
  1685.  
  1686. mcsb1a: db 11h,mcsr2,19h,7ch,0b5h,mcend ;ld de,sr2-add hl,de-ld a,h-or l
  1687.  
  1688. macsb2: db 21h,mcsr2,19h,mcend          ;ld hl,sr2-add hl,de
  1689.  
  1690. mcsb1b: db 21h,mcsr2,19h,7ch,0b5h,mcend ;ld hl,sr2-add hl,de-ld a,h-or l
  1691.  
  1692. macsb3: db 0cdh                         ;call cmh-add hl,de
  1693.         db litrl
  1694.         dw cmhl
  1695.         add hl,de
  1696.         db mcend
  1697.  
  1698. macsb4: db 0cdh                         ;call cmd-add hl,de
  1699.         db litrl
  1700.         dw cmd
  1701.         add hl,de
  1702.         db mcend
  1703.  
  1704. macsb5: db 11h,mcsr4,19h,mcend          ;ld de,sr4-add hl,de
  1705. macsb6: db 21h,mcsr4,19h,mcend          ;ld hl,sr4-add hl,de
  1706.  
  1707. macsb7: db 11h,mcsr4            ;ld de,sr4
  1708.         add hl,de
  1709.         ld a,h
  1710.         rla
  1711.         db mcend
  1712.  
  1713. macsb8: db 21h,mcsr4            ;ld hl,sr4
  1714.         add hl,de
  1715.         ld a,h
  1716.         rla
  1717.         db mcend
  1718.  
  1719. macsb9: db 11h,mcsr2            ;ld de,sr2
  1720.         add hl,de
  1721.         ld a,h
  1722.         rla
  1723.         db mcend
  1724.  
  1725. macsba: db 21h,mcsr2            ;ld hl,sr2
  1726.         add hl,de
  1727.         ld a,h
  1728.         rla
  1729.         db mcend
  1730.  
  1731. macac1: xor a
  1732.         ld (hl),a
  1733.         inc hl
  1734.         ld (hl),a
  1735.         db mcend
  1736.  
  1737. macac3: db 11h,mcsr0            ;ld de,sr0
  1738.         ld (hl),e
  1739.         inc hl
  1740.         ld (hl),d
  1741.         db mcend
  1742.  
  1743. macac4: ld (hl),e
  1744.         inc hl
  1745.         ld (hl),0
  1746.         db mcend
  1747.  
  1748. macac5: ld d,0
  1749.         ld (hl),e
  1750.         inc hl
  1751.         ld (hl),d
  1752.         db mcend
  1753.  
  1754. macacb: db 32h,mcsr0,mcend              ;sta sr0
  1755.  
  1756. macacc: db 21h,mcsr1,22h,mcsr0,mcend    ;ld hl,sr1-shld sr0
  1757.  
  1758.  
  1759. ;
  1760. ; Macros for function entry and exit:
  1761. ;
  1762.  
  1763.                 ;entry code for frame size non-zero OR  formal parms
  1764. mfntry: push bc
  1765.         db 21h,mcsr0    ;ld hl,sr0
  1766.         add hl,sp
  1767.         ld sp,hl
  1768.         ld b,h
  1769.         ld c,l
  1770.         db mcend
  1771.  
  1772.                 ;as above, but no ld sp,hl 'cause frame size is 0. This
  1773.                 ; is just to set new BC value. entire system could
  1774.                 ;use improvment, say to know to just dec bc twice for
  1775.                 ;each parameter up until 2...
  1776. mfntr2: push bc
  1777.         db 21h, mcsr0   ;ld hl,sr0
  1778.         add hl,sp
  1779.         ld b,h
  1780.         ld c,l
  1781.         db mcend
  1782.  
  1783.  
  1784. mfex1:  db mcdr1        ;define exit label
  1785.         db mcend
  1786.  
  1787.                 ;exit code for frame size > 6
  1788. mfex2:  ex de,hl
  1789.         db 21h,mcsr0    ;sr1: ex de,hl - ld hl,sr0 -
  1790.         add hl,sp                      
  1791.         ld sp,hl
  1792.         ex de,hl
  1793. mfex3:  pop bc  ;used in stret: routine for quick return (n);
  1794. mfex4:  ret     ;processing when not at end of function
  1795.         db mcend
  1796.  
  1797.  
  1798. ;
  1799. ; Macros for ++ and -- operator processing:
  1800. ;
  1801.  
  1802. m12:    inc (hl)
  1803.         ld l,(hl)
  1804.         db mcend
  1805.  
  1806. m12a:   inc (hl)
  1807.         db mcend
  1808.  
  1809. m13:    ld a,(hl)
  1810.         inc (hl)
  1811.         ld l,a
  1812.         db mcend
  1813.  
  1814. m14:    dec (hl)
  1815.         ld l,(hl)
  1816.         db mcend
  1817.  
  1818. m14a:   dec (hl)
  1819.         db mcend
  1820.  
  1821. m15:    ld a,(hl)
  1822.         dec (hl)
  1823.         ld l,a
  1824.         db mcend
  1825.  
  1826. m16b:   ld e,(hl)
  1827.         inc hl
  1828.         ld d,(hl)
  1829.         inc de
  1830.         ld (hl),d
  1831.         dec hl
  1832.         ld (hl),e
  1833.         db mcend
  1834.  
  1835. m16bz:  rst 0x38;7              ;substitute for m16b if -z7 in effect
  1836.         inc de
  1837.         ld (hl),d
  1838.         dec hl
  1839.         ld (hl),e
  1840.         db mcend
  1841.  
  1842. me16b:  db 2ah,mcsr0            ;lhld sr0- inc hl- shld sr0
  1843.         inc hl
  1844.         db 22h,mcsr0
  1845.         db mcend
  1846.  
  1847. m18:    ld e,(hl)
  1848.         inc hl
  1849.         ld d,(hl)
  1850.         dec de
  1851.         ld (hl),d
  1852.         dec hl
  1853.         ld (hl),e
  1854.         db mcend
  1855.  
  1856. m18z:   rst 0x38;7
  1857.         dec de
  1858.         ld (hl),d
  1859.         dec hl
  1860.         ld (hl),e
  1861.         db mcend
  1862.  
  1863. me18:   db 2ah,mcsr0,2bh,22h,mcsr0,mcend        ; lhld sr0- dec hl- shld sr0
  1864.  
  1865. m20:    ld e,(hl)
  1866.         inc hl
  1867.         ld d,(hl)
  1868.         db mcend
  1869.  
  1870. m20z:   rst 0x38;7
  1871.         db mcend
  1872.  
  1873. m21:    push de
  1874.         db mcend
  1875.  
  1876. me21:   push hl
  1877.         db mcend
  1878.  
  1879. m22:    inc de
  1880.         db mcend
  1881.  
  1882. me22:   inc hl
  1883.         db mcend
  1884.  
  1885. m23:    dec de
  1886.         db mcend
  1887.  
  1888. me23:   dec hl
  1889.         db mcend
  1890.  
  1891. m26:    push hl
  1892.         db 21h,mcsr0            ;ld hl,sr0
  1893.         add hl,de
  1894.         ex de,hl
  1895.         pop hl
  1896.         db mcend
  1897.  
  1898. me26:   db 11h,mcsr1,19h,mcend  ; ld de,sr1- add hl,de
  1899.  
  1900. m27:    db 7bh,mcsr1,5fh,7ah,mcsr2,57h,mcend
  1901.                                 ; ld a,e-sr1-ld e,a-ld a,d-sr2-
  1902.                                 ; ld d,a  (sr1 and sr2 will contain
  1903.                                 ; code sequences like `sub value')
  1904.  
  1905. me27:   db 11h,mcsr2    ;ld de,sr2
  1906.         add hl,de
  1907.         db mcend
  1908.  
  1909. m28:    ld (hl),d
  1910.         dec hl
  1911.         ld (hl),e
  1912.         db mcend
  1913.  
  1914. m30:    pop de
  1915.         db mcend
  1916.  
  1917. me30:   pop hl
  1918.         db mcend
  1919.  
  1920. mnul:   db mcend                        ; null (generates nothing)
  1921.  
  1922. macn:   equ mnul                ; an alias for `null'
  1923.  
  1924. ;
  1925. ; Misc. utility sequences:
  1926. ;
  1927.  
  1928. mac6e:  ld l,(hl)
  1929.         db mcend
  1930.  
  1931. mac38:  db 0c3h,0,0,mcend               ; jp 0  (used to create the jump
  1932.                                 ; vector at start of functions)
  1933.  
  1934. mac40:  db 2ah,mcsr0,mcend              ; lhld sr0
  1935.  
  1936. mac40r: db 2ah,mcerp,mcsr0,mcend        ; lhld sr0 (relocate the address)
  1937.  
  1938. mac41:  db 21h,mcsr0,9,mcend            ; ld hl,sr0-add hl,bc
  1939.  
  1940. mac42:  ld (hl),e
  1941.         inc hl
  1942.         ld (hl),d
  1943.         db mcend
  1944.  
  1945. mcn10:  equ mache0
  1946.  
  1947. mcn11:  ld a,l
  1948.         or a
  1949.         db mcend
  1950.  
  1951. mcn12:  ld a,e
  1952.         or a
  1953.         db mcend
  1954.  
  1955. mcn13:  ld a,h
  1956.         or a
  1957.         db mcend
  1958.  
  1959. mcn14:  ld a,d
  1960.         or a
  1961.         db mcend
  1962.  
  1963. macrdl: ld a,d
  1964.         rla
  1965.         db mcend
  1966.  
  1967. macrhl: ld a,h
  1968.         rla
  1969.         db mcend
  1970.  
  1971. mac0d:  ld a,h
  1972.         or l
  1973.         db 0cah,mcesr,mcsr0,mcend ; jp z,foo
  1974.  
  1975. mac33:  ld a,h
  1976.         or l
  1977.         db 0c2h,mcesr,mcsr0,mcend ; jp nz,foo
  1978.  
  1979.  
  1980. mac07:  ld a,l
  1981.         or a
  1982.         db 0cah,mcesr,mcsr0,mcend   ; ld a,l-or a-jp z,sr0
  1983.  
  1984. mac0dc: equ mac07               ; another alias
  1985.  
  1986. mac7a:  ld a,l
  1987.         or a
  1988.         db 0c2h,mcesr,mcsr0,mcend   ; ld a,l-or a-jp nz,sr0
  1989.  
  1990. mac33c: equ mac7a               ; gotta get that ole' USE FACTOR up there!
  1991.  
  1992. mac33d: ld a,d
  1993.         or e
  1994.         db 0c2h,mcesr,mcsr0,mcend       ;jp nz,sr0
  1995.  
  1996. mac0dd: ld a,d
  1997.         or e
  1998.         db 0cah,mcesr,mcsr0,mcend       ;jp z,sr0
  1999.  
  2000. mac7ad: ld a,e
  2001.         or a
  2002.         db 0c2h,mcesr,mcsr0,mcend       ;jp nz,sr0
  2003.  
  2004. mac07d: ld a,e
  2005.         or a
  2006.         db 0cah,mcesr,mcsr0,mcend       ;jp z,sr0
  2007.  
  2008. mac35:  db mcsr0,0bdh,0c2h,mcesr,mcsr1,mcsr2
  2009.         db 0bch,0cah,mcesr,mcsr3,mcdr1,mcend
  2010.                                 ; sr0-cp l-jp nz,bar-sr1-cp h-
  2011.                                 ; jp z,sr3-bar: ...
  2012.  
  2013. mac35d: db mcsr0,0bbh,0c2h,mcesr,mcsr1,mcsr2
  2014.         db 0bah,0cah,mcesr,mcsr3,mcdr1,mcend
  2015.                                 ; sr0-cp e-jp nz,bar-sr1-cp d-
  2016.                                 ; jp z,sr3-bar: ...
  2017.  
  2018. mac35c: db mcsr0,0cah,mcesr,mcsr3,mcend
  2019.                                 ; sr0-jp z,sr3
  2020.  
  2021. mac71c: ld a,l
  2022.         cp e
  2023.         db mcend
  2024.  
  2025. mac36:  db 0c3h,mcesr,mcsr0,mcend       ; jp sr0
  2026.  
  2027. mac36a: db mcesr,mcsr0,mcend            ; just "sr0", with a relocation parm
  2028.  
  2029. mac37:  equ mac36               ; alias for mac36
  2030.  
  2031. maca0:  ld a,(hl)
  2032.         inc hl
  2033.         ld h,(hl)
  2034.         ld l,a
  2035.         db mcend
  2036.  
  2037. mac04:  db 21h,mcsr0,mcend              ; ld hl,sr0
  2038.  
  2039. mac4a:  db 11h,mcsr0,mcend              ; ld de,sr0
  2040.  
  2041. mac6a:  db 2ah                  ; lhld extbas
  2042.         db litrl                ; (gets base-of-external-data-area
  2043.         dw extbas               ; pointer into HL)
  2044.         db mcend
  2045.  
  2046.  
  2047. mac09:  db 22h,mcsr0,mcend              ; shld sr0
  2048.  
  2049. ;
  2050. ; Macros for function call generation
  2051. ;
  2052.  
  2053. mac08:  db 0cdh,mcerp,mcsr3,mcend    ; call sr3  (note the `cb'
  2054.                                 ; causes a reloc parameter to be generated)
  2055.                                 ;(Note: this is the code generated for
  2056.                                 ;function calls)
  2057.  
  2058. mac8a:  db 21h,mcesr,mcsr2      ; ld hl,foo
  2059.         push hl
  2060.         db 21h,mcsr1            ; ld hl,sr1
  2061.         add hl,sp
  2062.         ld a,(hl)
  2063.         inc hl
  2064.         ld h,(hl)
  2065.         ld l,a
  2066.         jp (hl)
  2067.         db mcdr2,mcend          ; foo: ...
  2068.                                 ;(generated for calls to non-simple funcs)
  2069.  
  2070. mac8ar: ex de,hl
  2071.         db 21h,mcsr0    ; ld hl,sr0
  2072.         add hl,sp
  2073.         ld sp,hl
  2074.         ex de,hl
  2075.         db mcend                ;(cleans up stack on return from func call)
  2076.  
  2077. ;
  2078. ; More misc. stuff:
  2079. ;
  2080.  
  2081. mac61:  ld h,0
  2082.         db mcend
  2083.  
  2084. mac62:  ld d,0
  2085.         db mcend
  2086.  
  2087. maca1:  ld (hl),e
  2088.         inc hl
  2089.         ld (hl),d
  2090.         db mcend
  2091.  
  2092. maca9:  ld (hl),e
  2093.         inc hl
  2094.         xor a
  2095.         ld (hl),a
  2096.         db mcend
  2097.  
  2098. ;
  2099. ; Here are some macros to generate calls to routines
  2100. ; within the C.CCC runtime utility package:
  2101. ;
  2102.  
  2103. macf1:  db 0cdh         ;call pzinh
  2104.         db litrl
  2105.         dw pzinh
  2106.         db mcend
  2107.  
  2108. macf2:  db 0cdh         ;call pnzinh
  2109.         db litrl
  2110.         dw pnzinh
  2111.         db mcend
  2112.  
  2113. macf3:  db 0cdh         ;call pcinh
  2114.         db litrl
  2115.         dw pcinh
  2116.         db mcend
  2117.  
  2118. macf4:  db 0cdh         ;call pncinh
  2119.         db litrl
  2120.         dw pncinh
  2121.         db mcend
  2122.  
  2123. macf4a: db 0cdh         ;call ppinh
  2124.         db litrl
  2125.         dw ppinh
  2126.         db mcend
  2127.  
  2128. macf4b: db 0cdh         ;call pminh
  2129.         db litrl
  2130.         dw pminh
  2131.         db mcend
  2132.  
  2133. macf5:  db 0cdh         ;call pzind
  2134.         db litrl
  2135.         dw pzind
  2136.         db mcend
  2137.  
  2138. macf6:  db 0cdh         ;call pnzind
  2139.         db litrl
  2140.         dw pnzind
  2141.         db mcend
  2142.  
  2143. macf7:  db 0cdh         ;call pcind
  2144.         db litrl
  2145.         dw pcind
  2146.         db mcend
  2147.  
  2148. macf8:  db 0cdh         ;call pncind
  2149.         db litrl
  2150.         dw pncind
  2151.         db mcend
  2152.  
  2153. macf8a: db 0cdh         ;call ppind
  2154.         db litrl
  2155.         dw ppind
  2156.         db mcend
  2157.  
  2158. macf8b: db 0cdh         ;call pmind
  2159.         db litrl
  2160.         dw pmind
  2161.         db mcend
  2162.  
  2163.  
  2164. mcumul:
  2165. mac63u: db 0cdh                 ; call usmul
  2166.         db litrl
  2167.         dw usmul
  2168.         db mcend
  2169.  
  2170. mcsmul:
  2171. mac63s: db 0cdh                 ; call smul
  2172.         db litrl
  2173.         dw smul
  2174.         db mcend
  2175.  
  2176. mcdiv5: ex de,hl
  2177. mcudiv:
  2178. mac64u: db 0cdh                 ; call usdiv
  2179.         db litrl
  2180.         dw usdiv
  2181.         db mcend
  2182.  
  2183. mcdiv7: ex de,hl
  2184. mcsdiv:
  2185. mac64s: db 0cdh                 ; call sdiv
  2186.         db litrl
  2187.         dw sdiv
  2188.         db mcend
  2189.  
  2190. mcmod5: ex de,hl
  2191. mcumod:
  2192. mac79u: db 0cdh                 ; call usmod
  2193.         db litrl
  2194.         dw usmod
  2195.         db mcend
  2196.  
  2197. mcmod7: ex de,hl
  2198. mcsmod:
  2199. mac79s: db 0cdh                 ; call smod
  2200.         db litrl
  2201.         dw smod
  2202.         db mcend
  2203.  
  2204. mcalbu:
  2205. mac68:  db 0cdh                 ; call albu (DE < HL unsigned?)
  2206.         db litrl
  2207.         dw albu
  2208.         db mcend
  2209.  
  2210. mcagbu:
  2211. mac69:  db 0cdh                 ; call agbu (DE > HL unsigned?)
  2212.         db litrl
  2213.         dw agbu
  2214.         db mcend
  2215.  
  2216. mcalbs:
  2217. mac68s: db 0cdh                 ; call albs (DE <= HL signed?)
  2218.         db litrl
  2219.         dw albs
  2220.         db mcend
  2221.  
  2222. mcagbs:
  2223. mac69s: db 0cdh                 ; call agbs (DE > HL signed?)
  2224.         db litrl
  2225.         dw agbs
  2226.         db mcend
  2227.  
  2228. mcbgau: db 0cdh
  2229.         db litrl
  2230.         dw bgau
  2231.         db mcend
  2232.  
  2233. mcbgas: db 0cdh
  2234.         db litrl
  2235.         dw bgas
  2236.         db mcend
  2237.  
  2238. mcblau: db 0cdh
  2239.         db litrl
  2240.         dw blau
  2241.         db mcend
  2242.  
  2243. mcblas: db 0cdh
  2244.         db litrl
  2245.         dw blas
  2246.         db mcend
  2247.  
  2248.  
  2249. mceq:
  2250. mac71:  db 0cdh                 ; tests equality of DE and HL
  2251.         db litrl
  2252.         dw eqwel
  2253.         db mcend
  2254.  
  2255. maccom: db 0cdh                 ;2's complement HL
  2256.         db litrl
  2257.         dw cmhl
  2258.         db mcend
  2259.  
  2260. maccmd: db 0cdh                 ;2's complement DE
  2261.         db litrl
  2262.         dw cmd
  2263.         db mcend
  2264.  
  2265. macsad: equ mac0ca
  2266.  
  2267. macslh: db 0cdh,litrl           ;shift HL left by E bits
  2268.         dw shllbe
  2269.         db mcend
  2270.  
  2271. macsld: db 0cdh,litrl           ;shift DE left by L bits
  2272.         dw sdelbl
  2273.         db mcend
  2274.  
  2275. macsrh: db 0cdh,litrl           ;shift HL right by E bits
  2276.         dw shlrbe
  2277.         db mcend
  2278.  
  2279. macsrd: db 0cdh,litrl           ;shift DE right by L bits
  2280.         dw sderbl
  2281.         db mcend
  2282.  
  2283. mcssbh: db 0cdh,litrl           ;subtract HL from DE, result in HL
  2284.         dw cmhl                 ;call cmhl
  2285.         add hl,de
  2286.         db mcend
  2287.  
  2288. mcssbd: db 0cdh,litrl           ;subract DE from HL, result in HL
  2289.         dw cmd
  2290.         add hl,de
  2291.         db mcend
  2292.  
  2293.  
  2294. ;
  2295. ; bitwise operator macros:
  2296. ;
  2297.  
  2298. mcand:
  2299. mac73:  ld a,h
  2300.         and d
  2301.         ld h,a
  2302.         ld a,l
  2303.         and e
  2304.         ld l,a
  2305.         db mcend
  2306.  
  2307. mcxor:
  2308. mac74:  ld a,h
  2309.         xor d
  2310.         ld h,a
  2311.         ld a,l
  2312.         xor e
  2313.         ld l,a
  2314.         db mcend
  2315.  
  2316. mcor:
  2317. mac75:  ld a,h
  2318.         or d
  2319.         ld h,a
  2320.         ld a,l
  2321.         or e
  2322.         ld l,a
  2323.         db mcend
  2324.  
  2325. mac0a:  db 11h,mcsr0,0cdh               ; ld de,sr0-call usmul
  2326.         db litrl                ;  (used for subscript calculation)
  2327.         dw usmul
  2328.         db mcend
  2329.  
  2330. mac0c:  db 11h,mcsr0    ; ld de,sr0
  2331.         add hl,de
  2332.         db mcend
  2333.  
  2334. mac98a: db 21h,mcesr,mcsr0,mcend  ;ld hl,foo (foo to be defined later on)
  2335.  
  2336. mac98:  db 21h,mcesr,mcsr0      ;ld hl,foo
  2337.         db 0c3h,mcesr,mcsr1     ;jp sr1
  2338.         db mcdr0,mcend          ; foo:
  2339.  
  2340. mac01:  ld a,l
  2341.         cpl
  2342.         ld l,a
  2343.         inc l
  2344.         ld h,0ffh
  2345.         db mcend
  2346.  
  2347. mac0e:  db 0cdh
  2348.         db litrl
  2349.         dw cmhl
  2350.         db mcend
  2351.  
  2352. macad1: db 0e5h,21h,mcsr0,0cdh  ; push hl-ld hl,sr0-
  2353.         db litrl                ; call usmul
  2354.         dw usmul                ; (used to scale value in DE before
  2355.         pop de
  2356.         db mcend                ; adding it to pointer in HL)
  2357.  
  2358. macd1a: ex de,hl
  2359.         add hl,hl
  2360.         ex de,hl
  2361.         db mcend
  2362.  
  2363. macad2: db 0d5h,11h,mcsr0,0cdh  ; push de-ld de,sr0-
  2364.         db litrl                ; call usmul
  2365.         dw usmul                ; (used to scale value in HL before
  2366.         pop de
  2367.         db mcend                ; adding it to pointer in DE)
  2368.  
  2369. macad3: ex de,hl
  2370.         db 21h,mcsr0,0cdh       ; ex de,hl-ld hl,sr0-
  2371.         db litrl                ; call usdiv
  2372.         dw usdiv                ; (used to scale result after two
  2373.         db mcend                        ; pointers are subtracted
  2374.  
  2375. macad4: xor a
  2376.         ld a,h
  2377.         rra
  2378.         ld h,a
  2379.         ld a,l
  2380.         rra
  2381.         ld l,a
  2382.         db mcend
  2383.  
  2384. mac1a:  ld a,l
  2385.         cpl
  2386.         ld l,a
  2387.         ld h,0ffh
  2388.         db mcend
  2389.  
  2390. mac1b:  ld a,l
  2391.         cpl
  2392.         ld l,a
  2393.         ld a,h
  2394.         cpl
  2395.         ld h,a
  2396.         db mcend
  2397.  
  2398. mac05:  db 21h,mcerp,mcsr0      ; ld hl,sr0
  2399.         db mcend                ; (creates a relocation parameter for
  2400.                                 ;  the data field of the lxi)
  2401.  
  2402.  
  2403. mac65m: equ mcssbh              ; HL <-- DE - HL
  2404.  
  2405. mac65b: equ macsrd              ; >>
  2406.  
  2407. mac67:  equ macsld              ; <<
  2408.  
  2409. ;
  2410. ; **** END OF MACROS ****
  2411. ;
  2412.  
  2413.         ;IF LASM
  2414.         ;link cc2e
  2415.         ;ENDIF
  2416.