home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / parasol / parasols.ark / LCOMMON.ASM < prev    next >
Encoding:
Assembly Source File  |  1986-10-06  |  14.4 KB  |  965 lines

  1. ;
  2. ;-----------------------------------------------
  3. ;
  4. ;        S Y M B O L   T A B L E
  5. ;        M A N I P U L A T I O N
  6. ;
  7. ;-----------------------------------------------
  8. ;
  9. ;
  10. ;
  11. ;-----fixup reference to built-in routine------
  12. ;
  13. ; in:    a = routine identifier
  14. ;
  15. fix.up.built.in.rtn:
  16.     push    psw
  17.     lxi    h,word
  18.     lxi    d,word.save
  19.     call    move.string
  20.     pop    psw
  21. ;
  22.     sta    word
  23.     xra    a
  24.     sta    word + 1
  25.     call    fix.up.fwd.ref.word
  26. ;
  27.     lxi    h,word.save
  28.     lxi    d,word
  29.     jmp    move.string
  30. ;
  31. ;
  32. ;
  33. ;--------------------------
  34. ;    all forward references cause all registers to be
  35. ;    undefined.  Specific cases must be handled elsewhere
  36. ;--------------------------
  37. ;
  38. ;
  39. fix.up.fwd.ref.word:
  40.     lhld    curr.ovl.start.key
  41.     push    h
  42.     call    opt.undef.all
  43.     call    init.sym.tbl.srch
  44. fufrw.lup:
  45.     call    get.sym.tbl.entry
  46.     lda    ste.type    ;any more to do?
  47.     cpi    stet.end.tbl
  48.     jz    fufrw.restore.ovl    ;exit
  49. ;
  50.     lxi    h,curr.block.level    ;is it within scope?
  51.     lda    ste.block.level
  52.     cmp    m
  53.     jc    fufrw.restore.ovl    ;exit
  54. ;
  55.     lda    ste.type    ;is it a fwd ref?
  56.     cpi    stet.fwd.ref
  57.     jnz    fufrw.lup
  58. ;
  59.     lxi    h,ste.name    ;is it same name?
  60.     lxi    d,word
  61.     call    compare.strings
  62.     jnz    fufrw.lup
  63. ;
  64.     lhld    ste.ovl.key    ;is reference in an overlay?
  65.     mov    a,h
  66.     ana    l
  67.     inr    a
  68.     jz    fufrw.not.ovl
  69. ;
  70.     lda    overlay.in.process    ;patch ovl-to-ovl handled same
  71.     ora    a            ;as patch com-to-com
  72.     jnz    fufrw.not.ovl
  73. ;
  74. ;---set up for overlay patch---
  75. ;
  76.     push    h        ;ovl-hdr key
  77.     call    write.code.write
  78.     ;---save COM fcb---
  79.     lxi    h,code.fcb
  80.     lxi    d,code.fcb.save
  81.     lxi    b,36
  82.     call    move.h.2.d.cnt.b
  83.     lxi    h,code.file.map
  84.     lxi    d,code.map.save
  85.     lxi    b,512
  86.     call    move.h.2.d.cnt.b
  87.     ;---replace COM fcb with OVL fcb---
  88.     lxi    h,ovl.fcb
  89.     lxi    d,code.fcb
  90.     lxi    b,36
  91.     call    move.h.2.d.cnt.b
  92.     ;---don't allocate any new ovl recs---
  93.     lxi    h,code.file.map
  94.     lxi    d,code.file.map + 1
  95.     mvi    m,0ffh
  96.     lxi    b,511
  97.     call    move.h.2.d.cnt.b
  98.     mvi    a,0ffh
  99.     sta    overlay.in.process
  100. ;
  101.     pop    h        ;ovl-hdr key
  102.     shld    ovl.sctr.offset
  103.     shld    curr.ovl.start.key
  104. ;
  105.     lhld    curr.code.addr
  106.     push    h        ;save non-ovl address
  107. ;
  108. ;---find start address of overlay---
  109. ;
  110.     lhld    start.wk.sym.tbl.addr    ;save parms for
  111.     push    h            ;get.sym.tbl.entry
  112.     lhld    wk.sym.tbl.addr
  113.     push    h
  114. ;
  115.     ;--loop for earliest label in this overlay---
  116. fufrw.get.ovl.lup:
  117.     call    get.sym.tbl.entry
  118.     lda    ste.type
  119.     cpi    stet.end.tbl        ;finished?
  120.     jz    fufrw.ovl.endlup    ;yes
  121. ;
  122.     ani    0ffh - stet.deleted    ;see what it used to be
  123.     cpi    stet.label        ;is this a label
  124.     jnz    fufrw.get.ovl.lup    ;no, can't be ovl start
  125. ;
  126.     lhld    ste.ovl.key        ;is it same overlay as patch?
  127.     xchg
  128.     lhld    ovl.sctr.offset
  129.     call    cmp.de.fm.hl
  130.     jnz    fufrw.get.ovl.lup    ;no
  131. ;
  132.     lhld    ste.address        ;the last one here is overlay-start
  133.     shld    fufrw.ovl.hdr.addr
  134.     jmp    fufrw.get.ovl.lup
  135. ;
  136. fufrw.ovl.endlup:
  137.     ;---restore previous sym-tbl search params---
  138.     pop    h
  139.     shld    wk.sym.tbl.addr
  140.     pop    h
  141.     shld    start.wk.sym.tbl.addr
  142.     lxi    d,symbol.table.entry
  143.     call    move.sym.tbl.entry
  144. fufrw.ovl.hdr.addr    equ    $+1
  145.     lxi    h,0
  146.     shld    start.code.addr
  147. ;
  148. ;---do the patch---
  149. ;
  150.     lhld    ste.address
  151.     shld    curr.code.addr
  152.     call    set.code.key
  153.     shld    code.fcb + fcb.rnd.rec
  154.     call    read.code.buff.only
  155.     pop    h        ;routine addr
  156.     push    h        ;re-save
  157.     call    put.code.word
  158.     call    write.code.write    ;force disk update
  159.     ;---set back to non-overlay COM file---
  160.     xra    a
  161.     sta    overlay.in.process
  162.     lxi    h,code.fcb.save
  163.     lxi    d,code.fcb
  164.     lxi    b,36
  165.     call    move.h.2.d.cnt.b
  166.     lxi    h,code.map.save
  167.     lxi    d,code.file.map
  168.     lxi    b,512
  169.     call    move.h.2.d.cnt.b
  170.     lxi    h,0
  171.     shld    ovl.sctr.offset
  172.     lxi    h,0100h
  173.     shld    start.code.addr
  174.     pop    h            ;restore routine addr
  175.     shld    curr.code.addr
  176.     call    set.code.key
  177.     call    read.code.buff.only
  178.     jmp    fufrw.ovl.cont
  179. ;
  180. ;---NON-overlay fix-up---
  181. ;
  182. fufrw.not.ovl:
  183.     lhld    ste.address
  184.     call    read.code
  185.     lhld    curr.code.addr
  186.     push    h
  187.     lhld    ste.address
  188.     shld    curr.code.addr
  189.     pop    h
  190.     push    h
  191.     call    put.code.word
  192.     pop    h
  193.     shld    curr.code.addr
  194. fufrw.ovl.cont:
  195.     lhld    start.wk.sym.tbl.addr
  196.     mov    a,m
  197.     ori    stet.deleted
  198.     mov    m,a
  199.     jmp    fufrw.lup
  200. ;
  201. ;
  202. fufrw.restore.ovl:
  203.     pop    h
  204.     shld    curr.ovl.start.key
  205.     ret
  206. ;
  207. ;
  208. ;
  209. ;---------------------------------------
  210. ;
  211. ;
  212. ;    put code word / put code byte
  213. ; in:    (word) - hl (put into code l then h)
  214. ;    (byte) - a
  215. ;
  216. put.code.word:
  217.     mov    a,l
  218.     push    h
  219.     call    put.code.byte
  220.     pop    h
  221.     mov    a,h
  222. put.code.byte:
  223.     push    psw
  224. ;
  225.     lhld    start.code.addr
  226.     xchg
  227.     lhld    curr.code.addr
  228.     call    cmp.de.fm.hl
  229.     cc    err.pgm.bounds
  230. ;
  231.     call    read.code
  232. ;
  233.     lhld    curr.code.addr
  234.     mov    a,l
  235.     lhld    start.code.addr
  236.     sub    l
  237.     ani    7fh
  238.     mov    l,a
  239.     mvi    h,0
  240.     lxi    d,code.buffer
  241.     dad    d
  242.     pop    psw
  243.     mov    m,a
  244.     lhld    curr.code.addr
  245.     inx    h
  246.     shld    curr.code.addr
  247.     ret
  248. ;
  249. ;
  250. ;
  251. ;
  252. ;
  253. ;---------------------------------------
  254. write.code.write:
  255.     lhld    code.fcb + fcb.rnd.rec
  256.     lxi    d,code.file.map
  257.     dad    d
  258.     mvi    m,0ffh
  259.     lxi    d,code.buffer
  260.     mvi    c,26
  261.     call    entry
  262. ;
  263. ;---add in possible overlay base sctr offset---
  264. ;
  265.     lhld    code.fcb + fcb.rnd.rec
  266.     push    h
  267.     xchg
  268.     lhld    ovl.sctr.offset
  269.     dad    d
  270.     shld    code.fcb + fcb.rnd.rec
  271.     lxi    d,code.fcb
  272.     mvi    c,34
  273.     call    entry
  274.     pop    h
  275.     shld    code.fcb + fcb.rnd.rec
  276.     push    psw
  277. ;
  278.     lxi    d,dflt.dma
  279.     mvi    c,26
  280.     call    entry
  281. ;
  282.     call    clear.code.buff
  283.     pop    psw
  284.     ora    a
  285.     rz
  286.     jmp    err.code.write
  287. ;
  288. ;
  289. ;
  290. ;
  291. ;--------------------------------------
  292. ;
  293. ;    read  code
  294. ;
  295. ;
  296. read.code:
  297.     call    set.code.key
  298.     shld    curr.read.key
  299.     xchg
  300.     lhld    code.fcb + fcb.rnd.rec
  301.     call    cmp.de.fm.hl
  302.     rz
  303. ;
  304.     call    write.code.write
  305. ;
  306.     lxi    d,0
  307. read.code.write.lup:
  308.     push    d
  309.     lxi    h,code.file.map
  310.     dad    d
  311.     mov    a,m
  312.     ora    a
  313.     jnz    read.code.written
  314. ;
  315.     xchg
  316.     shld    code.fcb + fcb.rnd.rec
  317.     call    write.code.write
  318. ;
  319. read.code.written:
  320.     pop    d
  321.     lhld    curr.read.key
  322.     call    cmp.de.fm.hl
  323.     jz    read.code.end
  324.     inx    d
  325.     jmp    read.code.write.lup
  326. ;
  327. read.code.end:
  328.     lhld    curr.read.key
  329.     shld    code.fcb + fcb.rnd.rec
  330. ;
  331.     lxi    d,code.file.map
  332.     dad    d
  333.     mov    a,m
  334.     ora    a
  335.     jz    clear.code.buff
  336. ;
  337. read.code.buff.only:
  338. ;
  339.     lxi    d,code.buffer
  340.     mvi    c,26
  341.     call    entry
  342. ;
  343.     lhld    code.fcb + fcb.rnd.rec
  344.     push    h
  345.     xchg
  346.     lhld    ovl.sctr.offset
  347.     dad    d
  348.     shld    code.fcb + fcb.rnd.rec
  349.     lxi    d,code.fcb
  350.     mvi    c,33
  351.     call    entry
  352.     pop    h
  353.     shld    code.fcb + fcb.rnd.rec
  354. ;
  355.     lxi    d,dflt.dma
  356.     mvi    c,26
  357.     jmp    entry
  358. ;
  359. ;
  360. ;
  361. ;----------------------------------
  362. ;     set code key
  363. ;
  364. ; in:    hl=memory address of code file
  365. ; out:    hl=code file key
  366. ;
  367. ;
  368. set.code.key:
  369. ;---compute offset from start of code---
  370. ;---whether offset is zero or 100h------
  371.     xchg
  372.     lhld    start.code.addr
  373.     mov    a,h
  374.     cma
  375.     mov    h,a
  376.     mov    a,l
  377.     cma
  378.     mov    l,a
  379.     inx    h
  380.     dad    d
  381. ;--shr 8 then shl 1 (shr 7)
  382.     mov    a,l
  383.     mov    l,h
  384.     mvi    h,0
  385.     dad    h
  386.     add    a
  387.     mvi    a,0
  388.     adc    l
  389.     mov    l,a
  390.     mvi    a,0
  391.     adc    h
  392.     mov    h,a
  393.     ret
  394. ;
  395. ;
  396. ;
  397. clear.code.buff:
  398.     xra    a
  399.     sta    code.buffer
  400.     lxi    h,code.buffer
  401.     lxi    d,code.buffer + 1
  402.     lxi    b,127
  403.     jmp    move.h.2.d.cnt.b
  404. ;
  405. ;
  406. ;
  407. ;
  408. ;
  409. ;---put word and 'ste.' params into symbol table---
  410. ;
  411. put.word.into.tbl:
  412.     lhld    curr.code.addr
  413.     shld    ste.address
  414. put.word.into.tbl.no.addr:
  415.     lxi    h,word
  416.     lxi    d,ste.name
  417.     call    move.string
  418. put.ste.into.tbl.no.addr:
  419.     lhld    curr.ovl.start.key
  420.     lda    overlay.in.process
  421.     ora    a
  422.     jnz    psit.is.ovl
  423.     lxi    h,0ffffh
  424. psit.is.ovl:
  425.     shld    ste.ovl.key
  426.     lda    curr.block.level
  427.     sta    ste.block.level
  428. ;
  429. ;---fall into 'move.entry.to.sym.tbl'---
  430. ;
  431. ;
  432. ;
  433. ;
  434. ;-----move symbol.table.entry into symbol table-----
  435. ; in:    symbol.table.entry
  436. ;    start.sym.tbl.addr
  437. ;
  438. ; out:    start.sym.tbl.addr
  439. ;
  440. ;
  441. move.entry.to.sym.tbl:
  442.     lxi    d,ste.name - 1
  443.     lxi    b,(ste.name - symbol.table.entry)
  444. metst.count.lup:
  445.     inx    b
  446.     inx    d
  447.     ldax    d
  448.     ora    a
  449.     jnz    metst.count.lup
  450. ;
  451.     push    d
  452.     lhld    my.top.stk.addr
  453.     dad    b
  454.     xchg
  455.     lhld    start.sym.tbl.addr
  456.     call    cmp.hl.fm.de
  457.     pop    d
  458.     jc    metst.move.lup
  459. ;
  460.     lxi    d,em.sym.ofl
  461.     mvi    c,9
  462.     call    entry
  463.     jmp    boot
  464. em.sym.ofl:
  465.     db    'symbol table overflow',13,10,'$'
  466. ;
  467. metst.move.lup:
  468.     dcx    h
  469.     ldax    d
  470.     mov    m,a
  471.     dcx    d
  472.     dcx    b
  473.     mov    a,b
  474.     ora    c
  475.     jnz    metst.move.lup
  476.     shld    start.sym.tbl.addr
  477. ;
  478. ;---check if new low sym tbl addr---
  479. ;
  480.     xchg
  481.     lhld    lowest.sym.tbl.addr
  482.     call    cmp.hl.fm.de
  483.     xchg
  484.     rnc
  485. ;
  486.     shld    lowest.sym.tbl.addr
  487.     ret
  488. ;
  489. ;
  490. ;
  491. ;
  492. ;---------------------------------------------------
  493. ;
  494. set.dflt.dma:
  495.     lxi    d,dflt.dma
  496.     mvi    c,26
  497.     jmp    entry
  498. ;
  499. set.dflt.dma.map:    db    00h
  500. ;
  501. ;--------------------------------------------------
  502. ;
  503. listing.crlf:
  504.     mvi    e,0dh
  505.     call    print.out
  506.     mvi    e,0ah
  507.     jmp    print.out
  508. ;
  509. ;
  510. con.ch.in:
  511.     mvi    c,1
  512.     jmp    entry
  513. ;
  514. ;
  515. listing.string.out:
  516.     ldax    d
  517.     ora    a
  518.     rz
  519.     inx    d
  520.     push    d
  521.     mov    e,a
  522.     call    print.out
  523.     pop    d
  524.     jmp    listing.string.out
  525. ;
  526. ;
  527. ;
  528. listing.blk.hex.out:
  529.     push    psw
  530.     mvi    e,' '
  531.     call    print.out
  532.     pop    psw
  533. listing.hex.out:
  534.     push    psw
  535.     rrc
  536.     rrc
  537.     rrc
  538.     rrc
  539.     call    listing.hex.digit
  540.     pop    psw
  541. listing.hex.digit:
  542.     ani    0fh
  543.     adi    '0'
  544.     cpi    '9'+1
  545.     jc    listing.hex.ok
  546.     adi    7
  547. listing.hex.ok:
  548.     mov    e,a
  549.     jmp    print.out
  550. ;
  551. ;
  552. ;
  553. print.sym.tbl.entry:
  554.     lxi    d,pst.lit.type
  555.     call    listing.string.out
  556.     lda    ste.type
  557.     call    listing.hex.out
  558. ;
  559.     lxi    d,pst.lit.address
  560.     call    listing.string.out
  561.     lda    ste.address + 1
  562.     call    listing.hex.out
  563.     lda    ste.address
  564.     call    listing.hex.out
  565. ;
  566.     lxi    d,pst.lit.level
  567.     call    listing.string.out
  568.     lda    ste.block.level
  569.     call    listing.hex.out
  570. ;
  571.     lxi    d,pst.lit.ovl
  572.     call    listing.string.out
  573.     lda    ste.ovl.key + 1
  574.     call    listing.hex.out
  575.     lda    ste.ovl.key
  576.     call    listing.hex.out
  577. ;
  578.     lxi    d,pst.lit.length
  579.     call    listing.string.out
  580.     lda    ste.length + 1
  581.     call    listing.hex.out
  582.     lda    ste.length
  583.     call    listing.hex.out
  584. ;
  585.     lxi    d,pst.lit.name
  586.     call    listing.string.out
  587.     lxi    d,ste.name
  588.     ldax    d
  589.     ani    80h    ;special?
  590.     jnz    str.to.print.in.hex
  591.     call    listing.string.out
  592.     jmp    listing.crlf
  593. ;
  594. ;
  595. pst.lit.type:        db    'type:',0
  596. pst.lit.address:    db    ' addr:',0
  597. pst.lit.level:        db    ' lvl:',0
  598. pst.lit.ovl:        db    ' ovl#:',0
  599. pst.lit.length:        db    ' length:',0
  600. pst.lit.name:        db    ' name:',0
  601. pst.line.wk:        db    '       ',0
  602. ;
  603. ;
  604. ;
  605. ;
  606. ;
  607. ;
  608. ;
  609. ;------------------------------------------
  610. ;
  611. ;
  612. print.out.word:
  613.     lxi    d,word
  614.     ldax    d
  615.     ani    80h
  616.     jnz    err.unx.hex
  617.     call    listing.string.out
  618.     jmp    listing.crlf
  619. ;
  620. err.unx.hex:
  621.     call    str.to.print.in.hex
  622.     jmp    listing.crlf
  623. ;
  624. ;
  625. ;
  626. ;
  627. ;
  628. str.to.print.in.hex:
  629.     ldax    d
  630.     ora    a
  631.     jz    listing.crlf
  632.     inx    d
  633.     push    d
  634.     call    listing.blk.hex.out
  635.     pop    d
  636.     jmp    str.to.print.in.hex
  637. ;
  638. ;
  639. ;
  640. ;
  641. ;----------------------------------------------
  642. ;
  643. ;
  644. ;
  645. err.pgm.bounds:
  646.     lxi    h,em.pgm.bounds
  647.     jmp    print.error
  648. em.pgm.bounds:
  649.     db    'Program address out of bounds',0
  650. ;
  651. ;
  652. ;
  653. ;----------------------------------------------
  654. ;
  655. ;
  656. ;
  657. ;
  658. ;----initialize for symbol table search----
  659. ;
  660. init.sym.tbl.srch:
  661.     lhld    start.sym.tbl.addr
  662.     shld    wk.sym.tbl.addr
  663.     lhld    end.sym.tbl.addr
  664.     shld    start.wk.sym.tbl.addr
  665.     ret
  666. ;
  667. ;
  668. ;
  669. ;-----get next symbol-table entry-----
  670. ;
  671. ; in:    wk.sym.tbl.addr        points at next entry
  672. ;
  673. ; out:    symbol.table.entry
  674. ;    wk.sym.tbl.addr        points at new next entry
  675. ;    start.wk.sym.tbl.addr    points at new current entry
  676. ;
  677. get.sym.tbl.entry:
  678.     lhld    wk.sym.tbl.addr
  679.     shld    start.wk.sym.tbl.addr
  680.     lxi    d,symbol.table.entry
  681.     call    move.sym.tbl.entry
  682.     shld    wk.sym.tbl.addr
  683.     ret
  684. ;
  685. ;
  686. ;
  687. print.out.c.blanks:
  688.     mov    a,c
  689.     ora    a
  690.     rz
  691.     push    b
  692.     mvi    e,' '
  693.     call    print.out
  694.     pop    b
  695.     dcr    c
  696.     jmp    print.out.c.blanks
  697. ;
  698. ;
  699. ;
  700. move.sym.tbl.entry:
  701.     lxi    b,ste.name - symbol.table.entry
  702.     call    move.h.2.d.cnt.b
  703.     jmp    move.string
  704. ;
  705. ;
  706. ;
  707. put.fwd.bir.sv.word:
  708.     lhld    word
  709.     push    h
  710.     call    put.fwd.ref.bir
  711.     pop    h
  712.     shld    word
  713.     ret
  714. ;
  715. ;
  716. ;
  717. put.bir.call.fwd:
  718.     push    psw
  719.     call    opt.undef.all
  720.     mvi    a,(call)
  721.     call    put.code.byte
  722.     pop    psw
  723. put.fwd.ref.bir:
  724.     sta    word
  725.     mov    c,a
  726.     xra    a
  727.     sta    word + 1
  728. ;
  729.     mov    a,c
  730.     cpi    bir.routine.limit
  731.     jnc    put.fwd.ref.addr
  732.     sui    bir.routine.base
  733.     mov    e,a
  734.     mvi    d,0
  735.     lxi    h,built.in.rtn.flags
  736.     dad    d
  737.     mov    m,c
  738. ;
  739. ;
  740. ;
  741. ;---put backwards jump to table if table present---
  742. ;
  743.     lda    table.fwd.flag
  744.     ora    a
  745.     jz    put.fwd.ref.addr
  746. ;
  747.     mov    h,d
  748.     mov    l,e
  749.     dad    h    ;times 3
  750.     dad    d
  751.     xchg
  752.     lhld    fwd.tbl.addr
  753.     dad    d
  754.     jmp    put.code.word
  755. ;
  756. ;
  757. ;
  758. ;---no table present -- put forward reference---
  759. ;    (also entry point for fwd-ref addresses)
  760. ;
  761. put.fwd.ref.addr:
  762.     mvi    a,stet.fwd.ref
  763.     sta    ste.type
  764.     lxi    h,0
  765.     shld    ste.length
  766.     call    put.word.into.tbl
  767.     lxi    h,0
  768.     jmp    put.code.word
  769. ;
  770. ;
  771. ;
  772. err.code.write:
  773.     lxi    d,em.code.write
  774.     mvi    c,9
  775.     call    entry
  776.     mvi    c,1
  777.     call    entry
  778.     cpi    3
  779.     jz    boot
  780.     ret
  781. ;
  782. ;
  783. ;
  784. em.code.write:
  785.     db    'COM file write error',13,10
  786.     db    'press ^C to abort, or any other',13,10
  787.     db    'key to ignore',13,10,'$'
  788. ;
  789. ;
  790. ;
  791. print.out:
  792.     lda    print.console
  793.     ora    a
  794.     jz    print.out.not.con
  795.     push    d
  796.     call    print.con.ch
  797.     pop    d
  798. print.out.not.con:
  799.     lda    print.printer.flag
  800.     ora    a
  801.     jz    print.out.not.printer
  802.     push    d
  803.     mvi    c,5
  804.     call    entry
  805.     pop    d
  806. print.out.not.printer:
  807.     lda    print.disk.flag
  808.     ora    a
  809.     rz                ;exit
  810.     push    d
  811.     mov    a,e
  812.     lxi    h,print.fcb + fcb.status    ;zero status
  813.     mvi    m,0
  814.     push    h
  815.     lxi    d,print.fcb
  816.     call    disk.char.out
  817.     pop    h
  818.     mov    a,m        ;check status
  819.     ora    a
  820.     jz    print.out.disk.ok
  821.     lxi    d,em.print.disk
  822.     mvi    c,9
  823.     call    entry
  824.     xra    a        ;stop disk print on error
  825.     sta    print.disk.flag
  826. print.out.disk.ok:
  827.     pop    d
  828.     ret
  829. ;
  830. ;
  831. ;
  832. print.error.and.colm:
  833.     call    print.error
  834.     jmp    print.error.colm
  835. ;
  836. ;
  837. ;
  838. print.error.and.word:
  839.     mvi    a,0ffh
  840.     sta    print.word.flag
  841.     call    print.error
  842.     jmp    print.out.word
  843. ;
  844. ;
  845. ;
  846. print.warning:
  847.     lda    nowarn.flag
  848.     ora    a
  849.     rnz
  850.     mvi    a,'>'
  851.     sta    prt.err.flag.byte
  852.     push    h
  853.     jmp    print.warn.entry
  854. ;
  855. ;
  856. ;
  857. print.error:
  858.     push    h
  859.     lhld    err.ctr
  860.     inx    h
  861.     shld    err.ctr
  862.     mvi    e,7
  863.     call    print.con.ch    ;beep on error
  864.     mvi    a,'-'
  865.     sta    prt.err.flag.byte
  866. print.warn.entry:
  867.     mvi    d,5
  868. prt.err.dash.lup:
  869.     push    d
  870. prt.err.flag.byte    equ    $+1
  871.     mvi    e,'-'
  872.     call    print.out
  873.     pop    d
  874.     dcr    d
  875.     jnz    prt.err.dash.lup
  876.     pop    h
  877. print.error.lup:
  878.     mov    a,m
  879.     ora    a
  880.     jz    print.error.end
  881.     push    h
  882.     mov    e,a
  883.     call    print.out
  884.     pop    h
  885.     inx    h
  886.     jmp    print.error.lup
  887. ;
  888. print.error.end:
  889.     lda    print.word.flag
  890.     ora    a
  891.     cz    listing.crlf
  892.     xra    a
  893.     sta    print.word.flag
  894.     mvi    a,0ffh
  895.     sta    error.this.line
  896.     ret
  897. ;
  898. ;
  899. ;
  900. print.error.colm:
  901.     lda    curr.print.colm
  902.     ora    a
  903.     rz
  904. ;
  905. ;-----check number of spaces print is offset-----
  906. ;
  907.     mvi    c,0
  908.     lda    print.blk.match.flag
  909.     ani    06h
  910.     add    c
  911.     mov    c,a
  912. ;
  913.     lda    print.blk.lvl.flag
  914.     ani    6
  915.     add    c
  916.     mov    c,a
  917. ;
  918.     lda    print.line.num.flag
  919.     ani    6
  920.     add    c
  921.     mov    c,a
  922. ;
  923.     lda    print.code.addr.flag
  924.     ani    5
  925.     add    c
  926.     mov    c,a
  927. ;
  928.     call    print.out.c.blanks
  929. ;
  930. ;
  931.     lda    curr.print.colm
  932.     dcr    a
  933.     ora    a
  934.     jz    prt.err.got.colm
  935.     cpi    print.line.size - 3
  936.     jnc    prt.err.got.colm
  937. prt.err.colm.lup:
  938.     push    psw
  939.     mvi    e,'-'
  940.     call    print.out
  941.     pop    psw
  942.     dcr    a
  943.     jnz    prt.err.colm.lup
  944. prt.err.got.colm:
  945.     mvi    e,'|'
  946.     call    print.out
  947.     jmp    listing.crlf
  948. ;
  949. ;
  950. ;
  951. ;
  952. print.con.ch:
  953.     mvi    c,2
  954.     jmp    entry
  955. ;
  956. em.print.disk:
  957.     db    7,'Print write error$'
  958. ;
  959. ;
  960. ;
  961. ;
  962. ;--------------  End of LCOMMON.ASM  -----------------
  963. ;;
  964. ;
  965.