⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fax.asm

📁 智能电话系统的全部C-51,ASM51源程序 内部文件较多
💻 ASM
📖 第 1 页 / 共 4 页
字号:
;***************************************************************************
;*                                                                         *
;*      模块名:           智能电话系统汇编程序模块                         *
;*      说明:             此模块为汇编汇编子函数,用ASM51编译               *
;*      设计时间:         一九九七年五月二十九日                           *
;*                                                                         *
;***************************************************************************

                 NAME    fax(18)
                 RSEG    CODE(0)
;
func_voice              equ     01h
tab_col         equ     2fb0h           ;1996,10,14 (80 byte)
modemvoc        equ     3021h          ; open modem speaker or not
func_trnsprnt           equ     03h
telebusy        equ     301fh
telebusy1       equ     3020h


hi_mem          equ     0e1h
lo_mem          equ     0e0h
;
;com_bit         bit     10h             ;1996,09,26
;
;       definitions for enter and leef
cr              equ     0dh
lf              equ     0ah
;
;       definitions for messages
echo_ok         equ     070h
echo_connect    equ     071h
echo_ring       equ     072h
echo_nocarier   equ     073h
echo_error      equ     074h
echo_cn1200     equ     075h
echo_nodtone    equ     076h
echo_busy       equ     077h
echo_noanswer   equ     078h
echo_cn2400     equ     079h
echo_data       equ     07ah
echo_fax        equ     07bh
echo_fcerr      equ     07ch
echo_unknown    equ     07fh
;       tel.line status( point to  byte )
resultptr       equ     0630h  ;#3002h                  ;byte pointer
func_vt100      equ     06h                ;added aug.1,1995
;       point to the function byte
funcpointer     equ     0640h  ;#3006h                  ;byte pointer
;
;       definitions for system state
sys_command     equ     000h
sys_connect     equ     055h
;       point to the state byte
sysstate        equ     0650h  ;#3005h                  ;byte pointer
;
;       definitions for operations
op_none         equ     00h
op_ddial        equ     01h
op_vdial        equ     02h
op_ring         equ     03h
op_cancel       equ     04h
op_communicate  equ     05h
op_record       equ     06h
;       point to the operation byte
operateptr      equ     0660h  ;#3008h                  ;byte pointer
;
;       fax i/o ports
r3fe            equ     206h                   ;port address
r3fd            equ     205h                   ;port address
r3fc            equ     204h                   ;port address
r3fb            equ     203h                   ;port address
r3fa            equ     202h                   ;port address
r3f9            equ     201h                   ;port address
r3f8            equ     200h                   ;port address
;
;       clear interrupt port
intreg          equ     0218h                  ;port address
;
;       channel control port
chnport         equ     0210h  ;port address
;
;       comm. baud setting(8031)
siorate         equ     0f4h            ;0fdh 9600,  0f4h 2400
;
;       comm. baud setting(fax)
faxrate         equ     30h             ;0ch 9600, 30h 2400
frmt8n          equ     03h                    ;8,n,1
frmt7o          equ     0ah                    ;7,o,1
frmt7e          equ     1ah                    ;7,e,1
;
;       channel word( point to byte )
chnword         equ     0670h  ;#3000h                  ;byte pointer
;
;       ring times settings( point to byte )
ringcntptr      equ     0680h  ;#3007h                  ;byte pointer
recordring      equ     0690h  ;#3009h                  ;byte pointer
record_bit      equ     0691h                   ;1996,10,28
lastring        equ     06a0h  ;#2ffch                  ;last detection of ring tone
lastbusy        equ     06b0h  ;#2ffdh                  ;last detection of busy tone
timerintcnt     equ     06c0h  ;#2ffeh                  ;times of timer interrupt
busycounter     equ     06d0h  ;#2fffh                  ;busy tone
;
;       new command line detected or 0ah received( point to byte )
endofcmd        equ     06e0h  ;#3003h                  ;byte pointer
;
;       used by timer, base( point to byte )
timeaddr        equ     06f0h  ;#3004h                  ;byte pointer
timercnt        equ     01h
;
;       pointer to the temporary exchanging buffer, length in the first 1 bytes
;       max. length is 256-1
tmpptr          equ     0700h  ;#2000h                  ;buffer pointer
lotmpptr        equ     00h
hitmpptr        equ     07h    ;#20h
;
;       pointer to the temporary exchanging buffer, length in the first 1 bytes
;       max. length is 256-1
tmpbufptr       equ     0800h  ;#2100h                  ;buffer pointer
lotmpbufptr     equ     00h
hitmpbufptr     equ     08h    ;#21h
;
;       pointer to the buffer holding two pointer( source ptr. and dest. ptr )
;       used by comparing two string
ptrptr          equ     0900h  ;#2200h                  ;pointer to pointer
loptrptr        equ     00h
hiptrptr        equ     09h    ;#22h
;
;       constant parameters
packlen         equ     84h   ;128 bytes
maxretry        equ     0ah   ;16 retries
maxackwt        equ     05h   ;5 seconds
maxfrmwt        equ     78h   ;2 minutes
;
;       local variables
byterecv        equ     0910h  ;#300ah  ;1 byte---received bytes
retry           equ     0920h  ;#300bh  ;1 byte---#retry times
fcancel         equ     0930h  ;#300ch  ;1 byte---cancel flag
sndretry        equ     0940h  ;#300dh  ;1 byte---send retries
framrest        equ     0950h  ;#300eh  ;1 byte---length of last frame
framnum         equ     0960h  ;#300fh  ;1 byte---number of frame
sndpoint        equ     0970h  ;#3010h  ;2 byte---send pointer
;
;       definitions for messages
pulse           equ     00h
dtmf            equ     02h
;       dialing mode( 1 byte )
dialmode        equ     0980h  ;#3012h                  ;byte pointer
;
;       buffer for dialing string( 128 bytes )
dstring         equ     0990h  ;#3015h                  ;byte pointer
;
;       signal command (constant)
soh             equ     01h
eot             equ     04h
ack             equ     06h
nak             equ     15h
xon             equ     11h    ;added aug.1,1995
xoff            equ     13h    ;added aug.1,1995
xofftoon        equ     14h    ;added 1996.6
;
funcsave        equ     09a0h  ;#2ffah  ;keep function, added aug.1,1995
tranflow        equ     09b0h  ;#2ffbh  ;trans. flow control, added aug.1,1995
recvflow        equ     09c0h  ;#2ffch  ;recv. flow control, added aug.1,1995
;
;       result code (constant)
success         equ     0h
timeout         equ     1h
can             equ     2h
mailfull        equ     3h
fatal           equ     4h
linkerr         equ     5h
nomail          equ     6h
;
;       crc generator
hicrcgen        equ     010h
locrcgen        equ     021h
;
;       pointer to the frame buffer before writing the mail file
;       structure of the transmitted frame, crc for len and data
;               #soh[1] | seq[1] | nseq[1] | len[1] | data[128] | crc[2]
;       structure of the frame buffer
;               seq[1] | nseq[1] | len[1] | data[128] | crc[2]
ptrframe        equ     09d0h  ;#3100h  ;writing pointer
;
filebuff        equ     09e0h  ;#3200h  ;pointer to the file buffer
lofilebf        equ     0e0h   ;#00h    ;pointer to the file buffer(lsb)
hifilebf        equ     09h    ;#32h    ;pointer to the file buffer(msb)
;
crcstart        equ     09e2h  ;#3202h  ;pointer to buffer to be crc
crclenth        equ     80h    ;length of crc data
;
;       mail file index and container
wrpoint         equ     0af0h  ;#3ccah          ; 2 bytes(lsb)-(msb)
;;;;;
;maxem           equ     10h            ; 1b: number of email records
;s_nemail        equ     3ccch          ; 1b: number of email records
;s_emindex       equ     3ccdh          ; 2b * #masem: email index table
;;;;;       mails received
r_nemail        equ     3ccch          ; 1b: number of email records
;;;;;
r_emindex       equ     3ccdh          ; 2b * #masem: email index table
r_emindex_l     equ     0cdh           ; email index (low)
r_emindex_h     equ     3ch            ; email index (high)
;;;;;
;;;;;       email has the variable length, so we need index table, 2b per email record.
r_embase        equ     3cedh          ; email base address
r_embase_l      equ     0edh           ; email base address(low)
r_embase_h      equ     3ch            ; email base address(high)
;
;       definition of timer register address
;       comm receiving queue locations
comm_ptr        equ     00h        ;pointer to header of the queue(16 bits)
;       fax/modem transfering queue locations
faxt_ptr        equ     01h        ;pointer to header of the queue(16 bits)
;       fax/modem receiving queue locations
faxr_ptr        equ     02h        ;pointer to header of the queue(16 bits)
;       vt100 receiving queue locations
rvt_ptr         equ     03h        ;pointer to header of the queue(16 bits)
;       vt100 transfering queue locations
tvt_ptr         equ     04h        ;pointer to header of the queue(16 bits)
;
;       comm queue w/r pointers
comm_rd         equ     002dh        ;address of the read pointer(16 bits)
comm_wr         equ     002fh        ;address of the write pointer(16 bits)
;
;       fax/modem transfering queue w/r pointers
faxt_rd         equ     0031h        ;address of the read pointer(16 bits)
faxt_wr         equ     0033h        ;address of the write pointer(16 bits)
;
;       fax/modem receiving queue w/r pointers
faxr_rd         equ     0035h        ;address of the read pointer(16 bits)
faxr_wr         equ     0037h        ;address of the write pointer(16 bits)
;        
;       vt100 receiving queue w/r pointers
rvt_rd          equ     0039h        ;address of the read pointer(16 bits)
rvt_wr          equ     003bh        ;address of the write pointer(16 bits)
;        
;       vt100 transfering queue w/r pointers
tvt_rd          equ     003dh        ;address of the read pointer(16 bits)
tvt_wr          equ     003fh        ;address of the write pointer(16 bits)
;
;       comm queue w/r pointers
;comm_rd         equ     0500h        ;address of the read pointer(16 bits)
;comm_wr         equ     0502h        ;address of the write pointer(16 bits)
;;
;;       fax/modem transfering queue w/r pointers
;faxt_rd         equ     0504h        ;address of the read pointer(16 bits)
;faxt_wr         equ     0506h        ;address of the write pointer(16 bits)
;;
;;       fax/modem receiving queue w/r pointers
;faxr_rd         equ     0508h        ;address of the read pointer(16 bits)
;faxr_wr         equ     050ah        ;address of the write pointer(16 bits)
;;        
;;       vt100 receiving queue w/r pointers
;rvt_rd          equ     050ch        ;address of the read pointer(16 bits)
;rvt_wr          equ     050eh        ;address of the write pointer(16 bits)
;;        
;;       vt100 transfering queue w/r pointers
;tvt_rd          equ     0510h        ;address of the read pointer(16 bits)
;tvt_wr          equ     0512h        ;address of the write pointer(16 bits)
;
;       initialization string of fax

