home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / cpm86 / swv20.lbr / SWV20.AQ6 / SWV20.A86
Text File  |  1988-03-12  |  20KB  |  634 lines

  1. ;
  2. ;       SWV20 Version 1.0
  3. ;
  4. ;       CP/M-80 emulator for CP/M-86, MP/M-86 and Concurrent DOS
  5. ;       using the NEC V-20 and V-30 micorprocessors.
  6. ;
  7. ;       Copyright 1986 Thomas M. Langley
  8. ;       All rights reserved.
  9. ;       Commercial and Government use prohibited
  10. ;
  11. ;
  12. ;       Some codemacros for V20 instructions
  13. ;
  14. ;       BRKEM - Break to 8080 mode:
  15. ;
  16.         codemacro               brkem  int:Db
  17.         db      0fh
  18.         db      0ffh
  19.         db      int
  20.         endm
  21. ;
  22. ;       RETEM - Return to 8086 mode:
  23. ;
  24.         codemacro               retem
  25.         db      0edh
  26.         db      0fdh
  27.         endm
  28. ;
  29. ;       CALLN - Call 8086 subroutine from emulation mode
  30. ;
  31.         codemacro               calln  int:Db
  32.         db      0edh
  33.         db      0edh
  34.         db      int
  35.         endm
  36. ;
  37. ;       Start of code area
  38. ;
  39.         cseg
  40.         org     0
  41.         mov     sp,offset stack
  42. ;
  43. ;       Move the BIOS and BDOS intercept code to
  44. ;       the top of the emulator's address space (ES:)
  45. ;
  46. ;       Entry:  ES: -> Emulator address space segment
  47. ;
  48.         push    ds
  49.         mov     ax,es
  50.         mov     ds,ax                  ;DS: now equal to ES:
  51.         mov     si,offset tpa          ;start of "8080" part of emulation code
  52.         mov     di,bdosv               ;relocation area
  53.         mov     cx,copylen             ;length of move in words
  54.         cld                            ;set forward direction
  55.         rep     movsb                  ;do move
  56.         pop     ds
  57. ;
  58. ;       Finished with emulation mode TPA so clear out prior to load
  59. ;
  60.         mov     di,10h
  61.         mov     cx,200h
  62.         xor     ax,ax
  63.         rep     stosw                  ;make all 0's
  64. ;
  65. ;       Process command tail
  66. ;
  67.         and     cmdlen,00ffh
  68.         call    parsel
  69.         cmp     wrkbuf,'?'             ;is it version request?
  70.         mov     dx,offset vermsg
  71.         jne     noerr                  ;display version
  72.         jmp     error
  73.  
  74. ;
  75. ;       Parse command name into wrkbuf
  76. ;
  77. noerr   equ     $
  78.         cmp     cmdlen,0               ;command there?
  79.         mov     dx,offset ermsg1
  80.         jnz     noerr1                 ;no command specified
  81.         jmp     error
  82. ;
  83. noerr1  equ     $
  84.         push    di
  85.         mov     cx,cmdlen              ;get command length
  86.         mov     si,offset cmdtxt
  87.         mov     di,offset cpmtxt
  88.         mov     cpmdma,cx
  89.         rep     movsb                  ;copy
  90.         pop     di
  91.         mov     ax,ftype1
  92.         mov     [di],ax
  93.         mov     ax,ftype2
  94.         mov     2[di],ax               ;add .COM
  95.         mov     byte ptr 4[di],0
  96. ;
  97. ;       Parse file name (of command file) into the work fcb
  98. ;
  99.         call    parsef                 ;parse to command fcb
  100.         call    load                   ;load program
  101.         jz      initg
  102.         xor     si,si                  ;index
  103.         mov     cx,12                  ;move program name
  104. init1   equ     $
  105.         mov     al,wrkbuf[si]          ;get character
  106.         or      al,al                  ;is id the end?
  107.         jz      init2
  108.         mov     ermsg2a[si],al
  109.         inc     si                     ;next buffer location
  110.         loop    init1
  111.         mov     di,offset ermsg2b      ;now move rest of message
  112.         mov     cx,ermsg2l
  113. init2   equ     $
  114.         mov     al,[di]                ;get character
  115.         inc     di
  116.         mov     ermsg2a[si],al         ;and store
  117.         inc     si
  118.         loop    init2
  119.         jmp     error
  120. ;
  121. ;       parse first parameter into the work fcb and then move it
  122. ;       to the CP/M's first default fcb
  123. ;
  124. initg   equ     $
  125.         mov     di,1
  126.         mov     cx,11                  ;eleven bytes to 'blank'
  127. ;
  128. initg1  equ     $
  129.         mov     al,20h
  130.         mov     cpmfcb1[di],al
  131.         mov     cpmfcb2[di],al
  132.         inc     di                     ;next offset
  133.         loop    initg1
  134. ;
  135.         call    parsel                 ;parse first parameter
  136.         jnz     done                   ;nothing parsed
  137.         call    parsef                 ;parse to first fcb
  138.         jnz     done
  139.         push    cx                     ;have to save these
  140.         push    si
  141.         mov     cx,16                  ;only need 16 bytes
  142.         mov     si,offset wrkfcb
  143.         mov     di,offset cpmfcb1
  144.         rep     movsb
  145.         pop     si
  146.         pop     cx                     ;stack still down 2 words
  147. ;
  148. ;
  149. ;       Parse second parameter to temporary work area and then copy
  150. ;       to second fcb at 6ch to avoid overlaying default dma
  151. ;
  152.         call    parsel                 ;parse second parameter
  153.         jnz     done                   ;no parameter
  154.         call    parsef                 ;parse to second fcb
  155.         jnz     done
  156.         mov     cx,16
  157.         mov     si,offset wrkfcb
  158.         mov     di,offset cpmfcb2
  159.         rep     movsb                  ;move fcb
  160.         jmps    done
  161. ;
  162. ;
  163. ;
  164. error   equ     $
  165.         mov     cl,9                   ;display error message in DX
  166.         call    bdos
  167.         mov     cl,0
  168.         call    bdos                   ;exit
  169. ;
  170. ;
  171. ;       Done with all initialization, so pass control to
  172. ;       CP/M program.
  173. ;
  174. done    equ     $
  175.         pop     cx                     ;get command tail length
  176.         pop     si                     ;and start within command buffer
  177. ;
  178.         xor     al,al
  179. ;
  180. ;       Set up entry parameters for emulation mode
  181. ;
  182.         mov     iobyte,0               ;io byte
  183.         mov     cl,32                  ;get current user
  184.         mov     dl,0ffh
  185.         call    bdos
  186.         shl     bl,1                   ;shift to upper nibble
  187.         shl     bl,1
  188.         shl     bl,1
  189.         shl     bl,1
  190.         push    bx
  191.         mov     cl,26                  ;get current disk
  192.         call    bdos
  193.         pop     bx                     ;get user # back
  194.         or      al,bl                  ;combine current disk and (userno shl 4)
  195.         mov     curdsk,al
  196.         mov     dx,es                  ;'new' cs:
  197.         mov     cl,51
  198.         call    bdos                   ;set dma seg
  199.         mov     dx,offset cpmdma       ;and offset
  200.         mov     cl,26
  201.         call    bdos
  202. ;
  203. stop    equ     $
  204.         xor     ax,ax
  205.         mov     ds,ax
  206.         mov     si,128*4
  207.         mov     word ptr[si],offset estart
  208.         mov     ax,es
  209.         mov     ds: 2[si],ax
  210.         mov     ss,ax
  211.         mov     ds,ax
  212.         mov     sp,0ffffh
  213.         mov     ax,0100h
  214.         mov     bp,ax
  215. emexit  equ     $
  216.         nop
  217.         brkem   128
  218.         mov     cl,0
  219.         int     224
  220. ;
  221. ;
  222. load    equ     $
  223.         push    cx
  224.         push    si
  225.         push    es
  226.         or      prfcbf6,80h            ;indicate read only mode
  227. load1   equ     $
  228.         mov     dx,offset prfcb        ;command fcb
  229.         mov     cl,15                  ;open function
  230.         call    bdos
  231.         cmp     al,0ffh                ;error
  232.         mov     ah,al
  233.         mov     dx,offset ermsg2
  234.         jne     load2                  ;exit if error
  235.         cmp     prfcbdr,0              ;was it default
  236.         jne     load4                  ;exit if not
  237.         mov     prfcbdr,1              ;make it A:
  238.         jmps    load1                  ;try again
  239. load2   equ     $
  240.         mov     dx,es
  241.         mov     cl,51                  ;set base
  242.         call    bdos
  243.         mov     cx,63*8                ;largest amount to load
  244.         mov     dx,offset tpa          ;start of load
  245. load3   equ     $
  246.         mov     di,cx
  247.         mov     cl,26                  ;set offset
  248.         call    bdos
  249.         mov     dx,offset prfcb
  250.         mov     cl,20                  ;read record
  251.         call    bdos
  252.         cmp     al,1                   ;error?
  253.         mov     dx,offset ermsg4
  254.         mov     ah,0ffh
  255.         ja      load4
  256.         mov     ah,0
  257.         je      load4
  258.         mov     cl,52                  ;get dma address
  259.         call    bdos
  260.         add     ax,128                 ;next record
  261.         mov     dx,ax
  262.         mov     cx,di                  ;restore counter
  263.         loop    load3
  264.         mov     dx,offset ermsg3
  265.         mov     ah,0ffh
  266. load4   equ     $
  267.         pop     es
  268.         pop     si
  269.         pop     cx
  270.         or      ah,ah
  271.         ret
  272. ;
  273. ;       PARSEL:  Parse Command Line
  274. ;
  275. ;           Exit:   DI -> Last character + 1 in wrkbuf (0x00)
  276. ;
  277. parsel  equ     $
  278.         call    xblank                 ;skip leading blanks
  279.         test    cmdlen,0ffh            ;see if anything in buffer
  280.         mov     al,0ffh                ;and exit with flag set if no parameter
  281.         jz      parsel4
  282.         mov     di,offset wrkbuf       ;output area
  283.         mov     si,offset cmdtxt       ;input buffer
  284. parsel1 equ     $
  285.         mov     al,[si]                ;get cmdbuf
  286.         or      al,al                  ;end of string
  287.         jz      parsel3
  288.         cmp     al,' '                 ;delimiter?
  289.         je      parsel3                ;treat as end of string
  290.         jb      parsel2                ;skip if control character (< 20h)
  291.         cmp     al,'z'                 ;see if lower case
  292.         ja      parsel2                ;and ignore if greater
  293.         mov     [di],al                ;store in target
  294.         inc     di
  295. parsel2 equ     $
  296.         inc     si                     ;next source byte
  297.         dec     cmdlen                 ;decrement command length
  298.         jnz     parsel1
  299. parsel3 equ     $
  300.         call    shiftb
  301.         xor     al,al
  302.         mov     [di],al                ;store ending zero
  303.         cmp     di,offset wrkbuf       ;see if it didn't change
  304.         jne     parsel4
  305.         dec     al
  306. parsel4 equ     $
  307.         push    ax
  308.         call    xblank
  309.         pop     ax
  310.         mov     ah,al
  311.         or      al,al                  ;set return code
  312.         ret
  313. ;
  314. ;       Skip leading blanks
  315. ;
  316. xblank  equ     $
  317.         test    cmdlen,0ffh
  318.         jz      xblank2                ;exit if 0
  319.         mov     si,offset cmdtxt       ;always start from here
  320. xblank1 equ     $
  321.         cmp     byte ptr[si],' '       ;is it a blank
  322.         jne     xblank2                ;no more blanks
  323.         inc     si                     ;next buffer byte
  324.         dec     cmdlen
  325.         jnz     xblank1                ;get rest of buffer
  326. xblank2 equ     $
  327.         call    shiftb
  328.         mov     al,0
  329.         test    cmdlen,0ffh            ;see if 0
  330.         jnz     xblankx
  331.         dec     al                     ;make 0ffh
  332. xblankx equ     $
  333.         mov     ah,al
  334.         or      al,al
  335.         ret
  336. ;
  337. shiftb  equ     $
  338.         push    di
  339.         push    si
  340.         push    es
  341.         mov     ax,ds
  342.         mov     es,ax
  343.         mov     cx,cmdlen
  344.         or      cx,cx                  ;see if 0
  345.         jz      shiftb1
  346.         mov     di,offset cmdtxt
  347.         rep     movsb                  ;copy buffer left
  348. shiftb1 equ     $
  349.         mov     cx,127
  350.         sub     cx,cmdlen              ;get remainder in buffer
  351.         xor     al,al
  352.         rep     stosb                  ;zero the rest
  353.         pop     es
  354.         pop     si
  355.         pop     di
  356.         ret
  357. ;
  358. parsef  equ     $                      ;parse file name
  359.         push    si
  360.         push    cx                     ;save these
  361.         push    di
  362.         mov     pfcbnam,offset wrkbuf
  363.         mov     pfcbfcb,offset wrkfcb
  364.         mov     dx,offset pfcb
  365.         mov     cl,152
  366.         call    bdos
  367.         or      ax,ax
  368.         pop     di
  369.         pop     cx
  370.         pop     si
  371.         ret
  372. ;
  373. bdos    equ     $
  374.         int     224
  375.         ret
  376. ;
  377.         dseg
  378.         org     80h
  379. cmdbuf  rb      0                      ;command line buffer
  380. cmdlen  rw      1                      ;command line buffer len
  381. cmdtxt  rb      126                    ;command line
  382.         org     0100h
  383. ;
  384. vermsg  db      0dh,0ah,'SW-V20 Version 1.0 '
  385.         db      'Copyright (C) 1986 Thomas M. Langley - All rights reserved.'
  386.         db      0dh,0ah,'$'
  387. ;
  388. ermsg1  db      0dh,0ah,'No command name specified.',0dh,0ah,'$'
  389. ermsg2  db      0dh,0ah,'SWV20: Program File "'
  390. ermsg2a db      '            '
  391. ermsg2b db      '" cannot be opened.',0dh,0ah,'$'
  392. ermsg2l equ     offset $ - offset ermsg2a
  393. ermsg3  db      0dh,0ah,'Program file too large',0dh,0ah,'$'
  394. ermsg4  db      0dh,0ah,'Error loading program file',0dh,0ah,'$'
  395. ;
  396. wrkbuf  db      0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  397. ;
  398. pfcb    equ     $
  399. pfcbnam dw      offset wrkbuf
  400. pfcbfcb dw      offset wrkfcb
  401. ;
  402. ftype1  rw      0
  403.         db      '.C'
  404. ftype2  rw      0
  405.         db      'OM'
  406. ;
  407. crlf    db      0dh,0ah,'$'
  408. wrkfcb  rb      0
  409. prfcb   equ     $                      ;default fcb 1
  410. prfcbdr db      0                      ;default drive
  411.         db      0,0, 0,0,0             ;f1-f5 (file name
  412. prfcbf6 db      0
  413.         rb      36-7                   ;rest of fcb
  414.         db      0
  415. wrkfcbl equ     offset $ - offset wrkfcb
  416. ;
  417.         sseg
  418.         org     0
  419.         rw      32
  420. stack   equ     $
  421.         db      0
  422. ;
  423. jmp80   equ     0c3h
  424. ret80   equ     0c9h
  425. mvia    equ     3eh
  426. mvic    equ     0eh
  427. mvie    equ     1eh
  428. movac   equ     79h
  429. movea   equ     5fh
  430. ;
  431.         eseg
  432.         org     0
  433.         db      jmp80
  434.         dw      biosv
  435. iobyte  db      0                      ;CP/M io byte
  436. curdsk  db      0                      ;currently logged disk and user number
  437.         db      jmp80
  438.         dw      bdosj
  439.         org     5ch
  440. cpmfcb1 rb      1                      ;first fcb
  441.         rb      15
  442. cpmfcb2 rb      1                      ;second fcb
  443.         rb      15
  444.         rb      4
  445.         org     80h
  446. cpmdma  rw      1                      ;default dma buffer and command line
  447. cpmtxt  rb      126
  448. ;
  449.         org     0100h
  450. tpa     equ     $
  451. ;
  452. ;       This is the emulation mode code to link to native mode opsys.
  453. ;       It is relocated from here to top of ram during execution and
  454. ;       this area is overlaid by the transient program.
  455. ;
  456. bas80   equ     0fe00h - offset $      ;relocation value
  457. ;
  458. bdosv   equ     bas80 + offset $
  459.         rb      6
  460. bdosj   equ     bas80 + offset $
  461.         db      jmp80                  ;call
  462.         dw      bdose
  463. bdose   equ     bas80 + offset $
  464.         db      0edh,0edh,224          ;calln 224
  465.         db      ret80
  466. estart  equ     bas80 + offset $
  467.         db      0cdh
  468.         dw      0100h
  469.         db      0edh,0fdh
  470.  
  471. ;
  472. biosv   equ     bas80 + offset $
  473.         db      jmp80
  474.         dw      cold
  475.         db      jmp80
  476.         dw      warm
  477.         db      jmp80
  478.         dw      const
  479.         db      jmp80
  480.         dw      conin
  481.         db      jmp80
  482.         dw      conout
  483.         db      jmp80
  484.         dw      lstout
  485.         db      jmp80
  486.         dw      punch
  487.         db      jmp80
  488.         dw      reader
  489.         db      jmp80
  490.         dw      home
  491.         db      jmp80
  492.         dw      seldsk
  493.         db      jmp80
  494.         dw      settrk
  495.         db      jmp80
  496.         dw      setsec
  497.         db      jmp80
  498.         dw      setdma
  499.         db      jmp80
  500.         dw      read
  501.         db      jmp80
  502.         dw      write
  503.         db      jmp80
  504.         dw      listst
  505.         db      jmp80
  506.         dw      sectran
  507. ;
  508. cold    equ     bas80 + offset $
  509. warm    equ     bas80 + offset $
  510.         db      mvic,0
  511.         db      jmp80
  512.         dw      bdosj
  513. const   equ     bas80 + offset $
  514.         db      mvic,0bh               ;cp/m get console status
  515.         db      jmp80
  516.         dw      bdosj
  517. conin   equ     bas80 + offset $
  518.         db      mvic,6
  519.         db      mvie,0fdh              ;cp/m input raw i/o
  520.         db      jmp80
  521.         dw      bdosj
  522. conout  equ     bas80 + offset $
  523.         db      movac
  524.         db      movea
  525.         db      mvic,6                 ;cp/m output raw i/o
  526.         db      jmp80
  527.         dw      bdosj
  528. lstout  equ     bas80 + offset $
  529.         db      movac
  530.         db      movea
  531.         db      mvic,5                 ;cp/m write to printer
  532.         db      jmp80
  533.         dw      bdosj
  534. punch   equ     bas80 + offset $
  535.         db      movac
  536.         db      movea
  537.         db      mvic,4                 ;cp/m aux write
  538.         db      jmp80
  539.         dw      bdosj
  540. reader  equ     bas80 + offset $
  541.         db      mvic,3                 ;cp/m aux read
  542.         db      jmp80
  543.         dw      bdosj
  544. ;
  545. home    equ     bas80 + offset $
  546. seldsk  equ     bas80 + offset $
  547. settrk  equ     bas80 + offset $
  548. setsec  equ     bas80 + offset $
  549. setdma  equ     bas80 + offset $
  550. read    equ     bas80 + offset $
  551. write   equ     bas80 + offset $
  552. sectran equ     bas80 + offset $
  553.         db      ret80
  554. ;
  555. listst  equ     $
  556.         db      mvia,0ffh
  557.         db      ret80
  558. ;
  559. copylen equ     offset $ - offset tpa
  560. ;
  561.         end
  562. ;
  563. Φ.áαó±░╨╪rΘ░óÆóæóÉóΓó;┤ú*ú$ó╫ó┌ó█ó╓óε░óßó╪ó┘ó▌╞<■áα╨╪s ░*PΦ·Φ=Φ    ╞r Ç>±uΦ┼Φ┼╕áPΦPá╫╨╪s
  564. ░P╕áPΦΣΦÇ>π=t
  565. Ç>π_tΦ╕BPΦ$Ç>╬uAÇ>ptΦ≡Φ■Φ¡╞╬áu
  566. ╫
  567. w╨╪s╕BP╕\P░$PΦΘ ╕CP╕íP░#δ#Ç>╬u%Ç>puΦ╣Φh╞p╕íP╕CP░,PΦ╠ΦáδÇ>╬v    ░PΦ.Θ┌■Ç>╬t╞╪Ç>╬tÇ>╬uΦï< u░PΦá▌╨╪s╧╞┘ΦIÇ>π,tÇ>πt░PΦßÇ>π,░ t@ó▌
  568. :1B01958100FF00B0FF742FBFE501BE82008A040AC074143C20741072073C7AA9
  569. :1B01B081770388054746FF0E800075E6E8410032C0880581FFE5017502FEC8EC
  570. :1B01CB8150E80600588AE00AC0C3F7068000FF00740FBE8200803C207507462E
  571. :1B01E681FF0E800075F4E81100B000F7068000FF007502FEC88AE00AC0C357D7
  572. :1B02018156068CD88EC08B0E80000BC97405BF8200F3A4B97F002B0E800032F2
  573. :1B021C81C0F3AA075E5FC3565157C706F501E501C706F7010002BAF501B198FB
  574. :0C023781E806000BC05F595EC3CDE0C338
  575. :1B0100820D0A53572D5632302056657273696F6E20312E3020436F7079726971
  576. :1B011B826768742028432920313938362054686F6D6173204D2E204C616E678F
  577. :1B0136826C6579202D20416C6C207269676874732072657365727665642E0DF0
  578. :1B0151820A240D0A4E6F20636F6D6D616E64206E616D6520737065636966694C
  579. :1B016C8265642E0D0A240D0A53575632303A2050726F6772616D2046696C6579
  580. :1B0187822022202020202020202020202020222063616E6E6F74206265206FDE
  581. :1B01A28270656E65642E0D0A240D0A50726F6772616D2066696C6520746F6F2A
  582. :1B01BD82206C617267650D0A240D0A4572726F72206C6F6164696E672070721E
  583. :1B01D8826F6772616D2066696C650D0A24000000000000000000000000000079
  584. :1401F3820000E50100022E434F4D0D0A240000000000000046
  585. :010224820057
  586. :01004083003C
  587. :08000084C312FE0000C306FEDA
  588. :1B010684C309FEEDEDE0C9CD0001EDFDC345FEC345FEC34AFEC34FFEC356FE17
  589. :1B012184C35DFEC364FEC36BFEC370FEC370FEC370FEC370FEC370FEC370FEAA
  590. :1B013C84C370FEC37101C370FE0E00C306FE0E0BC306FE0E061EFDC306FE7969
  591. :1B0157845F0E06C306FE795F0E05C306FE795F0E04C306FE0E03C306FEC93E8D
  592. :02017284FFC93F
  593. :00000001FF
  594. 72726F72206C6F6164696E672070721E
  595. :1B01D8826F6772616D2066696C650D0A24000000000000        db      mvic,5                 ;cp/m write to printer
  596.         db      jmp80
  597.         dw      bdosj
  598. punch   equ     bas80 + offset $
  599.         db      movac
  600.         db      movea
  601.         db      mvic,4                 ;cp/m aux write
  602.         db      jmp80
  603.         dw      bdosj
  604. reader  equ     bas80 + offset $
  605.         db      mvic,3                 ;cp/m aux read
  606.         db      jmp80
  607.         dw      bdosj
  608. ;
  609. home    equ     bas80 + offset $
  610. seldsk  equ     bas80 + offset $
  611. settrk  equ    
  612.                         ;
  613.    0171                 listst  equ     $
  614.  0171 3EFF                      db      mvia,0ffh
  615.  0173 C9                        db      ret80
  616.                         ;
  617.    0074                 copylen equ     offset $ - offset tpa
  618.                         ;
  619.                                 end
  620.  
  621.  
  622. END OF ASSEMBLY.  NUMBER OF ERRORS:   0.  USE FACTOR:  3%
  623.    bas80 + offset $
  624.    FE70                 sectran equ     bas80 + offset $
  625.  0170 C9                        db      ret80         lstout  equ     bas80 + offset $
  626.  015D 79                        db      movac
  627.  015E 5F                        db      movea
  628.  015F 0E05                      db      mvic,5                 ;cp/m write to printer
  629.  0161 C3                        db      jmp80
  630.  0162 06FE                      dw      bdosj
  631.    FE64                 punch   equ     bas80 + offset $
  632.  0164 79                        db      movac
  633.  0165 5F                        db      movea
  634.  0166 0E04                      db      mv