home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / PARASOL / PARASOLS.ARK / LEOJ1.ASM < prev    next >
Assembly Source File  |  1986-10-05  |  10KB  |  646 lines

  1. start:        ;label not used - prevents assembly error
  2. my.stack.top:    ;label not used - prevents assembly error
  3. ;
  4.     org    ovly.start.loc
  5. ;
  6. ;
  7. ;
  8.     mvi    a,bir.END
  9.     call    fix.up.built.in.rtn
  10. ;
  11. ;---have object program close it's overlay file---
  12.     lda    any.overlay
  13.     ora    a
  14.     jz    MAIN.no.ovl.used
  15. ;
  16.     mvi    a,21h
  17.     call    put.code.byte
  18.     lxi    h,0ffffh
  19.     call    put.code.word
  20.     mvi    a,bir.overlay.load
  21.     call    put.bir.call.fwd
  22. ;---Copy overlay name to object routine--
  23.     lxi    h,ovl.fcb + 1
  24.     lxi    d,ovl.load.fcb + 1
  25.     lxi    b,11
  26.     call    move.h.2.d.cnt.b
  27.  
  28.     lxi    h,ovl.load.fcb + 6    ;set R/O mode for MP/M
  29.     mov    a,m
  30.     ori    80h
  31.     mov    m,a
  32. MAIN.no.ovl.used:
  33. ;
  34.     lda    stack.save.flag
  35.     ora    a
  36.     jz    MAIN.end.no.stk.sv
  37. ;
  38.     mvi    a,bir.cpm.stack
  39.     lxi    h,0
  40.     call    put.LXI.H.fixup
  41.     call    put.SPHL
  42.     call    put.RET
  43. ;
  44.     jmp    MAIN.eof.src
  45. ;
  46. MAIN.end.no.stk.sv:
  47. ;
  48.     lda    stack.none.flag
  49.     ora    a
  50.     jz    MAIN.reboot
  51. ;
  52.     call    put.RET
  53.     jmp    MAIN.eof.src
  54. ;
  55. MAIN.reboot:
  56.     call    put.JMP
  57.     lxi    h,BOOT
  58.     call    put.code.word
  59. ;
  60. MAIN.eof.src:
  61. ;
  62. ;-----final forward reference fix-up-----
  63. ;
  64.     lxi    h,l.eoj.himem
  65.     shld    himem.bir.ptr
  66. ;
  67.     lxi    h,bir.descriptions
  68.     shld    curr.rtn.desc.addr
  69. ;
  70.     lxi    d,built.in.rtn.flags
  71.     lxi    h,reloc.rtn.tbl
  72. MAIN.reloc.lup:
  73.     ldax    d
  74.     cpi    0ffh
  75.     jz    MAIN.reloc.end
  76.     inx    d
  77.     push    d
  78.     ora    a
  79.     jz    MAIN.chk.nxt.reloc
  80.     mov    c,a
  81.     push    h
  82. ;
  83. ;
  84. ;
  85. ;---check if fwd table is prresent---
  86. ;
  87.     lda    table.fwd.flag
  88.     ora    a
  89.     jz    MAIN.no.tbl.fix
  90. ;
  91.     push    h
  92.     push    d
  93.     push    b
  94.     mvi    b,0
  95.     mov    h,b
  96.     mov    a,c
  97.     sui    bir.routine.base
  98.     mov    l,a
  99.     mov    c,a
  100.     dad    h    ;times 3
  101.     dad    b
  102.     mov    b,h
  103.     mov    c,l
  104.     lhld    fwd.tbl.addr
  105.     dad    b
  106. ;
  107. ;---if printing map & using fwd tbl, show vector address---
  108. ;
  109.     lda    reloc.map.flag
  110.     ora    a
  111.     jz    MAIN.no.vctr.prt
  112. ;
  113.     push    h    ;addr of bir-tbl JMP
  114.     mvi    e,'('
  115.     call    print.out
  116.     pop    h
  117.     push    h
  118.     lxi    d,print.line
  119.     call    cvt.bin.2.hex.str
  120.     lxi    d,print.line
  121.     call    listing.string.out
  122.     mvi    e,')'
  123.     call    print.out
  124.     mvi    e,' '
  125.     call    print.out
  126.     pop    h    ;addr of bir-tbl JMP
  127. MAIN.no.vctr.prt:
  128.     inx    h    ;past JMP instr
  129.     xchg
  130.     lhld    himem.bir.ptr
  131.     mov    m,e    ;store addr of JMP addr
  132.     inx    h
  133.     mov    m,d
  134.     inx    h
  135.     xchg
  136.     lhld    curr.code.addr
  137.     xchg
  138.     mov    m,e    ;store addr to jump to
  139.     inx    h
  140.     mov    m,d
  141.     inx    h
  142.     shld    himem.bir.ptr
  143.     pop    b
  144.     pop    d
  145.     pop    h
  146. MAIN.no.tbl.fix:
  147. ;
  148. ;---check if to print map---
  149. ;
  150.     lda    reloc.map.flag
  151.     ora    a
  152.     jz    MAIN.no.MAP
  153.     push    b
  154.     lhld    curr.code.addr
  155.     lxi    d,print.line
  156.     call    cvt.bin.2.hex.str
  157.     lxi    d,print.line
  158.     call    listing.string.out
  159.     mvi    e,' '
  160.     call    print.out
  161.     lhld    curr.rtn.desc.addr
  162.     xchg
  163.     call    listing.string.out
  164.     call    listing.crlf
  165.     pop    b
  166.     pop    h
  167.     push    h
  168. MAIN.no.MAP:
  169. ;
  170.     call    put.reloc.rtn
  171.     pop    h
  172. MAIN.chk.nxt.reloc:
  173.     lxi    d,4
  174.     dad    d
  175.     pop    d
  176. MAIN.reloc.chk.end:
  177.     mov    a,m
  178.     inx    h
  179.     ora    a
  180.     jnz    MAIN.reloc.chk.end
  181. ;
  182.     push    d
  183.     push    h
  184.     lhld    curr.rtn.desc.addr
  185.     xchg
  186.     call    size.d.2.h
  187.     inx    d
  188.     xchg
  189.     shld    curr.rtn.desc.addr
  190.     pop    h
  191.     pop    d
  192.     jmp    MAIN.reloc.lup
  193. ;
  194. ;
  195. himem.bir.ptr    dw    l.eoj.himem
  196. ;
  197. ;
  198. MAIN.reloc.end:
  199. ;
  200. ;---if fwd-tbl used, go back and patch in vectors---
  201. ;
  202.     lhld    curr.code.addr
  203.     push    h
  204.     lda    table.fwd.flag
  205.     ora    a
  206.     jz    hi.bir.end
  207. ;
  208.     lxi    h,l.eoj.himem
  209.     shld    himem.bir.ptr
  210. ;
  211.     lxi    d,built.in.rtn.flags
  212. hi.bir.lup:
  213.     ldax    d
  214.     cpi    0ffh
  215.     jz    hi.bir.end
  216.     inx    d
  217.     push    d
  218.     ora    a
  219.     jz    chk.nxt.hi.bir
  220. ;
  221.     lhld    himem.bir.ptr
  222.     mov    e,m    ;get addr of JMP addr
  223.     inx    h
  224.     mov    d,m
  225.     inx    h
  226.     xchg
  227.     shld    curr.code.addr
  228.     xchg
  229.     mov    e,m    ;get addr to jump to
  230.     inx    h
  231.     mov    d,m
  232.     inx    h
  233.     shld    himem.bir.ptr
  234.     xchg
  235.     call    put.code.word
  236. chk.nxt.hi.bir:
  237.     pop    d
  238.     jmp    hi.bir.lup
  239. ;
  240. hi.bir.end:
  241.     pop    h
  242.     shld    curr.code.addr    ;restore high code addr
  243. ;
  244. ;-----if stack size specified, allocate stack storage-----
  245. ;
  246.     lda    stack.id.flag
  247.     ora    a
  248.     jz    MAIN.not.stack.id
  249. ;
  250.     lhld    stack.id.size
  251.     xchg
  252.     lhld    curr.code.addr
  253.     dad    d
  254.     shld    curr.code.addr
  255.     mvi    a,bir.stack.fwd
  256.     call    fix.up.built.in.rtn
  257. MAIN.not.stack.id:
  258. ;
  259. ;----highest memory address---
  260. ;
  261.     mvi    a,bir.hi.mem
  262.     call    fix.up.built.in.rtn
  263. ;
  264. ;
  265. ;---anything left as a forward reference is undefined--
  266. ;
  267.     call    init.sym.tbl.srch
  268. MAIN.undef.find.lup:
  269.     call    get.sym.tbl.entry
  270.     lda    ste.type
  271.     cpi    stet.deleted
  272.     jnc    MAIN.undef.find.lup
  273.     cpi    stet.end.tbl
  274.     jz    MAIN.end
  275.     call    err.undef.label
  276.     call    print.sym.tbl.entry
  277.     jmp    MAIN.undef.find.lup
  278. MAIN.end:
  279.     call    write.code.write
  280.     lxi    d,code.fcb
  281.     mvi    c,16
  282.     call    entry
  283. ;
  284. ;---close compiler's overlay output file---
  285. ;
  286.     lda    any.overlay
  287.     ora    a
  288.     jz    MAIN.no.ovl.close
  289.     lxi    h,ovl.fcb
  290.     lxi    d,code.fcb
  291.     lxi    b,36
  292.     call    move.h.2.d.cnt.b
  293.     lxi    d,code.fcb
  294.     mvi    c,16
  295.     call    entry
  296. MAIN.no.ovl.close:
  297. ;
  298. ;---close source file---
  299. ;
  300.     lxi    d,src.in
  301.     mvi    c,16    ;close
  302.     call    entry
  303. ;
  304. ;-------------------------------
  305. ;   compiler summary printing
  306. ;-------------------------------
  307. ;
  308.     call    listing.crlf
  309.     call    listing.crlf
  310. ;
  311.     mvi    a,0ffh
  312.     sta    print.console
  313. ;
  314. ;--- # errors ---
  315. ;
  316.     lhld    err.ctr
  317.     lxi    d,decimal.work
  318.     call    cvt.bin.2.dec.str
  319.     lxi    d,decimal.work
  320.     call    listing.string.out
  321.     lxi    d,msg.err
  322.     call    listing.string.out
  323. ;
  324.     lda    nowarn.flag
  325.     ora    a
  326.     jnz    summ.skip.1a
  327. ;---# statements---
  328.     lhld    statement.counter
  329.     lxi    d,decimal.work
  330.     call    cvt.bin.2.dec.str
  331.     lxi    d,decimal.work
  332.     call    listing.string.out
  333.     lxi    d,msg.statements
  334.     call    listing.string.out
  335. ;---# lines printed---
  336.     lhld    print.line.ctr
  337.     lxi    d,decimal.work
  338.     call    cvt.bin.2.dec.str
  339.     lxi    d,decimal.work
  340.     call    listing.string.out
  341.     lxi    d,msg.lines.printed
  342.     call    listing.string.out
  343.     call    listing.crlf
  344. ;
  345. ;--- total symbol table space ---
  346. ;
  347. summ.skip.1a:
  348.     lhld    my.top.stk.addr
  349.     xchg
  350.     lhld    end.sym.tbl.addr
  351.     call    sub.de.fm.hl.2.hl
  352.     shld    tot.sym.space
  353. ;
  354.     lda    nowarn.flag
  355.     ora    a
  356.     jnz    summ.skip.1b
  357. ;
  358.     lxi    d,decimal.work
  359.     call    cvt.bin.2.dec.str
  360.     lxi    d,msg.tot.sym.tbl.spc
  361.     call    listing.string.out
  362.     lxi    d,decimal.work
  363.     call    listing.string.out
  364.     call    listing.crlf
  365. ;
  366. ;--- symbol table space used ---
  367. ;
  368. summ.skip.1b:
  369.     lhld    lowest.sym.tbl.addr
  370.     xchg
  371.     lhld    end.sym.tbl.addr
  372.     call    sub.de.fm.hl.2.hl
  373.     shld    used.sym.space
  374. ;
  375.     lda    nowarn.flag
  376.     ora    a
  377.     jnz    summ.skip.1c
  378. ;
  379.     lxi    d,decimal.work
  380.     call    cvt.bin.2.dec.str
  381.     lxi    d,msg.usd.sym.tbl.spc
  382.     call    listing.string.out
  383.     lxi    d,decimal.work
  384.     call    listing.string.out
  385. ;
  386. ;---  % = used / (total / 100)
  387. ;
  388. summ.skip.1c:
  389.     lhld    tot.sym.space
  390.     xchg
  391.     lxi    h,100
  392.     call    div.d.by.h.2.d.r.h
  393.     lhld    used.sym.space
  394.     xchg
  395.     call    div.d.by.h.2.d.r.h
  396.     xchg
  397.     lxi    d,decimal.work
  398.     call    cvt.bin.2.dec.str
  399.     lxi    d,msg.percent.prefix
  400.     call    listing.string.out
  401.     lxi    d,decimal.work
  402.     call    listing.string.out
  403.     lxi    d,msg.percent.postfix
  404.     call    listing.string.out
  405. ;
  406.     lda    nowarn.flag
  407.     ora    a
  408.     jnz    summ.skip.2
  409. ;
  410.     call    listing.crlf
  411. ;
  412. ;---highest code addr
  413. ;
  414. summ.skip.2:
  415.     lhld    curr.code.addr
  416.     lxi    d,decimal.work
  417.     call    cvt.bin.2.hex.str
  418.     lxi    d,msg.hi.obj.code
  419.     call    listing.string.out
  420.     lxi    d,decimal.work
  421.     call    listing.string.out
  422. ;
  423.     lda    nowarn.flag
  424.     ora    a
  425.     jnz    summ.skip.3
  426. ;
  427.     lxi    d,msg.num.k.prefix
  428.     call    listing.string.out
  429. ;---#k
  430.     lhld    curr.code.addr
  431.     lxi    d,100h
  432.     call    sub.de.fm.hl.2.hl
  433.     lxi    d,7fh    ;round up #k to next 1/4 K
  434.     dad    d
  435.     push    h
  436.     xchg
  437.     lxi    h,1024
  438.     call    div.d.by.h.2.d.r.h
  439.     xchg
  440.     lxi    d,decimal.work
  441.     call    cvt.bin.2.dec.str
  442.     lxi    d,decimal.work
  443.     call    listing.string.out
  444.     pop    d
  445.     mov    a,d
  446.     ani    03h
  447.     ora    a
  448.     jz    MAIN.even.K
  449.     dcr    a
  450.     jz    MAIN.25.K
  451.     dcr    a
  452.     jz    MAIN.50.K
  453. ;
  454.     lxi    d,msg.75
  455.     jmp    MAIN.K.fract
  456. ;
  457. MAIN.50.K:
  458.     lxi    d,msg.50
  459.     jmp    MAIN.K.fract
  460. ;
  461. MAIN.25.K:
  462.     lxi    d,msg.25
  463. MAIN.K.fract:
  464.     call    listing.string.out
  465. MAIN.even.K:
  466. ;
  467. ;--- number of records in code file ---
  468.     lxi    d,msg.num.recs.prefix
  469.     call    listing.string.out
  470. ;---# recs
  471.     lhld    curr.code.addr
  472.     call    set.code.key
  473.     inx    h
  474.     lxi    d,decimal.work
  475.     call    cvt.bin.2.dec.str
  476.     lxi    d,decimal.work
  477.     call    listing.string.out
  478.     lxi    d,msg.num.recs.postfix
  479.     call    listing.string.out
  480.     call    listing.crlf
  481. summ.skip.3:
  482. ;
  483. ;---close print file
  484. ;
  485.     lda    print.disk.flag
  486.     ora    a
  487.     jz    MAIN.final.end
  488. ;
  489.     lxi    d,print.fcb
  490.     call    close.dsk.ch
  491. ;
  492.     lxi    d,print.fcb
  493.     mvi    c,16    ;close
  494.     call    entry
  495.     inr    a
  496.     jnz    MAIN.final.end
  497.     lxi    d,em.print.close
  498.     mvi    c,9
  499.     call    entry
  500.     jmp    MAIN.final.end
  501. ;
  502. em.print.close:
  503.     db    'Print File Close Error$'
  504. ;
  505. ;
  506. MAIN.final.end:
  507.     lda    auto.execute.flag
  508.     ora    a
  509.     jz    boot
  510.     lhld    err.ctr
  511.     mov    a,h
  512.     ora    l
  513.     jnz    boot
  514. ;
  515.     lxi    h,code.fcb
  516.     lxi    d,dflt.fcb
  517.     lxi    b,dflt.dma - dflt.fcb
  518.     call    move.h.2.d.cnt.b
  519. ;
  520.     xra    a
  521.     sta    dflt.fcb + fcb.ext.num
  522.     sta    dflt.fcb + fcb.cur.rec
  523.     lxi    h,0
  524.     push    h
  525.     push    psw
  526.     jmp    execute.no.format
  527. ;
  528. ;------------------------------------------------------
  529. ;
  530. ;
  531. ;
  532. ;
  533. ;-----------------------------------------------------
  534. ;    output relocatable routine to object code
  535. ;
  536. ; in:    hl -> reloc table entry
  537. ;    c  =  bir code
  538. ;
  539. ;
  540. put.reloc.rtn:
  541.     push    h
  542.     mov    a,c
  543.     call    fix.up.built.in.rtn
  544.     pop    h
  545. ;
  546.     mov    e,m
  547.     inx    h
  548.     mov    d,m
  549.     inx    h
  550.     xchg
  551.     shld    curr.rtn.strt.addr
  552.     shld    curr.rtn.addr
  553. ;
  554.     xchg
  555.     mov    e,m
  556.     inx    h
  557.     mov    d,m
  558.     inx    h
  559.     xchg
  560.     shld    strt.map.loc
  561.     shld    curr.map.loc
  562. ;
  563.     xchg
  564.     shld    curr.rtn.fwd.tbl
  565. ;
  566.     mvi    a,80h
  567.     sta    curr.reloc.bit
  568. ;
  569.     lhld    curr.code.addr
  570.     shld    curr.rtn.code.strt.addr
  571. ;
  572. prr.lup:
  573.     call    prr.test.reloc.bit
  574.     jz    prr.no.reloc
  575. ;
  576.     call    prr.test.reloc.bit
  577.     jz    prr.reloc
  578.     lhld    curr.rtn.fwd.tbl
  579.     mov    a,m
  580.     inx    h
  581.     shld    curr.rtn.fwd.tbl
  582.     call    put.fwd.ref.bir
  583.     lhld    curr.rtn.addr
  584.     inx    h
  585.     inx    h
  586.     shld    curr.rtn.addr
  587.     jmp    prr.next
  588. ;
  589. prr.reloc:
  590.     lhld    curr.rtn.addr
  591.     mov    e,m    ;de <- value of reloc reference
  592.     inx    h
  593.     mov    d,m
  594.     inx    h
  595.     shld    curr.rtn.addr
  596. ;
  597.     lhld    curr.rtn.strt.addr
  598.     xchg
  599. ;---subtract start of rtn from reference location---
  600.     call    sub.de.fm.hl.2.hl
  601.     xchg
  602.     lhld    curr.rtn.code.strt.addr
  603.     dad    d
  604.     call    put.code.word
  605.     jmp    prr.next
  606. ;
  607. prr.no.reloc:
  608.     lhld    curr.rtn.addr
  609.     mov    a,m
  610.     inx    h
  611.     shld    curr.rtn.addr
  612.     call    put.code.byte
  613. ;
  614. prr.next:
  615.     lhld    strt.map.loc
  616.     xchg
  617.     lhld    curr.rtn.addr
  618.     call    cmp.de.fm.hl
  619.     jc    prr.lup
  620.     ret
  621. ;
  622. ;
  623. ;
  624. prr.test.reloc.bit:
  625.     lhld    curr.map.loc
  626.     mov    c,m
  627.     lda    curr.reloc.bit
  628.     mov    b,a
  629.     ana    c
  630.     push    psw
  631.     mov    a,b
  632.     rrc
  633.     sta    curr.reloc.bit
  634.     cpi    80h
  635.     jnz    prr.trb.exit
  636.     lhld    curr.map.loc
  637.     inx    h
  638.     shld    curr.map.loc
  639. prr.trb.exit:
  640.     pop    psw
  641.     ret
  642. ;
  643. ;
  644. ;
  645. ;
  646.