-
- public as_init
-
- extrn ioiniml
- extrn f_cpu,add_hla,div32_r
- extrn @ctbl
-
- include config.inc
- include z180reg.inc
-
-
-;--------------------------------------------------------------
-; TC = (f PHI /(2*baudrate*Clock_mode)) - 2
-;
-; Clock_mode == 16
-; TC = (f PHI / (32 * baudrate)) - 2
-;
-; br150 = baudrate/150
-; TC = (f PHI / (32 * 150 * br150)) - 2
-; TC = (f PHI / (32 * 150 * br150)) - 2
-
-
-;--------------------------------------------------------------
-; Init Serial I/O for console input and output (ASCI1)
-;
-; b: device number (0..15)
-; c: asci channel number (0/1)
-
- dseg
-as_init:
- ld hl,initab0
- dec c
- jr nz,$+5
- ld hl,initab1
-
- push hl ;save initab addr
- ld c,8 ;
- mlt bc ;
- ld hl,@ctbl+7 ;get baudrate index
- add hl,bc ;
- ld a,(hl)
- and 0fh
- add a,a ;get factor
- ld hl,bd150_tab
- call add_hla
- ld c,(hl)
- inc hl
- ld b,(hl)
- ld hl,(f_cpu)
- ld de,(f_cpu+2)
- call div32_r
- ld bc,32*150
- call div32_r
- ld de,2
- or a
- sbc hl,de
- jr nc,as_ini_1
- ld hl,0
-as_ini_1:
- ld b,h
- ld c,l
- pop de ;get back initab addr
- ld hl,init_br_off
- add hl,de
- ld (hl),c
- inc hl
- ld (hl),b
- ex de,hl
- jp ioiniml
-
-
-bd150_tab:
-; factor index baudrate orig. cp/m
- dw 19200/150 ; 0 19200 -
- dw 28800/150 ; 1 28800 50
- dw 38400/150 ; 2 38400 75
- dw 57600/150 ; 3 57600 110
- dw 11520/15 ; 4 115200 134.5
- dw 150/150 ; 5 150
- dw 300/150 ; 6 300
- dw 600/150 ; 7 600
- dw 1200/150 ; 8 1200
- dw 1800/150 ; 9 1800
- dw 2400/150 ;10 2400
- dw 3600/150 ;11 3600
- dw 4800/150 ;12 4800
- dw 7200/150 ;13 7200
- dw 9600/150 ;14 9600
- dw 19200/150 ;15 19200
-
-
-
-
-initab0:
- db 1,stat0,0 ;Disable rx/tx interrupts
- ;Enable baud rate generator
- db 1,asext0,M_BRGMOD+M_DCD0DIS ; +M_CTS0DIS
- db 2,astc0l
-init_br_off equ $ - initab0
- dw 28
- db 1,cntlb0,M_MPBT ;No MP Mode, X16
- db 1,cntla0,M_RE+M_TE+M_MOD2 ;Rx/Tx enable, 8N1
- db 0
-
-initab1:
- db 1,stat1,0 ;Disable rx/tx ints, disable CTS1
- db 1,asext1,M_BRGMOD ;Enable baud rate generator
- db 2,astc1l,low 3, high 3
- db 1,cntlb1,M_MPBT ;No MP Mode, X16
- db 1,cntla1,M_RE+M_TE+M_MOD2 ;Rx/Tx enable, 8N1
- db 0
-
- end
+\r
+ public as_init\r
+\r
+ extrn ioiniml\r
+ extrn f_cpu,add_hla,div32_r\r
+ extrn @ctbl\r
+\r
+ maclib z180reg.inc\r
+ maclib config.inc\r
+\r
+\r
+;--------------------------------------------------------------\r
+; TC = (f PHI /(2*baudrate*Clock_mode)) - 2\r
+;\r
+; Clock_mode == 16\r
+; TC = (f PHI / (32 * baudrate)) - 2\r
+;\r
+; br150 = baudrate/150\r
+; TC = (f PHI / (32 * 150 * br150)) - 2\r
+; TC = (f PHI / (32 * 150 * br150)) - 2\r
+\r
+\r
+;--------------------------------------------------------------\r
+; Init Serial I/O for console input and output (ASCI1)\r
+;\r
+; b: device number (0..15)\r
+; c: asci channel number (0/1)\r
+\r
+ dseg\r
+as_init:\r
+ ld de,initab0\r
+ dec c\r
+ jr nz,$+5\r
+ ld de,initab1\r
+\r
+ ld c,8 ;\r
+ mlt bc ;\r
+ ld hl,@ctbl+7 ;get baudrate index\r
+ add hl,bc ;\r
+ ld a,(hl)\r
+ call as_br_div\r
+ ld b,h\r
+ ld c,l\r
+ ld hl,init_br_off\r
+ add hl,de\r
+ ld (hl),c\r
+ inc hl\r
+ ld (hl),b\r
+ ex de,hl\r
+ jp ioiniml\r
+\r
+\r
+as_br_div:\r
+ push de\r
+ push bc\r
+ and 0fh\r
+ add a,a ;get factor\r
+ ld hl,bd150_tab\r
+ call add_hla\r
+ ld c,(hl)\r
+ inc hl\r
+ ld b,(hl)\r
+ ld hl,(f_cpu)\r
+ ld de,(f_cpu+2)\r
+ call div32_r\r
+ ld bc,32*150\r
+ call div32_r\r
+ ld de,2\r
+ or a\r
+ sbc hl,de\r
+ pop bc\r
+ pop de\r
+ ret nc\r
+ ld hl,0\r
+ ret\r
+\r
+bd150_tab:\r
+; factor index baudrate orig. cp/m\r
+ dw 19200/150 ; 0 19200 -\r
+ dw 28800/150 ; 1 28800 50\r
+ dw 38400/150 ; 2 38400 75\r
+ dw 57600/150 ; 3 57600 110\r
+ dw 11520/15 ; 4 115200 134.5\r
+ dw 150/150 ; 5 150\r
+ dw 300/150 ; 6 300\r
+ dw 600/150 ; 7 600\r
+ dw 1200/150 ; 8 1200\r
+ dw 1800/150 ; 9 1800\r
+ dw 2400/150 ;10 2400\r
+ dw 3600/150 ;11 3600\r
+ dw 4800/150 ;12 4800\r
+ dw 7200/150 ;13 7200\r
+ dw 9600/150 ;14 9600\r
+ dw 19200/150 ;15 19200\r
+\r
+\r
+\r
+\r
+initab0:\r
+ db 1,stat0,0 ;Disable rx/tx interrupts\r
+ ;Enable baud rate generator\r
+ db 1,asext0,M_BRGMOD+M_DCD0DIS ; +M_CTS0DIS\r
+ db 2,astc0l\r
+init_br_off equ $ - initab0\r
+ dw 28\r
+ db 1,cntlb0,M_MPBT ;No MP Mode, X16\r
+ db 1,cntla0,M_RE+M_TE+M_MOD2 ;Rx/Tx enable, 8N1\r
+ db 0\r
+\r
+initab1:\r
+ db 1,stat1,0 ;Disable rx/tx ints, disable CTS1\r
+ db 1,asext1,M_BRGMOD ;Enable baud rate generator\r
+ db 2,astc1l,low 3, high 3\r
+ db 1,cntlb1,M_MPBT ;No MP Mode, X16\r
+ db 1,cntla1,M_RE+M_TE+M_MOD2 ;Rx/Tx enable, 8N1\r
+ db 0\r
+\r
+ end\r