initstr:  db    41h, 54h                ;'at'
	  db    51h, 30h                ;'q0'
	  db    45h, 31h                ;'e1'
	  db    56h, 31h                ;'v1'
	  db    53h, 30h, 3dh, 30h      ;'s0=0'
	  db    53h, 37h, 3dh, 31h, 35h ;'s7=15'
	  db    26h, 43h, 31h           ;'&c1'
	  db    cr, 0
;
;       settings of ring times
ringset:  db    41h, 54h                ;'at'
	  db    53h, 30h, 3dh, 0        ;'s0='
ringcnt:  db    cr, 0
;
;       command set
d3:       db  33h, 0                                            ;'3'
vdcrlf:   db  41h, 54h, 44h, 50h, 33h, cr, 0                ;'atdp3'
autoans:  db  41h, 54h, 41h, cr, 0                          ;'ata'
hookon:   db  41h, 54h, 48h, 30h, cr, 0                     ;'ath0'
escape:   db  2bh, 2bh, 2bh, 0                                  ;'+++'
hookoff:  db  41h, 54h, 48h, cr, 0                          ;'ath'
speakoff: db  41h, 54h, 4dh, 30h, 0dh,0                     ;'m0'
speakon:  db  41h, 54h, 4dh, 31h, 0dh,0                     ;'m1'
smallvoc: db  41h, 54h, 4ch, 31h, 0dh,0                     ;'l1'
;
;       result codes
ok:       db  4fh,4bh,0                                         ;'ok'
connect:  db  43h,4fh,4eh,4eh,45h,43h,54h,0                     ;'connect'
ring:     db  52h,49h,4eh,47h,0                                 ;'ring'
nocarier: db  4eh,4fh,20h,43h,41h,52h,52h,49h,45h,52h,0         ;'no carrier'
error:    db  45h,52h,52h,4fh,52h,0                             ;'error'
cn1200:   db  43h,4fh,4eh,4eh,45h,43h,54h,20h,31h,32h,30h,30h,0 ;'connect 1200'
nodtone:  db  4eh,4fh,20h,44h,49h,41h,4ch,54h,4fh,4eh,45h,0     ;'no dialtone'
busy:     db  42h,55h,53h,59h,0                                 ;'busy'
noanswer: db  4eh,4fh,20h,41h,4eh,53h,57h,45h,52h,0             ;'no answer'
cn2400:   db  43h,4fh,4eh,4eh,45h,43h,54h,20h,32h,34h,30h,30h,0 ;'connect 2400'
fxdata:   db  44h,41h,54h,41h,0                                 ;'data'
fax:      db  46h,41h,58h,0                                     ;'fax'
fcerr:    db  2bh,46h,43h,45h,52h,52h,4fh,52h,0                 ;'+fcerror'

                 PUBLIC  s_setup
                 $DEFFN  s_setup(0,0,0,0,0,0,0,0)
                 PUBLIC  faxrqclr
                 $DEFFN  faxrqclr(0,0,0,0,0,0,0,0)
                 PUBLIC  settime
                 $DEFFN  settime(0,0,0,0,0,0,0,0)
                 PUBLIC  gettime
                 $DEFFN  gettime(0,0,0,0,0,0,2,0)
                 PUBLIC  timeer
                 $DEFFN  timeer(0,0,0,0,0,0,0,0)
                 PUBLIC  s_rcvchar
                 $DEFFN  s_rcvchar(0,0,0,0,0,0,0,0)
                 PUBLIC  s_sendchar
                 $DEFFN  s_sendchar(0,0,0,0,0,0,2,0)
                 PUBLIC  sleep
                 $DEFFN  sleep(0,0,0,0,0,0,0,0)
                 PUBLIC  sent
                 $DEFFN  sent(0,0,0,0,0,0,0,0)
                 PUBLIC  disable
                 $DEFFN  disable(0,0,0,0,0,0,0,0)
                 PUBLIC  enable
                 $DEFFN  enable(0,0,0,0,0,0,0,0)
                 PUBLIC  enableint
                 $DEFFN  enableint(0,0,0,0,0,0,0,0)
                 PUBLIC  inp
                 $DEFFN  inp(0,0,0,0,0,0,2,0)
                 PUBLIC  outp
                 $DEFFN  outp(0,0,0,0,0,0,3,0)

                 EXTERN  ?CL8051L_4_05_L17
                 RSEG    CODE

