home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 149.lha / SimpleTerm_v1.0 / Simpleterm.asm < prev    next >
Assembly Source File  |  1988-04-25  |  24KB  |  786 lines

  1. ;`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~
  2. ;~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`
  3. ;`~`    Simpleterm Version 1.0 - Totally Public Domain Freeware!      ~`~
  4. ;~`~           Source Code For - Simpleterm Version 1.0               `~`
  5. ;`~`             Programmed by - Luciano Bertato                      ~`~
  6. ;~`~                CompuServe - 73246,1744                           `~`
  7. ;`~`     Canada Remote Systems - LUCIANO BERTATO (Amiga Conference)   ~`~
  8. ;~`~                      Date - Monday August 1, 1988                `~`
  9. ;`~`                                                                  ~`~
  10. ;~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`
  11. ;`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~
  12. ; - To contact me through the BBS's, ie. A thank you, or a SIMPLE question:
  13. ;   Compuserve 73246,1744 and CRS (Amiga Conference) 231-0538 or 232-0442.
  14. ;
  15. ; - The files in this package includes:
  16. ;
  17. ;   Simpleterm - the working program.
  18. ;   Simpleterm.asm - the source code, this file.
  19. ;   Simpleterm.o - the object code.
  20. ;   exec.lib - my library for CreateExtIO and DeleteExtIO (public domain).
  21. ;   Make - execute program to assemble and link Simpleterm.
  22. ;   ExecuteMe - used to rename files after unarcing the arced package.
  23. ;   ReadMe - read the instructions.
  24. ;
  25. ; - You have to provide your Blink, Assem, amiga.lib files yourself.
  26. ;
  27. ; - I wrote this simple no frills terminal for educational purposes!!
  28. ;
  29. ; - The Amiga Assembler community NEEDED easy to understand fully
  30. ;   documented, up to date 68000 source code for a terminal program!!
  31. ;
  32. ; - I ask you to PLEASE spread the Simpleterm Arc'ed package to as
  33. ;   many sources as possible, such as BBS's and public domain
  34. ;   disks, etc..... But PLEASE keep all files together!!
  35. ;
  36. ; - I also ask you to not alter this source code, because it will
  37. ;   only screw things up!! I wrote this program for educational
  38. ;   purposes, NOT for adding extra features, thereby confusing
  39. ;   the heck out of assembler programmers, thereby making them
  40. ;   hate assembler!!
  41. ;
  42. ; - I learned alot during the writing of this program, and you will
  43. ;   too!! I would like to thank all the people on the BBS's that
  44. ;   helped me out. 
  45. ;
  46. ; - You don't need any include files for this program, as I defined
  47. ;   all of the symbols in the equates section of this source code.
  48. ;   when you link this program, you'll need two libraries. Of course,
  49. ;   you'll need the amiga.lib, and you'll need a lib called exec.lib,
  50. ;   which has _CreateExtIO and _DeleteExtIO. 'exec.lib' is included
  51. ;   in the arc'ed package.
  52. ;
  53. ; - Simpleterm will open an 8 color CUSTOMSCREEN (for color BBS's), then
  54. ;   open a console on the CUSTOMSCREEN, then open the serial port. The
  55. ;   code is clear on how it is done.
  56. ;
  57. ; - To set the baud rate, just change the DEF_BAUD value found in the
  58. ;   'my equates' section of this source code.
  59. ;
  60. ; - To exit Simpleterm, press the ESC key.
  61. ;
  62. ; - To dial a BBS, for pulse dialing: ATDP 232-0442 <ret>
  63. ;
  64. ; - To dial a BBS, for tone dialing: ATDT 231-0538 <ret>
  65. ;
  66. ; - This terminal can also be used in color BBS's. Looks nice!!
  67. ;
  68. ; - If Simpleterm aborts when loading (look at the code to see why),
  69. ;   it's because it couldn't set up or open something properly, such as:
  70. ;
  71. ;     - couldn't open the console or serial port
  72. ;     - couldn't allocate memory, or couldn't open a library, etc...
  73. ;
  74. ; - I used the Metacomco assembler. Therefore to assemble the program:
  75. ;
  76. ;     Assem Simpleterm.asm -o Simpleterm.o -c W50000
  77. ;
  78. ; - Using Blink:
  79. ;
  80. ;     Blink Simpleterm.o to Simpleterm LIB amiga.lib+exec.lib
  81. ;
  82. ; - Simpleterm is only 3672 bytes, and can be shortened even further,
  83. ;   because I left in some 'movea.l  _SysBase,a6' lines that are not
  84. ;   needed. Also, there are other unnessesary lines that can be taken
  85. ;   out! 3672 bytes for a terminal program!! Wow...now that's the
  86. ;   beauty of assembly programming!!
  87. ;
  88. ; - Have fun....................
  89. ;
  90. ;`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~
  91. ;~`                             Exported                               ~`
  92. ;`~                                                                    `~
  93. ;~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`
  94.    XDEF     _SysBase
  95.  
  96. ;`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~
  97. ;~`                              Macros                                ~`
  98. ;`~                                                                    `~
  99. ;~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`
  100.  
  101. CALL        MACRO
  102.               XREF    _LVO\1
  103.               JSR     _LVO\1(a6)
  104.             ENDM
  105.  
  106. LIBCALL     MACRO
  107.               XREF    _\1
  108.               JSR     _\1
  109.             ENDM
  110.  
  111. ;`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~
  112. ;~`                              Equates                               ~`
  113. ;`~                                                                    `~
  114. ;~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`
  115.  
  116. * system equates
  117.  
  118. _SysBase        EQU  4
  119.  
  120. * include file equates
  121.  
  122. CUSTOMSCREEN    EQU  15
  123. V_HIRES         EQU  $8000
  124. SMART_REFRESH   EQU  0
  125. BORDERLESS      EQU  $800
  126. ACTIVATE        EQU  $1000
  127. CMD_WRITE       EQU  3
  128. CMD_READ        EQU  2
  129. IO_DATA         EQU  $28
  130. IO_LENGTH       EQU  $24
  131. IO_DEVICE       EQU  $14
  132. IO_UNIT         EQU  $18
  133. IO_COMMAND      EQU  $1c
  134. IO_ACTUAL       EQU  $20
  135. IO_SERFLAGS     EQU  $4f
  136. IO_CTLCHAR      EQU  $30
  137. IO_RBUFLEN      EQU  $34
  138. IO_WBUFLEN      EQU  $38
  139. IO_BAUD         EQU  $3c
  140. IO_BRKTIME      EQU  $40
  141. IO_TERMARRAY1   EQU  $44
  142. IO_TERMARRAY2   EQU  $48
  143. IO_READLEN      EQU  $4c
  144. IO_WRITELEN     EQU  $4d
  145. IO_STOPBITS     EQU  $4e
  146. IO_FLAGS        EQU  $1e
  147. IOEXTSER_SIZE   EQU  $52
  148. IOF_QUICK       EQU  1
  149. SDCMD_SETPARAMS EQU  $b
  150. SDCMD_QUERY     EQU  9
  151. SERF_SHARED     EQU  $20
  152. SERF_XDISABLED  EQU  $80
  153. SERF_RAD_BOOGIE EQU  $10
  154. SERF_7WIRE      EQU  4
  155. MP_SIZE         EQU  $22
  156. MP_SIGTASK      EQU  $10
  157. MP_SIGBIT       EQU  $f
  158. MN_REPLYPORT    EQU  $e
  159. nw_Screen       EQU  30
  160. wd_RPort        EQU  $32
  161. wd_WScreen      EQU  $2e
  162. sc_ViewPort     EQU  $2c
  163.  
  164. * my equates
  165.  
  166. DEF_BAUD        EQU  1200
  167. DEF_RBUFLEN     EQU  4096
  168. DEF_WBUFLEN     EQU  4096
  169. DEF_BRKTIME     EQU  750000
  170. DEF_READLEN     EQU  8
  171. DEF_WRITELEN    EQU  8
  172. DEF_STOPBITS    EQU  1
  173. DEF_TERMARRAY1  EQU  0
  174. DEF_TERMARRAY2  EQU  0
  175. DEF_SERFLAGS    EQU  SERF_SHARED!SERF_XDISABLED!SERF_RAD_BOOGIE
  176.  
  177. ;`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~
  178. ;~`                           Assembly Code                            ~`
  179. ;`~                                                                    `~
  180. ;~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`
  181.  
  182. * start
  183.  
  184. _main:
  185.    movem.l  d0-d7/a0-a6,-(sp)        save registers
  186.  
  187. * open intuition library
  188.  
  189.    lea      IntuiName,a1             open intuition library
  190.    clr      d0
  191.    movea.l  _SysBase,a6
  192.    CALL     OpenLibrary
  193.    move.l   d0,IntuitionBase
  194.    beq      exit
  195.  
  196. * open dos library
  197.  
  198.    lea      DosName,a1               open dos library
  199.    clr      d0
  200.    CALL     OpenLibrary
  201.    move.l   d0,DosBase
  202.    beq      exit2
  203.  
  204. * open graphics library
  205.  
  206.    lea      GfxName,a1               open graphics library
  207.    clr      d0
  208.    CALL     OpenLibrary
  209.    move.l   d0,GfxBase
  210.    beq      exit3
  211.  
  212. * open the screen
  213.  
  214.    lea      newscreen,a0             open the screen
  215.    movea.l  IntuitionBase,a6
  216.    CALL     OpenScreen
  217.    move.l   d0,screenptr
  218.    beq      exit4
  219.  
  220. * open window #1
  221.  
  222.    lea      newwindow1,a0            open window #1
  223.    move.l   d0,nw_Screen(a0)
  224.    CALL     OpenWindow
  225.    move.l   d0,windowptr1
  226.    beq      exit5
  227.  
  228.    move.l   d0,a0                    get RP and VP
  229.    move.l   wd_RPort(a0),windowRPort
  230.    move.l   wd_WScreen(a0),a0
  231.    move.l   a0,screenptr
  232.    add.l    #sc_ViewPort,a0
  233.    move.l   a0,screenVPort
  234.  
  235. * make read and write ports for console
  236.  
  237.    clr.l    -(sp)                    make write message port
  238.    pea      MyConWrite               for console
  239.    LIBCALL  CreatePort
  240.    move.l   d0,conWPort
  241.    addq.l   #8,sp
  242.    tst.l    d0
  243.    beq      exit6
  244.  
  245.    move.l   d0,-(sp)                 make write IOStdReq structure
  246.    LIBCALL  CreateStdIO              for console
  247.    move.l   d0,writereqcon
  248.    addq.l   #4,sp
  249.    tst.l    d0
  250.    beq      exit7
  251.  
  252.    clr.l    -(sp)                    make read message port
  253.    pea      MyConRead                for console
  254.    LIBCALL  CreatePort
  255.    move.l   d0,conRPort
  256.    addq.l   #8,sp
  257.    tst.l    d0
  258.    beq      exit8
  259.  
  260.    move.l   d0,-(sp)                 make read IOStdReq structure
  261.    LIBCALL  CreateStdIO              for console
  262.    move.l   d0,readreqcon
  263.    addq.l   #4,sp
  264.    tst.l    d0
  265.    beq      exit9
  266.  
  267. * open the console
  268.  
  269.    move.l   writereqcon,a1          open console device
  270.    move.l   windowptr1,IO_DATA(a1)
  271.    moveq.l  #0,d0
  272.    move.l   d0,d1
  273.    lea      conname,a0
  274.    movea.l  _SysBase,a6
  275.    CALL     OpenDevice
  276.    tst.l    d0
  277.    bne      exit10
  278.  
  279.    move.l   writereqcon,a1             copy initialized write
  280.    move.l   readreqcon,a2              request to read request
  281.    move.l   IO_DEVICE(a1),IO_DEVICE(a2)
  282.    move.l   IO_UNIT(a1),IO_UNIT(a2)
  283.    move.w   #CMD_WRITE,IO_COMMAND(a1)   set structures to write
  284.    move.w   #CMD_READ,IO_COMMAND(a2)    or read
  285.  
  286. * make read and write ports for serial.device
  287.  
  288.    clr.l    -(sp)                    make write message port
  289.    pea      MySerWrite               for serial.device
  290.    LIBCALL  CreatePort
  291.    move.l   d0,serWPort
  292.    addq.l   #8,sp
  293.    tst.l    d0
  294.    beq      exit11
  295.  
  296.    move.l   #IOEXTSER_SIZE,-(sp)     make write IOExtReq structure
  297.    move.l   d0,-(sp)                 for serial.device
  298.    LIBCALL  CreateExtIO
  299.    move.l   d0,writereqser
  300.    addq.l   #8,sp
  301.    tst.l    d0
  302.    beq      exit12
  303.  
  304.    clr.l    -(sp)                    make read message port
  305.    pea      MySerRead                for serial.device
  306.    LIBCALL  CreatePort
  307.    move.l   d0,serRPort
  308.    addq.l   #8,sp
  309.    tst.l    d0
  310.    beq      exit13
  311.  
  312.    move.l   #IOEXTSER_SIZE,-(sp)     make read IOExtReq structure
  313.    move.l   d0,-(sp)                 for serial.device
  314.    LIBCALL  CreateExtIO
  315.    move.l   d0,readreqser
  316.    addq.l   #8,sp
  317.    tst.l    d0
  318.    beq      exit14
  319.  
  320. * open the serial.device for output and input
  321.  
  322.    move.l   writereqser,a1                open the serial.device
  323.    move.b   #SERF_SHARED,IO_SERFLAGS(a1)  for output
  324.    moveq.l  #0,d0
  325.    move.l   d0,d1
  326.    lea      sername,a0
  327.    movea.l  _SysBase,a6
  328.    CALL     OpenDevice
  329.    tst.l    d0
  330.    bne      exit15
  331.  
  332.    move.l   readreqser,a1                 open the serial.device
  333.    move.b   #SERF_SHARED,IO_SERFLAGS(a1)  for input
  334.    moveq.l  #0,d0
  335.    move.l   d0,d1
  336.    lea      sername,a0
  337.    movea.l  _SysBase,a6
  338.    CALL     OpenDevice
  339.    tst.l    d0
  340.    bne      exit16
  341.  
  342. * set the default parameters for the serial.device
  343.  
  344.    bsr      SetDefaultParms          call subroutine to set default params
  345.    tst.l    d0
  346.    bne      exit17
  347.  
  348.    move.l   writereqser,a1            set structures to write
  349.    move.l   readreqser,a2             or read
  350.    move.w   #CMD_WRITE,IO_COMMAND(a1)
  351.    move.w   #CMD_READ,IO_COMMAND(a2)
  352.  
  353. * set console and serial devices to get 1 character
  354.  
  355.    bsr      ConGetChar
  356.    bsr      SerGetChar
  357.  
  358. * main loop of the program
  359.  
  360. mainloop:
  361.    move.l   conRPort,a0              set the signals for the
  362.    clr.l    d3                       console and serial devices
  363.    move.b   MP_SIGBIT(a0),d3
  364.    moveq.l  #1,d1
  365.    lsl.l    d3,d1
  366.    move.l   serRPort,a0
  367.    clr.l    d3
  368.    move.b   MP_SIGBIT(a0),d3
  369.    moveq.l  #1,d2
  370.    lsl.l    d3,d2
  371.    move.l   d1,d0
  372.    or.l     d2,d0
  373.    move.l   _SysBase,a6
  374.    CALL     Wait                     wait for a signal from the
  375.    cmp.l    d1,d0                    console or serial devices
  376.    beq      maincon
  377.    cmp.l    d2,d0
  378.    bne      mainloop
  379.  
  380. mainser:
  381.    move.l   readreqser,a1            print all characters that are received
  382.    move.l   _SysBase,a6              from the serial device to the console
  383.    CALL     CheckIO
  384.    beq      mainloop
  385.    move.l   readreqser,a1
  386.    move.l   _SysBase,a6
  387.    CALL     WaitIO
  388.    bne      mainloop
  389.    move.l   #SerReadCharBuff,d0
  390.    bsr      ConWriteChar
  391.    move.l   readreqser,a1
  392.    move.w   #SDCMD_QUERY,IO_COMMAND(a1)
  393.    move.l   _SysBase,a6
  394.    CALL     DoIO
  395.    move.l   readreqser,a1
  396.    move.w   #CMD_READ,IO_COMMAND(a1)
  397.    move.b   #IOF_QUICK,IO_FLAGS(a1)
  398.    move.l   IO_ACTUAL(a1),IO_LENGTH(a1)
  399.    move.l   #SerReadCharBuff,IO_DATA(a1)
  400.    move.l   _SysBase,a6
  401.    CALL     DoIO
  402.    move.l   readreqser,a1
  403.    move.l   IO_DATA(a1),d1
  404.    move.l   IO_ACTUAL(a1),d2
  405.    bsr      ConWrite
  406.    bsr      SerGetChar               loop back to mainser to see if
  407.    bra      mainser                  there's any more characters
  408.  
  409. maincon:
  410.    move.l   readreqcon,a1            get the characters that were
  411.    move.l   _SysBase,a6              typed from the console, and
  412.    CALL     CheckIO                  send them to the serial.device
  413.    beq      mainser
  414.    move.l   readreqcon,a1
  415.    move.l   _SysBase,a6
  416.    CALL     WaitIO
  417.    bne      mainloop
  418.    move.l   #ConReadCharBuff,a0
  419.    cmpi.b   #$1b,(a0)                to quit program >> press ESC key
  420.    beq      exit17
  421.    move.l   a0,d0
  422.    bsr      SerWriteChar
  423.    bsr      ConGetChar               loop back to maincon to see if
  424.    bra      maincon                  there's any more characters
  425.  
  426. * close serial.device for input
  427.  
  428. exit17:
  429.    move.l   readreqser,a1            close serial.device for input or
  430.    movea.l  _SysBase,a6              abort because can't set
  431.    CALL     CloseDevice              default parms for serial.device
  432.  
  433. * close serial.device for output
  434.  
  435. exit16:
  436.    move.l   writereqser,a1           close serial.device for output or
  437.    movea.l  _SysBase,a6              abort because can't open
  438.    CALL     CloseDevice              the serial.device for input
  439.  
  440. * delete serial.device read IOExtSer structure
  441.  
  442. exit15:
  443.    move.l   #IOEXTSER_SIZE,-(sp)
  444.    move.l   readreqser,-(sp)         delete serial.device read IOExtSer
  445.    LIBCALL  DeleteExtIO              structure or abort because can't open
  446.    addq.l   #8,sp                    serial.device for output
  447.  
  448. * close serial.device read message port
  449.  
  450. exit14:
  451.    move.l   serRPort,-(sp)           close serial.device read message port
  452.    LIBCALL  DeletePort               or abort because can't open read
  453.    addq.l   #4,sp                    IOExtSer structure for serial.device
  454.  
  455. * delete serial.device write IOExtSer structure
  456.  
  457. exit13:
  458.    move.l   #IOEXTSER_SIZE,-(sp)
  459.    move.l   writereqser,-(sp)        delete serial.device write IOExtSer
  460.    LIBCALL  DeleteExtIO              structure or abort because can't open
  461.    addq.l   #8,sp                    read message port for serial.device
  462.  
  463. * close serial.device write message port
  464.  
  465. exit12:
  466.    move.l   serWPort,-(sp)           close serial.device write message port
  467.    LIBCALL  DeletePort               or abort because can't open write
  468.    addq.l   #4,sp                    IOExtSer structure for serial.device
  469.  
  470. * close console
  471.  
  472. exit11:
  473.    move.l   writereqcon,a1           close console.device or abort
  474.    movea.l  _SysBase,a6              because can't open write 
  475.    CALL     CloseDevice              message port for serial.device
  476.  
  477. * delete console.device read IOStdReq structure
  478.  
  479. exit10:
  480.    move.l   readreqcon,-(sp)         delete console.device read IOStdReq
  481.    LIBCALL  DeleteStdIO              structure or abort because can't open
  482.    addq.l   #4,sp                    console.device
  483.  
  484. * close console.device read message port
  485.  
  486. exit9:
  487.    move.l   conRPort,-(sp)           close console.device read message port
  488.    LIBCALL  DeletePort               or abort because can't open read
  489.    addq.l   #4,sp                    IOStdReq structure for console.device
  490.  
  491. * delete console.device write IOStdReq structure
  492.  
  493. exit8:
  494.    move.l   writereqcon,-(sp)        delete console.device write IOStdReq
  495.    LIBCALL  DeleteStdIO              structure or abort because can't open
  496.    addq.l   #4,sp                    read message port for console.device
  497.  
  498. * close console.device write message port
  499.  
  500. exit7:
  501.    move.l   conWPort,-(sp)           close console.device write message port
  502.    LIBCALL  DeletePort               or abort because can't open write
  503.    addq.l   #4,sp                    IOStdReq structure for console.device
  504.  
  505. * close window #1
  506.  
  507. exit6:
  508.    movea.l  windowptr1,a0            close window #1 or abort because
  509.    movea.l  IntuitionBase,a6         can't open write message port
  510.    CALL     CloseWindow              for console.device
  511.  
  512. * close the screen
  513.  
  514. exit5:
  515.    movea.l  screenptr,a0             close the screen or abort
  516.    movea.l  IntuitionBase,a6         because of window for I/O
  517.    CALL     CloseScreen              open error
  518.  
  519. * close graphics library
  520.  
  521. exit4:
  522.    movea.l  GfxBase,a1               close graphics library or
  523.    movea.l  _SysBase,a6              abort because of screen
  524.    CALL     CloseLibrary             open error
  525.  
  526. * close dos library
  527.  
  528. exit3:
  529.    movea.l  DosBase,a1               close dos library or abort
  530.    movea.l  _SysBase,a6              because of graphics open
  531.    CALL     CloseLibrary             error
  532.  
  533. * close intuition library
  534.  
  535. exit2:
  536.    movea.l  IntuitionBase,a1         close intuition library or
  537.    movea.l  _SysBase,a6              abort because of dos open
  538.    CALL     CloseLibrary             error
  539.  
  540. * exit program
  541.  
  542. exit:
  543.    movem.l  (sp)+,d0-d7/a0-a6        exit or abort because
  544.    clr.l    d0                       of intuition open error
  545.    rts
  546.  
  547. ;`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~
  548. ;~`                            Subroutines                             ~`
  549. ;`~                                                                    `~
  550. ;~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`
  551.  
  552. *
  553. * set the serial.device to default parameters
  554. *
  555. *  error = SetDefaultParms()
  556. *   d0
  557.  
  558. SetDefaultParms:
  559.    move.l   writereqser,a1
  560.    bsr      SetDefaultParms_sub
  561.    bne      SetDefaultParms_error
  562.    move.l   readreqser,a1
  563.    bsr      SetDefaultParms_sub
  564. SetDefaultParms_error:
  565.    rts
  566. SetDefaultParms_sub:
  567.    move.l   #DEF_RBUFLEN,IO_RBUFLEN(a1)
  568.    move.w   #DEF_WBUFLEN,IO_WBUFLEN(a1)
  569.    move.l   #DEF_BAUD,IO_BAUD(a1)
  570.    move.l   #DEF_BRKTIME,IO_BRKTIME(a1)
  571.    move.b   #DEF_READLEN,IO_READLEN(a1)
  572.    move.b   #DEF_WRITELEN,IO_WRITELEN(a1)
  573.    move.b   #DEF_STOPBITS,IO_STOPBITS(a1)
  574.    move.b   #DEF_SERFLAGS,IO_SERFLAGS(a1)
  575.    move.l   #DEF_TERMARRAY1,IO_TERMARRAY1(a1)
  576.    move.l   #DEF_TERMARRAY2,IO_TERMARRAY2(a1)
  577.    move.w   #SDCMD_SETPARAMS,IO_COMMAND(a1)
  578.    move.l   _SysBase,a6
  579.    CALL     DoIO
  580.    rts
  581.  
  582. *
  583. * write to the console.device
  584. *
  585. *  actual_length = ConWrite(buffer,length)
  586. *     d0                      d1     d2
  587.  
  588. ConWrite:
  589.    movem.l  a0-a7/d1-d7,-(sp)
  590.    move.l   writereqcon,a1
  591.    move.l   a1,-(sp)
  592.    move.l   d1,IO_DATA(a1)
  593.    move.l   d2,IO_LENGTH(a1)
  594.    movea.l  _SysBase,a6
  595.    CALL     DoIO
  596.    move.l   (sp)+,a1
  597.    move.l   IO_ACTUAL(a1),d0
  598.    movem.l  (sp)+,a0-a7/d1-d7
  599.    rts
  600.  
  601. *
  602. * write to the serial.device
  603. *
  604. *  actual_length = SerWrite(buffer,length)
  605. *     d0                      d1     d2
  606.  
  607. SerWrite:
  608.    movem.l  a0-a7/d1-d7,-(sp)
  609.    move.l   writereqser,a1
  610.    move.l   a1,-(sp)
  611.    move.l   d1,IO_DATA(a1)
  612.    move.l   d2,IO_LENGTH(a1)
  613.    movea.l  _SysBase,a6
  614.    CALL     DoIO
  615.    move.l   (sp)+,a1
  616.    move.l   IO_ACTUAL(a1),d0
  617.    movem.l  (sp)+,a0-a7/d1-d7
  618.    rts
  619.  
  620. *
  621. * set console read port to wait for 1 character
  622. *
  623. *  ConGetChar()
  624. *
  625.  
  626. ConGetChar:
  627.    movem.l  a0-a7/d0-d7,-(sp)
  628.    move.l   readreqcon,a1
  629.    move.l   #ConReadCharBuff,IO_DATA(a1)
  630.    move.l   #1,IO_LENGTH(a1)
  631.    move.l   _SysBase,a6
  632.    CALL     SendIO
  633.    movem.l  (sp)+,a0-a7/d0-d7
  634.    rts
  635.  
  636. *
  637. * set serial read port to wait for 1 character
  638. *
  639. *  SerGetChar()
  640. *
  641.  
  642. SerGetChar:
  643.    movem.l  a0-a7/d0-d7,-(sp)
  644.    move.l   readreqser,a1
  645.    move.l   #SerReadCharBuff,IO_DATA(a1)
  646.    move.l   #1,IO_LENGTH(a1)
  647.    move.l   _SysBase,a6
  648.    CALL     SendIO
  649.    movem.l  (sp)+,a0-a7/d0-d7
  650.    rts
  651.  
  652. *
  653. * write 1 character to the console
  654. *
  655. *  actual_length = ConWriteChar(buffer)
  656. *     d0                          d0
  657.  
  658. ConWriteChar:
  659.    movem.l  a0-a7/d1-d7,-(sp)
  660.    move.l   writereqcon,a1
  661.    move.l   a1,-(sp)
  662.    move.l   d0,IO_DATA(a1)
  663.    move.l   #1,IO_LENGTH(a1)
  664.    movea.l  _SysBase,a6
  665.    CALL     DoIO
  666.    move.l   (sp)+,a1
  667.    move.l   IO_ACTUAL(a1),d0
  668.    movem.l  (sp)+,a0-a7/d1-d7
  669.    rts
  670.  
  671. *
  672. * write 1 character to the serial device
  673. *
  674. *  actual_length = SerWriteChar(buffer)
  675. *     d0                          d0
  676.  
  677. SerWriteChar:
  678.    movem.l  a0-a7/d1-d7,-(sp)
  679.    move.l   writereqser,a1
  680.    move.l   a1,-(sp)
  681.    move.l   d0,IO_DATA(a1)
  682.    move.l   #1,IO_LENGTH(a1)
  683.    movea.l  _SysBase,a6
  684.    CALL     DoIO
  685.    move.l   (sp)+,a1
  686.    move.l   IO_ACTUAL(a1),d0
  687.    movem.l  (sp)+,a0-a7/d1-d7
  688.    rts
  689.  
  690. ;`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~
  691. ;~`                          Initialized Data                          ~`
  692. ;`~                                                                    `~
  693. ;~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`
  694.  
  695.    SECTION   data,DATA
  696.  
  697. IntuiName:
  698.    dc.b     'intuition.library',0
  699.    cnop     0,2
  700. GfxName:
  701.    dc.b     'graphics.library',0
  702.    cnop     0,2
  703. DosName:
  704.    dc.b     'dos.library',0
  705.    cnop     0,2
  706. screenname:
  707.    dc.b     'Simpleterm V1.0, August 1988, By Luciano Bertato',0
  708.    cnop     0,2
  709. newscreen:
  710.    dc.w     0,0,640,200,3
  711.    dc.b     0,1
  712.    dc.w     V_HIRES,CUSTOMSCREEN
  713.    dc.l     0,screenname,0,0
  714. newwindow1:
  715.    dc.w     0,13,640,187
  716.    dc.b     0,1
  717.    dc.l     0
  718.    dc.l     SMART_REFRESH!ACTIVATE!BORDERLESS
  719.    dc.l     0,0,0,0,0
  720.    dc.w     640,200,640,200,CUSTOMSCREEN
  721. conname:
  722.    dc.b     'console.device',0
  723.    cnop     0,2
  724. sername:
  725.    dc.b     'serial.device',0
  726.    cnop     0,2
  727. MyConWrite:
  728.    dc.b     'ConCreateIO.write',0
  729.    cnop     0,2
  730. MyConRead:
  731.    dc.b     'ConCreateIO.read',0
  732.    cnop     0,2
  733. MySerWrite:
  734.    dc.b     'SerCreateIO.write',0
  735.    cnop     0,2
  736. MySerRead:
  737.    dc.b     'SerCreateIO.read',0
  738.    cnop     0,2
  739.  
  740. ;`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~
  741. ;~`                         Uninitialized Data                         ~`
  742. ;`~                                                                    `~
  743. ;~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`
  744.  
  745.    SECTION   mem,BSS
  746.  
  747. IntuitionBase:
  748.    ds.l     1          ; intuition base address pointer
  749. DosBase:
  750.    ds.l     1          ; dos base address pointer
  751. GfxBase:
  752.    ds.l     1          ; graphics base address pointer
  753. screenptr:
  754.    ds.l     1          ; screen pointer
  755. windowptr1:
  756.    ds.l     1          ; window for I/O pointer
  757. windowRPort:
  758.    ds.l     1          ; RP of window1
  759. screenVPort:
  760.    ds.l     1          ; VP of screen
  761. writereqcon:
  762.    ds.l     1          ; pointer to write IOStdReq structure for console
  763. readreqcon:
  764.    ds.l     1          ; pointer to read IOStdReq structure for console
  765. conWPort:
  766.    ds.l     1          ; pointer to write message port for console
  767. conRPort:
  768.    ds.l     1          ; pointer to read message port for console
  769. writereqser:
  770.    ds.l     1          ; pointer to write IOExtSer structure for serial.device
  771. readreqser:
  772.    ds.l     1          ; pointer to read IOExtSer structure for serial.device
  773. serWPort:
  774.    ds.l     1          ; pointer to write message port for serial.device
  775. serRPort:
  776.    ds.l     1          ; pointer to read message port for serial.device
  777. ConReadCharBuff:
  778.    ds.w     1          ; 1 character buffer for the console input port
  779. SerReadCharBuff:
  780.    ds.b     4096       ; character buffer for the serial input port
  781.  
  782. ;`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~
  783.  
  784.    END
  785.  
  786.