view level1/cmds/dw.as @ 2787:28b6ec8a14d5 lwtools-port

Added 'extern' pragam, fixed up rules.mak, changed 'section text' to 'section code' in sources
author Boisy Pitre <boisy.pitre@nuance.com>
date Sun, 27 Jan 2013 07:54:07 -0600
parents 03f26e88b809
children 19517af71188
line wrap: on
line source

********************************************************************
* dw - command interface to the server
*
* $Id$
*
* Edt/Rev  YYYY/MM/DD  Modified by
* Comment
* ------------------------------------------------------------------
*   1      2010/01/02  Aaron Wolfe
* Most basic implementation using new DW utility API

               nam       dw
               ttl       command interface to the server

tylg           set       $01       Prgrm+Objct
atrv           set       $80+rev   ReEnt+rev
rev            set       $00
edition        set       1

               section   data
pbuffer        rmb       256
pbend          rmb       2
cbuffer        rmb       256
portdev        rmb       10
portpath       rmb       1
outpath        rmb       1
numbyt         rmb       1
die            rmb       1
               endsect

               section   code
*               psect     dw_a,$01,$80,1,200,start

* signal handling
icpt           lda       #1
               sta       die,u
               rti       

command        fcc       'dw '

* save initial parameters
start:         pshs      d
               pshs      x
               clr       die,u
* set intercept handler
               leax      icpt,pcr            *ptr to handler
               os9       F$Icpt

               clra
               lbsr      TCPOpen
               lbcs      errex1


gotport        sta       portpath,u

* rawpath
			   lbsr		RawPath

* write command to port
               lda       portpath,u
               ldy       #3
               leax      command,pc
               os9       I$Write
               lbcs      errex2

* write parameters to port - X = start addr, y = # bytes, A = path#
               puls      x
               puls      y

               os9       I$WritLn
               lbcs      errex2

* read result
               leax      pbuffer,u
               lda       portpath,u
               ldy       #1
rrloop         os9       I$Read
               lbcs      errex2
               ldb       ,x+
               cmpb      #C$CR               * end of response
               bne       rrloop

* look for Fail
               ldb       pbuffer,u
               cmpb      #'F
               bne       gotconn             * we connected

* display failure message
               lda       #1
               ldy       #1
               leax      pbuffer,u
               ldb       #9                  *skip proto error info (FAIL xxx )
               abx       
prloop         os9       I$Write
               ldb       ,x+
               cmpb      #C$CR               *end of response
               bne       prloop

               ldy       #2
               leax      crlf,pc
               os9       I$Write

               lbra      done

crlf           fcb       C$CR
               fcb       C$LF

* response loop
* read 1 byte, this is how many bytes follow in this set.  0 for end of response
gotconn        nop       

* check for incoming serial data
rloop          lda       portpath,u
               ldb       #SS.Ready
               os9       I$GetStt
               bcc       serinc              read and print the byte

* if we got no data and die is set, bail
               lda       die,u
               bne       done

* sleep a while
               ldx       #0001
               os9       F$Sleep
               bra       rloop

* read B bytes from serial, print on screen
serinc         clra      
               tfr       d,y
               lda       portpath,u
               leax      pbuffer,u
               os9       I$Read
               lbcs      errex2
* print the data to stdout
               lda       #1
               leax      pbuffer,u
               os9       I$Write
               bra       rloop

done           clrb                          *no errors here			
* close port
errex2         lda       portpath,u
               os9       I$Close

errex1         os9       F$Exit              *goodbye
               endsect