; 61.	char inp (int portid)
; 62.	/*
; 63.	          功能          读端口
; 64.	*/
; 65.	{}
inp:
        push    p1
        push    dpl
        push    dph
        setb    p1.4
;
        mov     dph,r6
        mov     dpl,r7
        movx    a,@dptr
        mov     r7,a
        clr     a
        mov     r6,a
;
        pop    dph
        pop    dpl
        pop    p1
;
	RET
; 66.	
; 67.	
; 68.	void outp (int portid,char v)
; 69.	/*
; 70.	          功能          写端口
; 71.	*/
; 72.	{}
outp:
	MOV	DPTR,#$LOCBX outp
	MOV	A,R6
	MOVX	@DPTR,A
	INC	DPTR
	MOV	A,R7
	MOVX	@DPTR,A
        MOV     DPTR,#$LOCBX outp+2
        inc     dptr
        movx    a,@dptr
        mov     r5, a
;
        push    p1
        push    dpl
        push    dph
;
        setb    p1.4
        mov     dph,r6
        mov     dpl,r7
        mov     a,r5
        movx    @dptr,a
;
        pop    dph
        pop    dpl
        pop    p1
        RET
; 73.	
; 74.	
; 75.	void disable(void)     /* Clear interrupt flag */
; 76.	/*
; 77.             功能          关中断(键盘)
; 78.	*/
; 79.	{}
disable:
               clr    ex0

	RET
; 80.	
; 81.	
; 82.	void enable(void)      /* Set interrupt flag */
; 83.	/*
; 84.             功能          开中断(键盘)
; 85.	*/
; 86.	{}
enable:
        	setb    ex0             ; enable interrupt
		setb    ea

	RET

; 82.   void enableint(void)      /* Set interrupt flag */
; 83.	/*
; 84.             功能          开中断(键盘)
; 85.	*/
; 86.	{}
enableint:
               clr     ea
               setb    ex1                ; enable interrupt
               setb    px1

	RET

sent:           push    p1
		mov     r0, #02h
		lcall   delay
		mov     a, #41h
		lcall   wrtranqu
		mov     a, #54h
		lcall   wrtranqu
                mov     a,#44h
                lcall   wrtranqu
                mov     a, #54h                 ;'t'
                lcall   wrtranqu
                mov     a,#31h
                lcall   wrtranqu
                mov     a,#32h
                lcall   wrtranqu
                mov     a,#33h
                lcall   wrtranqu
                mov     a,#31h
                lcall   wrtranqu
                mov     a,#32h
                lcall   wrtranqu
                mov     a,#33h
                lcall   wrtranqu
                mov     a,#31h
                lcall   wrtranqu
                mov     a,#32h
                lcall   wrtranqu
                mov     a,#33h
                lcall   wrtranqu

        	mov     a, #0dh
		lcall   wrtranqu
;
                mov     r0, #02h
                lcall   delay
;
;                lcall   offline
                pop     p1

                ret

s_sendchar:     nop
                mov    a, r7
                lcall  wrtranqu
                ret
;############################################################################
;               entry:  wrtranqu          ;added aug.2,1995
;               function:  write a byte to fax/modem transfering queue
;               input:  a
;############################################################################
;
wrtranqu:       push    b
		push    p1
		push    dpl
		push    dph
                mov     p1, #lo_mem       ;;;;#hi_mem
;
;       get the lower byte of the write pointer
		push    acc
		mov     dptr, #faxt_wr
		movx    a, @dptr
		mov     b, a
		inc     a
		movx    @dptr, a
		pop     acc
;
;       compose the write pointer
		mov     dph, #faxt_ptr   ;base pointer (high byte) 
		mov     dpl, b
		movx    @dptr, a
;
;       enable interrupt for the empty request
                setb    p1.4
		mov     dptr, #r3f9
		movx    a, @dptr
		orl     a, #02h
		movx    @dptr, a
;               
		pop     dph
		pop     dpl
		pop     p1
		pop     b
		ret
;

s_setup:        push    p1

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -