20年前の機械制御紹介

## 20年も前の金型研磨機の記事です。![R0100004.JPG](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/378482/7d2ab435-2d8a-d500-31ba-24459f7292da.jpeg)
## Z80シリーズ東芝製CPU制御　ACサーボモーターを制御しています。
![jpg_us.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/378482/b9e98488-5517-799a-ac87-4eff979f0b2b.jpeg)
![LED状態.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/378482/0f0ee207-8394-0315-29f2-106d511a01ee.jpeg)
## 懐かしい資料です。
https://photos.app.goo.gl/qGNgiGsn5jHTsfZT8
## コントロールパネル部は当時としては最速のSX-CPU-50Mhzのセラロックで動いています。プログラムはオールAssemblerでした![SANY0008.JPG](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/378482/c8855ee3-2892-e9de-8442-057405290fd8.jpeg)

## その他の機械制御写真集
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/378482/d8bf200e-bf2f-04da-a45d-2848cfe64e8a.png)

## プログラム操作部です
```
;**************************************************************************
;Pg160  ;;;;;;;  add->BOR42 2001 9/22 9/28 end 10/5 17:33 ok-end 10/23 jp31
;_KR_panch	dw	'0300',0		;0.0005
;_KR_dai	dw	'0100',0
;_KR_doresu	dw	'0200',0
		ID	'pg160lcd'			;program ID label
		DEVICE	SX28L,OSCXTMAX,BOR42		;DRT18MS
		DEVICE	turbo,stackx_optionx
		FREQ	50000000
		RESET	reset_entry   		;set reset/boot address
;**************************** Program Variables ***************************
; Port Assignment: Bit variables
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
status_C	EQU	03h.0
status_DC	EQU	03h.1
status_Z	EQU	03h.2
;
scl		EQU	RA.0			;I2C clock
sda		EQU	RA.1			;I2C data I/O

rx_pin		EQU	ra.3			;UART receive input
tx_pin		EQU	ra.2			;UART transmit output
;
;
;led_pin		EQU	rb.0			;LED output
PRN_STR		EQU	rb.0			;input
IN_SW0C		EQU	rb.1			;SW COMON	    Output
;lcd_RW		EQU	rb.1			;RW	LCD control Output
lcd_RS		EQU	rb.2			;RS	LCD control Output
lcd_E		EQU	rb.3			;E(STB) LCD control Output

lcd_DB4		EQU	rb.4			;LCD DATA out
lcd_DB5		EQU	rb.5			;LCD DATA out
lcd_DB6		EQU	rb.6			;LCD DATA out
lcd_DB7		EQU	rb.7			;LCD DATA out

key0d		EQU	rc.0			;input
key1d		EQU	rc.1			;input
key2d		EQU	rc.2			;input
key3d		EQU	rc.3			;input
key0com		EQU	rc.4			;output
key1com		EQU	rc.5			;output
key2com		EQU	rc.6			;output
led_pin		EQU	rc.7			;output

		;Set RA in/out directions
ra_ini_data	=	%0111
ra_ini_in	=	%1010		;initialize port RA3&1	 >in
		;Set RB in/out directions
rb_ini_data	=	%00000011		;Set rb4567 = Pull-up enabled
rb_ini_Hin	=	%11110001		;Set RB Hi input set
rb_ini_Aout	=	%00000001		;Set RB in/out directions
rb_Pull_Hup	=	%00001110		;Set rb4567 = Pull-up enabled

rc_ini_data	=	%01111111		;Set start data
rc_ini_Hinp	=	%00001111		;Set RC 0-3 D input set
rc_Pull_Hup	=	%11110000		;Set RC 0-3 = Pull-up enabled

control_r	=	10100001b		;control byte: read E2PROM
control_w	=	10100000b		;control byte: write E2PROM
portsetup_r	=	00001010b		;Port A config: read bit
portsetup_w	=	00001000b		;Port A config: write bit
eeprom_size	=	128			;storage space of EEPROM
;
t_all		=	31			;bit cycle delay (62=5 usec)
;--------------------------------------------------------------------------

;****** Register definitions (bank 0)
;
		org	8			;start of program registers
main		=	$			;main bank
;
;
tmp	       ds      1		       ;temporary storage
byte		ds	1			;temporary UART/I2C shift reg.
flags		DS	1			;program flags register
number_low	ds	1			;low byte of rec'd value
number_high	ds	1			;high byte of rec'd value
hex		ds	1			;value of rec'd hex number
string		ds	1			;indirect ptr to output string
;
;
push_d		ds	1

rx_flag		EQU	flags.5			;signals when byte is received
seq_flag	EQU	flags.1			;I2C: R/W mode (if sequential=1)
got_ack		EQU	flags.2			;     if we got ack signal
rx_flag_T	EQU	flags.0
sw_flag		EQU	flags.3
ed_flag		EQU	flags.7

		org	10h
Cursor		ds	1	;Main		;どこかとぶつかる　　？
tmp1		ds	1	;Main		;どこかとぶつかる　　？
tmp2		ds	1
R_Mode		ds	1			;int DMX Rx Mode
tx_high		ds	1			;hi byte to transmit
tx_low		ds	1			;low byte to transmit
tx_count	ds	1			;number of bits sent
tx_divide	ds	1			;xmit timing (/16) counter
rx_count	ds	1			;number of bits received
rx_divide	ds	1			;receive timing counter
rx_byte		ds	1			;buffer for incoming byte

dpdt		ds	1		;4/29 どうもレジスタがぶつかる
cou0		ds	1		;kokoに以下を移したら直った
cou1		ds	1
cou2		ds	1
rx_data_cou	ds	1

		org	030h			;
RX1B		=	$			;

		org	0F0H			;bank4 variables
I2C		=	$			;I2C bank
SW1B		=	$			;
;
data		DS	1			;data byte from/for R/W
address		DS	1			;byte address
address_h	DS	1			;byte address  max1Fh=32page (LC64)
count		DS	1			;bit count for R/W
delay		DS	1			;timing delay for write cycle
byte_count	DS	1			;number of bytes in R/W
num_bytes	DS	1			;number of byte to view at once
save_addr	DS	1			;backup location for address

sw1dl		ds	1
push0		DS	1
push1		DS	1
push2		DS	1
push3		DS	1
push4		DS	1
OB_RUN		DS	1
ER_CUT		DS	1

in_bit		EQU	byte.0			;bit to receive on I2C
out_bit		EQU	byte.7			;bit to transmit on I2C

;------------------------------------------------------------------------
; *** 2400 baud (for slower baud rates, increase the RTCC prescaler)1023
baud_bit       =       7                       ;for 2400 baud
start_delay    =       128+64+1                ; "    "    "
int_period     =       163                    ; "    "    "
;
;------------------------------------------------------------------------
; *** 4800 baud
;baud_bit	=	6			;for 9600 baud
;start_delay	=	64+32+1			; "    "     "
;int_period	=	163			; "    "     "
;------------------------------------------------------------------------
; *** 9600 baud
;baud_bit	=	5			;for 9600 baud
;start_delay	=	32+16+1			; "    "     "
;int_period	=	164			; "    "     "
; *** 19200 baud
;baud_bit	=	4			;for 9600 baud
;start_delay	=	16+8+1			; "    "     "
;int_period	=	163			; "    "     "
;
;********* LCD Function
;bit8I1L7	=	%00110000	;Function set 8bits inc Lines=1 CH=7dots
bit44I1L7	=	%00100010	;Function set 4bits inc Lines=2 CH=10dots
bit4I2L10	=	%00101100	;Function set 4bits inc Lines=2 CH=10dots
_lcd_Cmov	=	%00011000	;Cursor bit3(0=mov/1=Disp shft)bit2(0=L/1=R)
_lcd_off	=	%00001000	;Display off Disp=Cursor=Blink=0
_lcd_on		=	%00001100	;Display off D=1 Cursor=0 Blink=0
_lcd_onC	=	%00001110	;Display off D=1 Cursor=1 Blink=0
_lcd_onCB	=	%00001111	;Display off D=1 Cursor=1 Blink=1
_lcd_onB	=	%00001101	;Display off D=1 Cursor=1 Blink=1
_lcd_inc1	=	%00000110	;Entry Inc/Dec=1 Shift=0
_lcd_inc1S	=	%00000111	;Entry Inc/Dec=1 Shift=1
M_Cursor	=	66
;---------------------------------------------------------------------------
;===========================================================================
;    TxMVcommand (1-7)               'SW
;    TxMVcommand (&H89)              'SLOW STOP
;    TxMVcommand (&H88)              'STOP
;    TxMVcommand (&H80 + Index) 'UP
;    TxMVcommand (&H90 + Index) 'DOWN
;    TxMVcommand (&HA0)              'ORIGINAL PRG
;    TxMVcommand (&HB0)              'USER PRG
;	_stop_all	=	0C0h    'ALL _OFF
;	_stop_up	=	0C8h	;'STOP_UP
;    TxMVcommand (&HD0)		    'KIDOU
;    TxMVcommand (&HE0)             'EDIT
;===========================================================================
;SUUTI_TOP:
;PP
;KAKOU_RYOU 	DS 	2 ;[A] 研削量　　　　回 0-60000(30mm)  	64(6400) = 100 /0.1
;KIRI_RYOU 	DS      2 ;[B] 切り込み量    回 0-1999(1mm)	01(0100) = 1 / 0.0005
;KIRI_KAI 	DS	2 ;[N] テーブル回転  回数 0-999		02(0200) = 2
;SP_OUT_KAI     DS      2 ;[C] スパークアウト回数 0-999		32(3200) = 50
;EARCUT_D       DS      2 ;[D] エア－カット  回数 0-1999(1mm)	C8(C800) = 100 /0.1
;OBERRUN_D      DS      2 ;[E] オーバーラン  回数 0-1999(1mm)	1FE(FE01)= 510 /0.51
;		NOP
;		NOP
;		NOP
;		NOP
;	org	RAMD + 0140H
;QQ
;STM_P_MM       DS      2 ;[S]定数　0.0005mm
;SOFT_UD_P 	DS	2 ;[E2]定数　177
;KAIHI_3M 	DS      2 ;[M3]定数　3mm/S=6000
;STOP1DATA	DS	2 ;-OBERRUN_D - EARCUT_D - KAIHI_3M + (SOFT_UD_P*2)
;DW3MM_DATA	DS	2 ;-OBERRUN_D - EARCUT_D
;KAKOU_END      DS	2 ;-OBERRUN_D + SOFT_UD_P + KAKOU_RYOU
;AP00E		DS	2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;TX_PIODATA: TT
;	;INA =LOW  1 12
;      	;INA  =HI   2 34
;       ;OUT B      3 56
;       ;CTC1COU    4 78
;       ;MODE       5 910
;       ;KIDOU_P    6
;       ;ERR_P      7
;===========================================================================
;	Locate 
;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,............................
;
_LOC_00		=	0+1
_LOC_01		=	1+1
;_LOC_07		=	7+1
;_LOC_012	=	12+1
_LOC_013	=	13+1
_LOC_10		=	63+1
_LOC_11		=	_LOC_10+1+1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;===========================================================================
		ORG	600H
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pr_kidou
;		page	pr_kidou_ss
;		jmp	pr_kidou_ss
pr_kidou_ss
		mov	w,#_tyuudan
		page	PR_string
		call	PR_string
		mov	w,#_osite
		page	PR_string
		call	PR_string
		retp
pr_kidou1
		page	lcd_clr
		call	lcd_clr		;clear display

		mov	w,#_kakouR
		page	PR_string
		call	PR_string

		mov	w,#_01
		page	PR_string
		call	PR_string

		mov	w,#_panch
		page	PR_string
		call	PR_string

;		mov	w,#_tyuudan
;		page	PR_string
;		call	PR_string
;		mov	w,#_tyu
;		page	PR_string
;		call	PR_string
		retp
pr_kidou2
		mov	w,#_Standbay		;send hello string
		page	PR_string
		call	PR_string
		retp

;***************************  SUBROUTINES  *********************************
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
TX_STOP_UP
		page	wait10ms
		call	wait10ms
		snb	key3d
		retp
		page	wait1ms
		call	wait1ms
		snb	key3d
		retp
TX_STOP_UP_G

		clrb	led_pin	

;		mov	w,#_Standbay
;		page	PR_string
;		call	PR_string

TX_STOP_UP_L
		
TX_STOP_UP_LL
		mov	w,#_tx_sw_s
		page	Tx_string
		call	Tx_string
		mov	w,#_stop_up
		page	Tx_string
		call	Tx_string

		page	wait100ms
		call	wait100ms
		page	wait100ms
		call	wait100ms

		mov	w,#_tx_sw_s
		page	Tx_string
		call	Tx_string
		mov	w,#_stop_up
		page	Tx_string
		call	Tx_string

		page	wait500ms
		call	wait500ms

		mov	w,#_tx_sw_s
		page	Tx_string
		call	Tx_string
		mov	w,#_stop_up
		page	Tx_string
		call	Tx_string

;		page	Rx_poke
;		call	Rx_poke
;
Rx_chk_ACK
;		bank	RX1B
;		mov	tmp,012h
;		bank	main
;		sub	tmp,#06h
;		test	tmp2
;		jz	TX_STOP_err
Rx_chk_ACK_e
;		page	Rx_chk_ACK
;		call	Rx_chk_ACK
;
;		page	wait500ms
;		call	wait500ms
;		page	Tx_data
;		jmp	Tx_data
		retp
TX_STOP_err
;		mov	w,#_err
;		page	PR_string
;		call	PR_string

;		page	wait500ms
;		call	wait500ms
;		mov	w,#_Standbay
;		page	PR_string
;		call	PR_string

		jmp	TX_STOP_UP_L
;----------------------------------------------------------------------------
;****************************************************************************
;***************************** SUBROUTINES *********************************
;-------------------------------------------------------------------------------
Data2Fram
		bank	I2C
		mov	address_h,#0
		mov	data,OB_RUN
		mov	address,#0
		CALL	I2C_write		;wipe EEPROM byte
		mov	data,ER_CUT
		inc	address
		CALL	I2C_write		;wipe EEPROM byte
		bank	main
		retp
;--------------------------------------
Fram2data
		bank	I2C
		mov	address,#0
		mov	address_h,#0
		CALL	I2C_read		;read EEPROM byte
		mov	OB_RUN,data

		inc	address
		CALL	I2C_read		;read EEPROM byte
		mov	tmp,data
		mov	ER_CUT,data
		bank	main
		retp
;--------------------------------------
;******************************** I2C Subroutines *****************************
;;
I2C_write	CALL	Set_address		;write address to slave
:page_mode	MOV	W,data			;get byte to be sent
		CALL	Write_byte		;Send data byte
		JB	seq_flag,:done		;is this a page write?
		CALL	Send_stop		;no, signal stop condition
:done		RETP				;leave and fix page bits
;
Set_address	CALL	Send_start		;send start bit
		MOV	W,#control_w		;get write control byte
		CALL	Write_byte		;Write it & use ack polling
		JNB	got_ack,Set_address	; until EEPROM ready
		MOV	W,address_h		;get EEPROM #High address
		CALL	Write_byte		; and send it
		MOV	W,address		;get EEPROM #Low address pointer
		CALL	Write_byte		; and send it
		RETP				;leave and fix page bits
;
Write_byte	MOV	byte,W			;store byte to send
		MOV	count,#8		;set up to write 8 bits
:next_bit	CALL	Write_bit		;write next bit
		RL	byte			;shift over to next bit
		DJNZ	count,:next_bit		;whole byte written yet?
		CALL	Read_bit		;yes, get acknowledge bit
		SETB	got_ack			;assume we got it
		SNB	in_bit			;did we get ack (low=yes)?
		CLRB	got_ack			;if not, flag it
;
; to use the LED as a 'no_ack' signal, the ':toggle_led' line in the interrupt
;  section must be commented out, and the next 3 instructions uncommented.
;		CLRB	led_pin			;default: LED off
;		SNB	in_bit			;did we get ack (low=yes)?
;		SETB	led_pin			; if not, flag it with LED
;
		RETP				;leave and fix page bits
;
Write_bit	MOVB	sda,out_bit		;put tx bit on data line
		MOV	!ra,#portsetup_w	;set Port A up to write
		JMP	:delay1			;100ns data setup delay
:delay1		JMP	:delay2			; (note: 250ns at low power)
:delay2		SETB	scl			;flip I2C clock to high
;		MOV	W,#t_high			;get write cycle timing*
		CALL	Bus_delay		;do delay while bus settles
		CLRB	scl			;return I2C clock low
		MOV	!ra,#portsetup_r	;set sda->input in case ack
;		MOV	W,#t_low		;get clock=low cycle timing*
		CALL	Bus_delay		;allow for clock=low cycle
		RETP				;leave and fix page bits
;
Send_start	SETB	sda			;pull data line high
		MOV	!ra,#portsetup_w	;setup I2C to write bit
		JMP	:delay1			;100ns data setup delay
:delay1		JMP	:delay2			; (note: 250ns at low power)
:delay2		SETB	scl			;pull I2C clock high
;		MOV	W,#t_su_sta		;get setup cycle timing*
		CALL	Bus_delay		;allow start setup time
:new		CLRB	sda			;data line goes high->low
;		MOV	W,#t_hd_sta		;get start hold cycle timing*
		CALL	Bus_delay		;allow start hold time
		CLRB	scl			;pull I2C clock low
;		MOV	W,#t_buf		;get bus=free cycle timing*
		CALL	Bus_delay		;pause before next function
		RETP				;leave and fix page bits
;
Send_stop	CLRB	sda			;pull data line low
		MOV	!ra,#portsetup_w	;setup I2C to write bit
		JMP	:delay1			;100ns data setup delay
:delay1		JMP	:delay2			; (note: 250ns at low power)
:delay2		SETB	scl			;pull I2C clock high
;		MOV	W,#t_su_sto		;get setup cycle timing*
		CALL	Bus_delay		;allow stop setup time
		SETB	sda			;data line goes low->high
;		MOV	W,#t_low		;get stop cycle timing*
		CALL	Bus_delay		;allow start/stop hold time
		RETP				;leave and fix page bits
;
Bus_delay	MOV	W,#t_all		;get timing for delay loop
:custom		MOV	tmp,W			;save it
:loop		DJNZ	tmp,:loop		;do delay
		RETP				;leave and fix page bits
;
;****** Subroutine(s) : Read from I2C EEPROM
;
I2C_read	bank	I2C
		CALL	Set_address		;write address to slave
:current	CALL	Send_start		;signal start of read
		MOV	W,#control_r		; get read control byte
		CALL	Write_byte		; and send it
:sequential	MOV	count,#8		;set up for 8 bits
		CLR	byte			;zero result holder
:next_bit	RL	byte			;shift result for next bit
		CALL	Read_bit		;get next bit
		DJNZ	count,:next_bit		;got whole byte yet?
		MOV	data,byte		;yes, store what was read
		SB	seq_flag		;is this a sequential read?
:non_seq	JMP	Send_stop		; no, signal stop & exit
		CLRB	out_bit			; yes, setup acknowledge bit
		CALL	Write_bit		;   and send it
		RETP				;leave and fix page bits
;
Read_bit	CLRB	in_bit			;assume input bit low
		MOV	!ra,#portsetup_r	;set Port A up to read
		SETB	scl			;flip I2C clock to high
;		MOV	W,#t_high		;get read cycle timing*
		CALL	Bus_delay		;Go do delay
		SNB	sda			;is data line high?
		SETB	in_bit			;yes, switch input bit high
		CLRB	scl			;return I2C clock low
;		MOV	W,#t_buf		;get bus=free cycle timing*
		CALL	Bus_delay		;Go do delay
		RETP				;leave and fix page bits
;
; *****	High level functions: Store byte & Erase
;
Store_W		BANK	I2C			;switch to EEPROM bank
		MOV	data,W			;save incoming value
		CALL	I2C_Write		;store it in EEPROM
		INC	address			;move to next address
		INC	byte_count		;adjust # bytes stored
		MOV	W,eeprom_size		;get memory size
		MOV	W,address-W		;are we past end?
		SNZ				;if not, skip ahead
		CLR	address			;if so, reset it
:done		RETP				;leave and fix page bits
;
Erase_Mem	CLR	address			;restore address pointer
		MOV	num_bytes,#eeprom_size	;wipe whole mem
:wipeloop	CLR	data			;byte to wipe with=0
;		MOV	data,address		;byte to wipe with=addr
		CALL	I2C_write		;wipe EEPROM byte
		INC	address			;move to next address
		DJNZ	num_bytes,:wipeloop	;Erased enough yet?
		CLR	byte_count		;done, reset stored count
		CLR	save_addr		;reset backup address
		RETP				;leave and fix page bits

;************************************************************************************
;-----------------------------------------------------------------------
start_init
;********************** CGRAM *************************
;
		page	Fram2data
		call	Fram2data

		bank	main
		page	pr_kidou
		call	pr_kidou
		mov	!option,#%10011000	;enable rtcc interrupt
;
		mov	w,#_tx_sw_s
		page	Tx_string
		call	Tx_string
;
		mov	w,#_stop_all
		page	Tx_string
		call	Tx_string
;
		page	wait500ms
		call	wait500ms
;
		mov	w,#_tx_sw_s
		page	Tx_string
		call	Tx_string
;
		mov	w,#_stop_all
		page	Tx_string
		call	Tx_string
;
;		page	Rx_chk_T
;		call	Rx_chk_T
;
;		page	Rx_poke
;		call	Rx_poke

		clr	R_Mode

		clrb	key2com
		nop
		nop
		nop
		nop
		nop
		nop

		page	main_ret0
		jmp	main_ret0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;************************************************************************************
;************************************************************************************
;************************************************************************************
		ORG	0400H
;************************************************************************************
Tx_data
		jmp	Tx_data_sub
Rx_Chk_S
		jmp	Rx_Chk_Sub
Rx_Bff_clr
		jmp	Rx_Bff_clr_S
;************************************************************************************
kakouryou
		mov	tmp,R_Mode
		and	tmp,#03h
		mov	w,tmp
		jmp	pc+w
		jmp	kakou01
		jmp	kakou02
		jmp	kakou03
		jmp	kakou01
R_mode_sel
		mov	tmp,R_Mode
		swap	tmp
		and	tmp,#03h
		mov	w,tmp
		jmp	pc+w
		jmp	Panch_D
		jmp	dai_D
		jmp	doresu_D
		jmp	Panch_D
;************************************************************************************
HEX2MAX99
		bank	main
		mov	cou1,tmp
		sub	cou1,#100
		jnc	HEX2MAX991
		mov	tmp,#99
HEX2MAX991
		page	HEX2BCD
		call	HEX2BCD
		test	dpdt
		snb	status_Z
		retp
		mov	tmp1,#99H
		retp
HEX2BCD
		mov	tmp1,tmp
		clr	cou1
B2D1
		sub	tmp1,#100
		inc	cou1
		snb	status_C
		jmp	B2D1
		dec	cou1
		add	tmp1,#100
		clr	cou0
B2D2
		sub	tmp1,#10
		inc	cou0
		snb	status_C
		jmp	B2D2
		dec	cou0
		add	tmp1,#10
		rl	cou0
		rl	cou0
		rl	cou0
		rl	cou0
		and	cou0,#0f0h
		or	tmp1,cou0
		mov	dpdt,cou1
		retp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;----------------------------------------------------------------------
Hex2lcd
;		mov	tmp1,w
		mov	dpdt,tmp1
		swap	dpdt
		call	cnv0asc
		call	lcd_data
		mov	dpdt,tmp1
		call	cnv0asc
		call	lcd_data
		retp
cnv0asc		and	dpdt,#0Fh
		mov	w,dpdt
		jmp	pc+w
		retw	'0'
		retw	'1'
		retw	'2'
		retw	'3'
		retw	'4'
		retw	'5'
		retw	'6'
		retw	'7'
		retw	'8'
		retw	'9'
		retw	'A'
		retw	'B'
		retw	'C'
		retw	'D'
		retw	'E'
		retw	'F'
		retp
cnv1asc		and	dpdt,#0Fh
		mov	w,dpdt
		jmp	pc+w
		jmp	cnv1asc_s
		retw	01h	;1
		retw	01h	;2
		retw	02h	;3
		retw	02h	;4
		retw	03h	;5
		retw	03h	;6
		retw	04h	;7
		retw	04h	;8
		retw	05h	;9
		retw	05h	;A
		retw	06h	;B
		retw	06h	;C
		retw	07h	;D
		retw	07h	;E
		retw	046h	;F
cnv1asc_s
		mov	dpdt,tmp1
		and	dpdt,#0Fh
		mov	w,#2
		mov	w,dpdt-w
		snb	status_C
		retw	00h
		retw	10h
;***************************************************
;	LCD control routines
;***************************************************
lcd_off_Cursor
		mov	w,#_lcd_on	;Display on  D/C/B set
		call	lcd_cmd
		retp
;****  LCD CGram address set xxxxxxx
CGRAM_Wd	mov	tmp,w
		or	tmp,#%01000000
		mov	w,tmp		;Entry I/D & S
		call	lcd_cmd
		mov	w,Cursor
;****  LCD Data Write  ****
lcd_data
		mov	tmp,w
		mov	dpdt,tmp
		and	dpdt,#%11110000	;mask lower
		mov	rb,dpdt
		page	wait1us		;dl-----
		call	wait1us		;
		setb	lcd_RS		;Hi
		page	wait1us		;dl-----
		call	wait1us		;
		setb	lcd_E		;Hi
		page	wait1us		;dl-----
		call	wait1us		;
		clrb	lcd_E		;Low
		page	wait1us		;dl-----
		call	wait1us		;
		mov	dpdt,tmp	;get data lowe
		swap	dpdt
		and	dpdt,#%11110000	;mask lower
		mov	rb,dpdt
		setb	lcd_RS		;Hi		;RSがrbの時必要
		page	wait1us		;dl-----
		call	wait1us		;
		setb	lcd_E		;Hi
		page	wait1us		;dl-----
		call	wait1us		;
		clrb	lcd_E		;Low
		call	lcd_busy
		retp
;****  LCD command out	*****
lcd_cmd
		mov	tmp,w
		mov	dpdt,tmp
		and	dpdt,#%11110000	;mask lower
		mov	rb,dpdt
		page	wait1us		;dl-----
		call	wait1us		;
		clrb	lcd_RS		;RS low
		page	wait1us		;dl-----
		call	wait1us		;
		setb	lcd_E		;E  Hi
		page	wait1us		;dl-----
		call	wait1us		;
		clrb	lcd_E		;E  Low
		mov	dpdt,tmp	;get data lowe
		swap	dpdt
		and	dpdt,#%11110000	;mask lower
		mov	rb,dpdt
		page	wait1us		;dl-----
		call	wait1us		;
		setb	lcd_E		;Hi
		page	wait1us		;dl-----
		call	wait1us		;
		clrb	lcd_E		;Low
		call	lcd_busy
		retp
;****  LCD CGram address set xxxxxxx
CGRAM_add	mov	tmp,w
		or	tmp,#%01000000
		mov	w,tmp		;Entry I/D & S
		call	lcd_cmd
		retp
;****  LCD DDram address set xxxxxxx
lcd_locat	mov	tmp,w
		or	tmp,#%10000000
		mov	w,tmp		;Entry I/D & S
		call	lcd_cmd
		retp
;****  LCD Display Clear **** 1.64ms
lcd_clr
		mov	w,#01h		;clear command
		call	lcd_cmd
		page	wait10ms
		call	wait10ms
		retp
;****  LCD Display home **** 1.64ms
lcd_home
		mov	w,#02h		;home command 1.64ms
		call	lcd_cmd
		page	wait10ms
		call	wait10ms
		retp
;		mov	w,#04h		;clear command
;bit0  if    Sift==1 then	with display shift
;bit1  if inc/sec==1 then	inc	else dec
;bit3  if     S/C==1 then	with display shift else Cursor movement

;****  LCD Busy Check  ************
lcd_busy
		page	wait50us
		call	wait50us
		retp
;****  Initialize  ***** busy state ts 10ms after Vdd reach to 4.5V
lcd_ini
		page	wait100ms
		call	wait100ms

		mov	rb,#bit44I1L7	;Function set 4bits mode
		page	wait1ms		;dl-----
		call	wait1ms		;
		clrb	lcd_RS		;Low !!!!!!!! RS low
		page	wait1ms		;dl-----
		call	wait1ms		;
		setb	lcd_E		;Hi
		page	wait1ms		;dl-----
		call	wait1ms		;
		clrb	lcd_E		;Low
;
		page	wait10ms
		call	wait10ms
;
		mov	w,#bit4I2L10	;function DL=0 4bit mode
		call	lcd_cmd
		page	wait10ms		;dl-----
		call	wait10ms		;
		mov	w,#_lcd_Cmov	;Cursor bit3(0=mov)bit2(1=R)
		call	lcd_cmd
		page	wait10ms		;dl-----
		call	wait10ms		;
		mov	w,#_lcd_onC	;Display on  D/C/B set
		call	lcd_cmd
		page	wait10ms		;dl-----
		call	wait10ms		;
		mov	w,#_lcd_inc1	;Entry I/D & S
		call	lcd_cmd
;
;		page	wait10ms
		call	wait10ms
		call	lcd_off_Cursor
		page	wait10ms
		call	wait10ms
		page	lcd_clr
		call	lcd_clr		;clear display
		page	wait10ms
		call	wait10ms
;		page	lcd_home
;		call	lcd_home

		retp
;************************************************************************
kakou01
		mov	w,#_01
		page	PR_string
		call	PR_string

		mov	w,#_kakou01
		page	Tx_string
		call	Tx_string
		retp
kakou02
		mov	w,#_02
		page	PR_string
		call	PR_string

		mov	w,#_kakou02
		page	Tx_string
		call	Tx_string
		retp
kakou03
		mov	w,#_03
		page	PR_string
		call	PR_string

		mov	w,#_kakou03
		page	Tx_string
		call	Tx_string
		retp
Panch_D
		mov	w,#_panch
		page	PR_string
		call	PR_string

		mov	w,#_KR_panch
		page	Tx_string
		call	Tx_string
		mov	w,#_KK_panch
		page	Tx_string
		call	Tx_string
		mov	w,#_SP_panch
		page	Tx_string
		call	Tx_string
		retp
dai_D
		mov	w,#_dai
		page	PR_string
		call	PR_string

		mov	w,#_KR_dai
		page	Tx_string
		call	Tx_string
		mov	w,#_KK_dai
		page	Tx_string
		call	Tx_string
		mov	w,#_SP_dai
		page	Tx_string
		call	Tx_string
		retp
doresu_D
		mov	w,#_doresu
		page	PR_string
		call	PR_string

		mov	w,#_KR_doresu
		page	Tx_string
		call	Tx_string
		mov	w,#_KK_doresu
		page	Tx_string
		call	Tx_string
		mov	w,#_SP_doresu
		page	Tx_string
		call	Tx_string
		retp
;*************************************************************************1023
Tx_data_sub

		mov	w,#_Standbay
		page	PR_string
		call	PR_string
Tx_data_subL
		clr	rx_data_cou

		mov	w,#_kakouR
		page	PR_string
		call	PR_string

		mov	w,#_tx1data
		page	Tx_string
		call	Tx_string

		call	kakouryou

		call	R_mode_sel
;;;;;;;;;;;;;;;;;;;;;
		bank	I2C
		mov	tmp,ER_CUT
		bank	main
		mov	dpdt,tmp
		page	cnv0asc
		call	cnv0asc
		page	send_byte
		call	send_byte		;not 0, so send character

		mov	w,#'0'
		page	send_byte
		call	send_byte		;not 0, so send character

		mov	w,#'0'
		page	send_byte
		call	send_byte		;not 0, so send character

		bank	I2C
		mov	tmp,ER_CUT
		bank	main
		swap	tmp
		mov	dpdt,tmp
		page	cnv0asc
		call	cnv0asc
		page	send_byte
		call	send_byte		;not 0, so send character

;;;;;;;;;;;;;;;
		bank	I2C
		mov	tmp,OB_RUN
		bank	main
		mov	dpdt,tmp
		page	cnv0asc
		call	cnv0asc
		page	send_byte
		call	send_byte		;not 0, so send character

		mov	w,#'0'
		page	send_byte
		call	send_byte		;not 0, so send character

		mov	w,#'0'
		page	send_byte
		call	send_byte		;not 0, so send character

		bank	I2C
		mov	tmp,OB_RUN
		bank	main
		swap	tmp
		mov	dpdt,tmp
		page	cnv0asc
		call	cnv0asc
		page	send_byte
		call	send_byte		;not 0, so send character

		mov	w,#_tx2data
		page	Tx_string
		call	Tx_string

		call	Rx_Bff_clr

		call	Rx_Chk_S

		test	tmp
		jnz	Tx_data_sub_RT
;		page	wait500ms
;		call	wait500ms
		retp
Tx_data_sub_RT
		page	wait100ms
		call	wait100ms
;		page	wait100ms
;		call	wait100ms
;		page	wait100ms
;		call	wait100ms
		jmp	Tx_data_subL
;---------------------------------------------------------------
Rx_Chk_Sub
;---------------------------------------------------------------
		page	Rx_poke
		call	Rx_poke
;---------------------------------------------------------------
		mov	rx_data_cou,#2
:rx_cmp_lp
		snb	rx_data_cou.4
		jmp	:add_2
:add_1
		mov	tmp,rx_data_cou
		add	tmp,#030h
		jmp	:add_4
:add_2
		mov	tmp,rx_data_cou
		add	tmp,#040h
:add_4
		mov	w,tmp
		mov	FSR,w
		mov	w,INDIRECT
		mov	byte,w
		bank	main
		add	tmp,#080h
		mov	w,tmp
		mov	FSR,w
		mov	w,INDIRECT
		mov	tmp,w
		bank	main

		sub	tmp,byte
		test	tmp
		jnz	Tx_data_err
		inc	rx_data_cou
		mov	tmp,rx_data_cou

		sub	tmp,#1Bh
		jnz	:rx_cmp_lp
		mov	w,#_ok
		page	PR_string
		call	PR_string
;		page	wait100ms
;		call	wait100ms
		clr	tmp
		retp
Tx_data_err
		mov	w,#_err
		page	PR_string
		call	PR_string
		mov	tmp,#1
		retp

;......................................1023
Rx_Bff_clr_S
		mov	tmp1,#030h
Rx_Bff_clr_1L
		mov	w,tmp1
		mov	FSR,w
		mov	w,#0FFh
		mov	INDIRECT,w
		bank	main
		inc	tmp1
		mov	tmp,tmp1
		sub	tmp,#040h
		jnz	Rx_Bff_clr_1L

		mov	tmp1,#050h
Rx_Bff_clr_2L
		mov	w,tmp1
		mov	FSR,w
		mov	w,#0FFh
		mov	INDIRECT,w
		bank	main
		inc	tmp1
		mov	tmp,tmp1
		sub	tmp,#060h
		jnz	Rx_Bff_clr_2L
Rx_Bff_clr_E
		retp
;************************************************************************************
		org	200h
;************************************************************************************
interrupt
		bank	main		       ;switch to serial register bank

:transmit	clrb	tx_divide.baud_bit	;clear xmit timing count flag
		inc	tx_divide		;only execute the transmit routine
		STZ				;set zero flag for test
		SNB	tx_divide.baud_bit	; every 2^baud_bit interrupt
		test	tx_count		;are we sending?
		JZ	:receive		;if not, go to :receive
		clc				;yes, ready stop bit
		rr	tx_high			; and shift to next bit
		rr	tx_low			;
		dec	tx_count		;decrement bit counter
		movb	tx_pin,/tx_low.6	;output next bit
;
:receive	movb	c,rx_pin		;get current rx bit
		test	rx_count		;currently receiving byte?
		jnz	:rxbit			;if so, jump ahead
		mov	w,#9			;in case start, ready 9 bits
		sc				;skip ahead if not start bit
		mov	rx_count,w		;it is, so renew bit count
		mov	rx_divide,#start_delay	;ready 1.5 bit periods
:rxbit		djnz	rx_divide,:rxdone	;middle of next bit?
		setb	rx_divide.baud_bit	;yes, ready 1 bit period
		dec	rx_count		;last bit?
		sz				;if not
		rr	rx_byte			;  then save bit
		snz				;if so
		setb	rx_flag			;  then set flag
:rxdone
;
		mov	w,#-int_period		;interrupt every 'int_period' clocks
:end_int	retiw				;exit interrupt
;
;******	End of interrupt sequence
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Subroutine - Get byte via serial port
;
get_byte	jnb	rx_flag,$		;wait till byte is received
		clrb	rx_flag			;reset the receive flag
		mov	byte,rx_byte		;store byte (copy using W)
						; & fall through to echo char back
;
; Subroutine - Send byte via serial port
;
send_byte
		bank	main		       ;switch to serial register bank
		mov	byte,w
		mov	tmp,rx_data_cou
		swap	tmp
		and	tmp,#01h
		mov	w,tmp
		jmp	pc+w
		jmp	:add_B0
		jmp	:add_D0
:add_B0
		mov	tmp,rx_data_cou
		add	tmp,#0B0h
		jmp	:add2end
:add_D0
		mov	tmp,rx_data_cou
		add	tmp,#0C0h
:add2end
		mov	w,tmp
		mov	FSR,w
		mov     w,byte
		mov	INDIRECT,w

		bank	main
		inc	rx_data_cou
		and	rx_data_cou,#1Fh

;		page	wait1ms
;		call	wait1ms

		mov	w,byte
:wait		test	tx_count		;wait for not busy
		jnz	:wait			;

		not	w			;ready bits (inverse logic)
		mov	tx_high,w		; store data byte
		setb	tx_low.7		; set up start bit
;		mov	tx_count,#20		;1 start + 8 data + 1 stop bit
		mov	tx_count,#20		;1 start + 8 data + 1 stop bit
		RETP				;leave and fix page bits
;-------------------------------------------------------------------------------
wait500ms
		call	wait100ms
		call	wait100ms
		call	wait100ms
		call	wait100ms
		call	wait100ms
		retp
wate
wait100ms	mov	cou2,#100
wait100msl	call	wait1ms
		decsz	cou2
		jmp	wait100msl
		retp
wait10ms	mov	cou2,#10
wait10msl	call	wait1ms
		decsz	cou2
		jmp	wait10msl
		retp
wait1ms		mov	cou1,#100
wait1msl	call	wait10us
		decsz	cou1
		jmp	wait1msl
		retp
wait100us	mov	cou1,#10
wait100usl	call	wait10us
		decsz	cou1
		jmp	wait100usl
		retp
wait50us	mov	cou1,#5
wait50usl	call	wait10us
		decsz	cou1
		jmp	wait50usl
		retp
wait10us	mov	cou0,#109	;50MHz
wait10usl	decsz	cou0
		jmp	wait10usl
		retP
wait1us		mov	cou0,#10	;50MHz
wait1usl	decsz	cou0
		jmp	wait1usl
		retP

;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TX_KIDOU

		setb	led_pin	
		mov	w,#_tx_sw_s
		page	Tx_string
		call	Tx_string

		mov	w,#_KIDOU
		page	Tx_string
		call	Tx_string

;		page	Rx_poke
;		call	Rx_poke
;
;		page	Rx_poke
;		call	Rx_poke
;
;		page	Rx_Chk_S
;		call	Rx_Chk_S
;
;		test	tmp
;		jnz	TX_KIDOU_ERR

		retp
TX_KIDOU_ERR
		page	wait500ms
		call	wait500ms
		page	TX_STOP_UP_G
		jmp	TX_STOP_UP_G
	
;-------------------------------------------------------------------------------
Rx_data_chk
		clrb	rx_flag			;reset the receive flag
;		clr	rx_data_cou
;		clr	rx_count		;currently receiving byte?
get_byte_L
		mov	tmp2,#50
get1byte_L
		clr	cou1
get2byte_L
		clr	cou0
rx_wate_L
		jb	rx_flag,rx_wate_LE
		decsz	cou0
		jmp	rx_wate_L
		decsz	cou1
		jmp	get2byte_L
		decsz	tmp2
		jmp	get1byte_L
		retp
rx_wate_LE
		mov	byte,rx_byte		;store byte (copy using W)
rx_data_poke
		mov	tmp,rx_data_cou
;		sub	tmp,#025
;		snb	status_C
;		retp
		mov	tmp,rx_data_cou
		swap	tmp
		and	tmp,#03h
		mov	w,tmp
		jmp	pc+w
		jmp	:add_30
		jmp	:add_50
		jmp	:add_70
		jmp	:add_90
:add_30
		mov	tmp,rx_data_cou
		add	tmp,#030h
		jmp	:add_end
:add_50
		mov	tmp,rx_data_cou
		add	tmp,#040h
		jmp	:add_end
:add_70
		mov	tmp,rx_data_cou
		add	tmp,#050h
		jmp	:add_end
:add_90
		mov	tmp,rx_data_cou
		add	tmp,#060h
:add_end
		mov	w,tmp
		mov	FSR,w
		mov	w,byte
		mov	INDIRECT,w
;
		bank	main
		inc	rx_data_cou
		and	rx_data_cou,#3Fh
;
		mov	tmp,byte		;store byte (copy using W)
		retp
;---------------------------------------------------
Rx_poke
		clr	rx_data_cou
		clr	rx_count		;currently receiving byte?
Rx_poke_L
		call	Rx_data_chk

		test	tmp2
		snz
		retp
		sub	tmp,#0Dh
		sb	status_Z
		jmp	Rx_poke_L
		test	rx_data_cou
		snz
		retp
		clr	rx_data_cou
		retp
Rx_chk_CR
		call	Rx_data_chk
		test	tmp2
		snz
		retp
		sub	tmp,#0Dh
		sb	status_Z
		jmp	Rx_chk_CR
		retp
Rx_chk_T
		clrb	rx_flag_T
		clrb	rx_flag			;reset the receive flag
		mov	tmp2,#25
		call	get1byte_L
		test	tmp2
		snz
		retp	;store byte (copy using W)
		sub	tmp,#'T'
		sb	status_Z
		jmp	Rx_chk_T
		setb	rx_flag_T
		retp
Rx_chk_TT
		clrb	rx_flag_T
		clrb	rx_flag			;reset the receive flag
		mov	tmp2,#2
		call	get1byte_L
		test	tmp2
		snz
		retp	;store byte (copy using W)
		sub	tmp,#'T'
		sb	status_Z
		jmp	Rx_chk_TT
		setb	rx_flag_T
		retp
;------------------------------------------------------------------------------------
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:
;		org	300h
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:
;-------------------------------------------------------------------------------
main_sub
		clrb	key2com
		mov	w,tmp
		setb	key1com
		mov	w,tmp
		setb	key0com
		mov	w,tmp
:loop3
		snb	key2d
		jmp	:loop4
		page	wait10ms
		call	wait10ms

		snb	key2d
		jmp	:loop4
		snb	sw_flag
		jmp	:loop41

		mov	w,#_tx_sw_s
		page	Tx_string
		call	Tx_string

		mov	w,#_pnp_sw
		page	Tx_string
		call	Tx_string

		setb	sw_flag
		page	loop_c1
		jmp	loop_c1
:loop4
		clrb	sw_flag
:loop41

		snb	key3d
		jmp	:loop5

		snb	ed_flag
		jmp	:main_sub_E

		page	TX_STOP_UP
		call	TX_STOP_UP

:loop5
		snb	key1d
		jmp	:loop51
		page	wait10ms
		call	wait10ms
		snb	key1d
		jmp	:loop51
;		page	wait1ms
;		call	wait1ms
;		jmp	:loop51
;		retp

		snb	ed_flag
		jmp	:main_sub_E
;....................................................10/23
;		page	Tx_data
;		call	Tx_data
		page	wait100ms
		call	wait100ms
		page	TX_KIDOU
		call	TX_KIDOU
		page	wait100ms
		call	wait100ms
		page	wait100ms
		call	wait100ms
		page	TX_KIDOU
		call	TX_KIDOU
:loop51
		snb	key0d
		jmp	:loop6
		page	wait10ms
		call	wait10ms

;		snb	key1d
;		jmp	:loop6

		bank	SW1B
		inc	sw1dl
		mov	tmp,sw1dl
		bank	main
		test	tmp
		sz	
		jmp	:main_sub_E

		snb	ed_flag
		jmp	:loop52

		setb	ed_flag
		mov	w,#64+15
		page	lcd_locat
		call	lcd_locat
		mov	w,#'*'
		page	lcd_data
		call	lcd_data

		page	Fram2data
		call	Fram2data

		page	pr_obr
		jmp	pr_obr
:loop52
		clrb	ed_flag
		mov	w,#64+15
		page	lcd_locat
		call	lcd_locat
		mov	w,#' '
		page	lcd_data
		call	lcd_data
		page	Data2Fram
		call	Data2Fram

		page	Tx_data
		call	Tx_data

		mov	w,#_Standbay		;send hello string
		page	PR_string
		call	PR_string


:loop53
		page	wait100ms
		call	wait100ms
:loop6
		setb	key2com
		mov	w,tmp
		setb	key1com
		mov	w,tmp
		clrb	key0com
		mov	w,tmp

		snb	key2d
		jmp	:loop7

		page	wait10ms
		call	wait10ms

		snb	key2d
		jmp	:loop7

		snb	ed_flag
		jmp	:up_obr
		snb	led_pin	;;;;;;;;;;;;;;;;;;
		jmp	:loop7

;					,#_dai
		setb	R_Mode.4
		clrb	R_Mode.5
		page	Tx_data
		call	Tx_data
		page	loop_c1
		jmp	loop_c1
:loop7
		snb	key3d
		jmp	:loop8

		page	wait10ms
		call	wait10ms

		snb	key3d
		jmp	:loop8


		snb	ed_flag
		jmp	:up_ec
		snb	led_pin	;;;;;;;;;;;;;;;;;;
		jmp	:loop8
;					,#_doresu
		clrb	R_Mode.4
		setb	R_Mode.5
		page	Tx_data
		call	Tx_data

		page	loop_c1
		jmp	loop_c1
:loop8
		snb	key1d
		jmp	:loop81

		page	wait10ms
		call	wait10ms

		snb	key1d
		jmp	:loop81


		snb	ed_flag
		jmp	:main_sub_E
;					,#_panch
		snb	led_pin	;;;;;;;;;;;;;;;;;;
		jmp	:loop81
		clrb	R_Mode.4
		clrb	R_Mode.5
		page	Tx_data
		call	Tx_data

		page	loop_c1
		jmp	loop_c1
:loop81
		snb	key0d
		jmp	:loop9
		page	wait10ms
		call	wait10ms
		snb	key0d
		jmp	:loop9

		sb	ed_flag
		jmp	:main_sub_E
;					,up
		mov	w,#_tx_sw_s
		page	Tx_string
		call	Tx_string

		mov	w,#_up
		page	Tx_string
		call	Tx_string

		page	loop_c0
		jmp	loop_c0
:loop9
		setb	key2com
		mov	w,tmp
		clrb	key1com
		mov	w,tmp
		setb	key0com
		mov	w,tmp

		snb	key1d
		jmp	:loop10

		page	wait10ms
		call	wait10ms

		snb	key1d
		jmp	:loop10



		snb	ed_flag
		jmp	:main_sub_E
;					,#_01
		snb	led_pin	;;;;;;;;;;;;;;;;;;
		jmp	:loop10
		clrb	R_Mode.1
		clrb	R_Mode.0
		page	Tx_data
		call	Tx_data
		page	loop_c1
		jmp	loop_c1
:loop10
		snb	key2d
		jmp	:loop11

		page	wait10ms
		call	wait10ms

		snb	key2d
		jmp	:loop11

		snb	ed_flag
		jmp	:dw_obr
;					,#_02
		snb	led_pin	;;;;;;;;;;;;;;;;;;
		jmp	:loop11
		clrb	R_Mode.1
		setb	R_Mode.0
		page	Tx_data
		call	Tx_data
		page	loop_c1
		jmp	loop_c1
:loop11
		snb	key3d
		jmp	:loop12

		page	wait10ms
		call	wait10ms

		snb	key3d
		jmp	:loop12

		snb	ed_flag
		jmp	:dw_ec
;					,#_03
		snb	led_pin	;;;;;;;;;;;;;;;;;;
		jmp	:loop12

		clrb	R_Mode.0
		setb	R_Mode.1
		page	Tx_data
		call	Tx_data
		page	loop_c1
		jmp	loop_c1
:loop12
		snb	key0d
		jmp	:loop13

		page	wait10ms
		call	wait10ms

		snb	key0d
		jmp	:loop13

		sb	ed_flag
		jmp	:main_sub_E
;					down
		mov	w,#_tx_sw_s
		page	Tx_string
		call	Tx_string

		mov	w,#_dw
		page	Tx_string
		call	Tx_string

		page	loop_c0
		jmp	loop_c0

:loop13
		bank	SW1B
		clr	sw1dl
		bank	main
:main_sub_E
		page	loop_start
		jmp	loop_start
:up_obr
		bank	I2C
		inc	OB_RUN
		jmp	:eeee
:dw_obr
		bank	I2C
		dec	OB_RUN
		jmp	:eeee
:up_ec
		bank	I2C
		inc	ER_CUT
		jmp	:eeee
:dw_ec
		bank	I2C
		dec	ER_CUT
:eeee
		bank	main
		page	pr_obr
		jmp	pr_obr
		retp
;-------------------------------------------------------------------------------
;**************************** INTERRUPT CODE *******************************
; Note: The interrupt code must always originate at 0h.

		ORG	0			;interrupt starts at 0h
;		retiw
		page	interrupt
		jmp	interrupt
;****************************************************************************
;****************************** SUBROUTINES *********************************
;
;
; Subroutine - Send string pointed to by address in W register
;
Tx_string
	  	mov     string,w		;store string address
:loop	     	
		mov     w,string		;read next string character
		mov	m,#0			; with indirect addressing
		iread				; using the mode register
		mov	m,#$F			;reset the mode register
		test	w			;are we at the last char?
		snz				;if not=0, skip ahead
		RETP				;yes, leave & fix page bits
		page	send_byte
		call	send_byte		;not 0, so send character
		inc	string			;point to next character
		jmp	:loop			;loop until done
;
;------------------------------------------------------------------------------------
PR_string	mov	string,w		      ;store string address
		mov	w,string		      ;read next string character
		mov	m,#0		; with indirect addressing
		iread				; using the mode register
		mov	m,#$F			;reset the mode register
		test	w			;are we at the last char?
		snz				;if not=0, skip ahead
		RETP				;yes, leave & fix page bits
		mov	tmp,w
		dec	tmp
		mov	w,tmp
		page	lcd_locat
		call	lcd_locat
		inc	string		    ;point to next character

:PR_loop	
		mov	w,string		;read next string character
		mov	m,#0			; with indirect addressing
		iread				; using the mode register
		mov	m,#$F			;reset the mode register
		test	w			;are we at the last char?
		snz				;if not=0, skip ahead
		RETP				;yes, leave & fix page bits

		page	lcd_data
		call	lcd_data
		inc	string		    ;point to next character
		jmp	:PR_loop		   ;loop until done
		RETP				;yes, leave & fix page bits
;
;***************************** PROGRAM DATA ********************************
;
; String data for user interface (must be in lower half of memory page)
;
;_tx_cr		dw	00DH,0
_tx_sw_s	dw	0FFH,0FEH,0FDH,0
_stop_up	dw	0C8h,00DH,0
_stop_all	dw	0C0h,00DH,0
_KIDOU		dw	0D0h,00DH,0
_pnp_sw		dw	007h,00DH,0
_tx1data	dw	0F8H,0FAH,0
_up		dw	081h,00DH,0
_dw		dw	091h,00DH,0
;_mv_stop	dw	089h,00DH,0

_kakou01	dw	'C800',0
_kakou02	dw	'9001',0
_kakou03	dw	'5802',0

_KR_panch	dw	'0300',0		;0.0005
_KR_dai		dw	'0100',0
_KR_doresu	dw	'0200',0

_KK_panch	dw	'0100',0
_KK_dai		dw	'0100',0		;'0300',0
_KK_doresu	dw	'0100',0

_SP_panch	dw	'1E00',0
_SP_dai		dw	'1E00',0
_SP_doresu	dw	'0A00',0

;_SP_panch	dw	'3200',0
;_SP_dai	dw	'3200',0
;_SP_doresu	dw	'0A00',0

_tx2data	dw	0DH,0
;_tx2data	dw	'C800FE01',0DH,0

;_tyu		dw	_LOC_013,	'ﾁｭｳ',0
_tyuudan	dw	_LOC_00,	'ﾘｾｯﾄ',0
_osite		dw	_LOC_11,	' ｦ ｵｼﾃｸﾀﾞｻｲ ! ',0
;_Standbay	dw	_LOC_11,	'< Standby OK!>',0
_Standbay	dw	_LOC_11,	'              ',0
_panch		dw	9,	3,'30 ｲｶ  ',0
_dai		dw	9,	3,'30ｲｼﾞｮｳ',0
_doresu		dw	9,	'   ﾄﾞﾚｽ  ',0
_kakouR		dw	_LOC_00,	'ｶｺｳ=',0
_01		dw	5,	'0.1  ',0
_02		dw	5,	'0.2  ',0
_03		dw	5,	'0.3  ',0
;_syuuryou	dw	_LOC_11,	'< ｹﾝｻｸｼｭｳﾘｮｳ >',0
_err		dw	66,	' - ',0		;'ｴﾗｰ',0
_ok 		dw	66,	'ok!',0		;'ｴﾗｰ',0
_obpr		dw	_LOC_11,	'OBR     AC',0

;_clr_low	dw	_LOC_11,	'              ',0


;****************************************************************************
;		ORG	100H
;***************************** MAIN PROGRAM CODE ******************************
; Program execution begins here on power-up or after a reset
;
reset_entry
		mov	m,#$F			;reset mode register
		mov	!ra,#ra_ini_in		;Set RA in/out directions
		mov	!rb,#rb_ini_Aout	;Set RB in/out directions
		mov	!rc,#rc_ini_Hinp	;Set RC in/out directions

		mov	w,#0Eh			;Set up MODE for Pull-UP
		mov	m,w
		mov	!rb,#rb_Pull_Hup	;Set rb4567 = Pull-up enabled
		mov	!rc,#rc_Pull_Hup	;Set rb4567 = Pull-up enabled

		clrb	IN_SW0C		;R/W low

		mov	m,#$F			;reset mode register
		mov	 ra,#ra_ini_data	;initialize port RA
		mov	 rb,#rb_ini_data	;initialize port RB
		mov	 rc,#rc_ini_data	;initialize port RC

		CLR	FSR			;reset all ram starting at 08h
:zero_ram	SB	FSR.4			;are we on low half of bank?
		SETB	FSR.3			;If so, don't touch regs 0-7
		CLR	IND			;clear using indirect addressing
		IJNZ	FSR,:zero_ram		;repeat until done

		page	wait100ms
		call	wait100ms

;
		page	lcd_ini
		call	lcd_ini
;?		mov	!option,#%10011111	;enable rtcc interrupt
;		mov	!option,#%10011000	;enable rtcc interrupt
		mov	!option,#%11011111	;disable rtcc interrupt
;		mov	tm2cou,#dmx_break
;
		page	lcd_clr
		call	lcd_clr		;clear display
		page	lcd_home
		call	lcd_home

		page	start_init
		jmp	start_init

main_ret0

;********************** CGRAM *************************
CGRAM_W
		mov	w,#0
		page	CGRAM_add
		call	CGRAM_add
		mov	push_d,#64
CGRAM_CL
		mov	w,#000H
		page	lcd_data
		call	lcd_data
		decsz	push_d
		jmp	CGRAM_CL
;0=1
		mov	push_d,#004H
		mov	w,#6
		page	CGRAM_Wd
		call	CGRAM_Wd
;1=2&3
		mov	push_d,#00EH
		mov	w,#6+8
		page	CGRAM_Wd
		call	CGRAM_Wd
;2=3&4
		mov	push_d,#0FFH
		mov	w,#5+16
		page	CGRAM_Wd
		call	CGRAM_Wd
		mov	w,#0F3H
		page	lcd_data
		call	lcd_data
;3=5&6
		mov	push_d,#0FFH
		mov	w,#23
		page	CGRAM_Wd
		call	CGRAM_Wd
		mov	w,#000H
		page	lcd_data
		call	lcd_data
		mov	w,#002H
		page	lcd_data
		call	lcd_data
		mov	w,#00EH
		page	lcd_data
		call	lcd_data
		mov	w,#0F5H
		page	lcd_data
		call	lcd_data
		mov	w,#0F5H
		page	lcd_data
		call	lcd_data
		mov	w,#00EH
		page	lcd_data
		call	lcd_data
		mov	w,#008H
		page	lcd_data
		call	lcd_data

;****************************************************************************
;----------------------------   Main Program    -----------------------------
;****************************************************************************
main_loop
:loop1
		snb	key3d
		jmp	:loop1

		page	wait10ms
		call	wait10ms

		snb	key3d
		jmp	:loop1

		page	TX_STOP_UP
		call	TX_STOP_UP

		page	pr_kidou1
		call	pr_kidou1
:loop2
		page	wait100ms
		call	wait100ms

		page	pr_kidou2
		call	pr_kidou2
;......................................................1023
		page	Tx_data
		call	Tx_data
;
;		mov	w,#_ok
;		page	PR_string
;		call	PR_string

loop_start
main_loop1
		page	main_sub
		jmp	main_sub
		jmp	main_loop1

loop_c0
;		page	Rx_poke
;		call	Rx_poke
;		page	Rx_chk_TT
;		call	Rx_chk_TT
		page	wait100ms
		call	wait100ms
		jmp	loop_c4
loop_c1
;		page	Rx_chk_T
;		call	Rx_chk_T
		page	wait100ms
		call	wait100ms
		page	wait100ms
		call	wait100ms
loop_c2
:loop_c3
:loop_c31
:loop_c32
:loop_c33
loop_c4
		jmp	loop_start
;----------------------------------------------------------------
pr_obr
		mov	w,#_obpr
		page	PR_string
		call	PR_string

		mov	w,#64 + 5
		page	lcd_locat
		call	lcd_locat

		bank	I2C
		mov	tmp,OB_RUN
		bank 	main
		page	HEX2BCD
		call	HEX2BCD
;		page	HEX2MAX99
;		call	HEX2MAX99
;		mov	tmp1,tmp
;		bank	I2C
;		mov	OB_RUN,tmp
;		bank 	main

		add	dpdt,#'0'
		mov	w,dpdt
		page	lcd_data
		call	lcd_data

		page	Hex2lcd
		call	Hex2lcd

		mov	w,#64 + 12
		page	lcd_locat
		call	lcd_locat

		bank	I2C
		mov	tmp,ER_CUT
		bank 	main
		page	HEX2MAX99
		call	HEX2MAX99
		bank	I2C
		mov	ER_CUT,tmp
		bank 	main
;		mov	tmp1,tmp
		page	Hex2lcd
		call	Hex2lcd

		page	wait500ms
		call	wait500ms
		jmp	loop_start

;-------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
		END				;End of program code
```
## プログラム制御部です
```asm
;===================================================================
;		PG-160 2001 9/28end  2400bps
;	ＡＧ－２００－ＣＯＮＴ－ＳＴＡ　制御基板　ＯＮ　Ｚ０２
;===================================================================
;PA0 		in					センサー上位置(LOW)
;PA1 		in	WK	ワーク感知SW
;PA2	1Y	in	B1      DR戸       		;A1センサー外位置(ER)
;PA3	2Y	in	B2	MG-TB		        ;A2センサー下位置（SM）
;PA4	3Y	in	B3	MG-TOIS			;A3センサー内側(OLD戸）
;PA5	4Y	in	B4      MG-PNP      		;A4上下移動範囲センサー（上昇端）
;PA6	TI2-1	out	SM-OUT1		ｽﾃｯﾋﾟﾝｸﾞﾓｰﾀ
;PA7	TI2-2	out	SM-OUT2		ｽﾃｯﾋﾟﾝｸﾞﾓｰﾀ

;===================================================================
;PA0 		in	% SOL1 DOWN CHK				;LOW	SEN7	下降端SW
;PA1 		in	WK	SEN2	ワーク感知SW
;PA2	1Y	in	% SOL2 IN	CHK			;EA	予備	SEN5エアー圧力SW
;PA3	2Y	in	% SOL2 OUT CHK					;SM	IN-3	ｽﾃｯﾋﾟﾝｸﾞﾓｰﾀ
;PA4	3Y	in	DR	IN-2	SEN4扉開閉SW
;PA5	4Y	in	UP	IN-1	SEN1上下移動範囲センサー	；上昇端SW
;PA6	TI2-1	out	SM-OUT1		ｽﾃｯﾋﾟﾝｸﾞﾓｰﾀ
;PA7	TI2-2	out	SM-OUT2		ｽﾃｯﾋﾟﾝｸﾞﾓｰﾀ
;                       -A-     -B-
;PB0	RY7	out	SOL1	SOL1	上下センサー移動
;PB1	RY6	out	SOL2	SOL2	内外センサー移動
;PB2	RY5	out	LED-G	PATLITE	ﾊﾟﾄﾗｲﾄ   
;PB3	RY4	out	電源				OLD LED-R	PATLITE	ﾊﾟﾄﾗｲﾄ
;PB4	RY3	out	MG3	ＩＭ３	ﾃｰﾌﾞﾙ駆動ﾓｰﾀ
;PB5	RY2	out	MG2	ＩＭ２	トイシ軸 ﾓｰﾀ
;PB6	RY1	out	MG1	ＩＭ１	ﾎﾟﾝﾌﾟﾓｰﾀ
;PB7    SELET   out     Low=A   
;
;CTC0	BPS			ボーレート			
;CTC1	in	SP	SEN3	テーブル1回転SW	ﾌｫﾄﾏｲｸﾛｾﾝｻ
;
;-----------------------------------------------
; 
STACK		EQU 	0F800h		; スタックポイント
START_ADDRESS	EQU	0000h		; スタート番地
;START_ADDRESS	EQU	08000h		; スタート番地
;UP350D		EQU	06000H
;........................................
;UP300D		EQU	UP350D
;UP170D		EQU	UP350D + 800H
;	INCLUDE STM_D.SRC
;........................................
;
RAMD		EQU	0C000H
ZVR_MON		EQU	00100h	; モートモニタプログラム　スタート番地;
CTC0	equ	010h		;
CTC1	equ	011h
CTC2	equ	012h
CTC3	equ	013h
;SIOAD	equ	018h
;SIOAC	equ	019h
SIOBD	equ	01ah
SIOBC	equ	01bh
PIOAD	equ	01ch
PIOAC	equ	01dh
PIOBD	equ	01eh
PIOBC	equ	01fh
WDTER	equ	0f0h
WDTCR	equ	0f1h
;
	ORG	START_ADDRESS
;
	JP	START			; 
	ORG	START_ADDRESS + 100H
INT_TOP:
CTC_INT0:	
	DW	CTC0INT
CTC_INT1:	
	DW	CTC1INT
CTC_INT2:	
	DW	CTC2INT
CTC_INT3:	
	DW	CTC3INT
SIO_INT:
	DW	rx_int
;
;=================================================
;	スタート
;=================================================
;
	ORG	START_ADDRESS + 200H
;
START:
	LD	SP, STACK		; 
	ld 	a,high INT_TOP
	ld 	i,a		
                ;INT VECTOR TABLE upper 8 bits
	im 	2		
;
 	call	initsio
	call	initpio
	call    initCTC
	XOR	A
	OUT	(PIOAD),A
	OUT	(PIOBD),A
	LD	A,0
	LD	(ACK),A
	LD	(ERR_P),A
	LD	(RX_D_P),A
	LD	(RX_F),A
	LD	(TX_F),A
	LD	(IX_DEC_P),A
	LD	(KIDOU_P),A
	LD	(CTC1COU),A
	LD	(PUSHMV_SW),A
	LD	(PUSHMV_P),A
	LD	(KIDOU_OFF),A
;;
;	LD	A,(MODE_P)			;6/13   !!!!!!!!!!!!!!!
;	AND	080H				;kokoga tati ugokanai
	LD	(MODE_P),A
	LD	A,0
	CALL	STMC_CLEAR
	CALL	SW_ALL_OFF
;	CALL	TX_Data_CHK
;	CALL	TX_SUUTI
;	CALL	WAIT_01SEC
;	CALL	TX_PIODATA
	CALL	WAIT_01SEC
	CALL	PAT_R_OFF
	CALL	PAT_G_OFF
	EI
;
;=================================================
;	メイン
;=================================================
MAIN:
MAIN_LOOP:
	LD	A,(PUSHMV_P)
	CP	0
	JR	Z,MAIN1
	DEC	A
	LD	(PUSHMV_P),A
MAIN1:
;
	LD	A,(ACK)
	CP	0
	CALL	NZ,TX_ACK
;
	CALL	TX_Data_CHK
;
	LD	A,(TX_F)
	CP	0
	CALL	NZ,TX_PIODATA
;
	LD	A,(RX_F)
	CP	0
	CALL	NZ,RX_CHK
;	-	-	- 	--------  Check ---------
	LD	A,(MODE_P)
	BIT	4,A
	CALL	NZ,KIDOU_STEP     ;起動時は中の確認ROOP
	LD	A,(MODE_P)
	BIT	4,A
	JR	NZ,MAIN_G_ON		;980724
	CALL	PAT_G_OFF
	JP	MAIN_LOOP
MAIN_G_ON:
	CALL	PAT_G_ON
;MAIN_E:
	JP	MAIN_LOOP
SET_TX_F:
	LD	A,1
	LD	(TX_F),A
	RET
;=================================================
TX_Data_CHK:
							;+5/30
	LD	HL,TX_Data
;
	LD	A,(KIDOU_OFF)
	CP	0
	JP	Z,TX_Data_CHK0
	CALL	IN_LOW_CHK
	BIT	5,A		;UP_SW_CHK
	CALL 	NZ,SW_UP_OFF
TX_Data_CHK0:
;							;+5/30
;	BIT	4,A		;SEN4扉開閉SW CHK
;	CALL	NZ,OPEN_DR

	CALL	IN_HI_CHK
	BIT	2,A		;  2000DW　B1      DR戸
	JP	NZ,OPEN_DR
	call	IN_LOW_CHK

;
	LD	A,(HL)
	LD	B,A
	CALL	IN_LOW_CHK
	OR	0C0H
	LD	(HL),A		;HL=0
	CP	B
	CALL	NZ,SET_TX_F
;
	INC	HL
	LD	A,(HL)
	LD	B,A
;
	CALL	IN_HI_CHK
	OR	0C0H
	LD	(HL),A		;HL=1
	CP	B
	CALL	NZ,SET_TX_F
;
	INC	HL
	LD	A,(HL)
	AND	07FH
	LD	B,A

	IN	A,(PIOBD)
	AND	07FH
	LD	(HL),A		;HL=2
	CP	B
	CALL	NZ,SET_TX_F
;
	INC	HL
	LD	A,(HL)
	LD	B,A
	LD	A,(CTC1COU)
;	OR	080H
	LD	(HL),A		;HL=3
	CP	B
	CALL	NZ,SET_TX_F
	RET
;=================================================
KIDOU_STEP:     ;起動時は中の確認ROOP
	LD	A,(KIDOU_P)
	CP	1		;砥石　下降
	CALL	Z,KIDOU_DW	;UP SW=OFF 2 DW
;;;;;;;;;;;;;3
	LD	A,(KIDOU_P)
	CP	4
	CALL	Z,KIDOU_UP	;WK SW=ON 2 UP
;;	LD	A,(KIDOU_P)
;;;;;;;;;;;;;;;;;;;6
;;	CP	6
;;	CALL	Z,KIDOU_D20MM	;
	LD	A,(KIDOU_P)
	CP	7
	CALL	Z,KIDOU_GOWK	;DOWN EC
;;;;;;;;;;;;;9
	LD	A,(KIDOU_P)
	CP	10
	CALL	Z,KIDOU_KENMA	;KENNMA
	LD	A,(KIDOU_P)
	CP	11
	CALL	Z,KIDOU_CTC1CHK	;KENNMA
	LD	A,(KIDOU_P)
	CP	12
	CALL	Z,KIDOU_CTC1CHK	;KENNMA END
	LD	A,(KIDOU_P)
	CP	13
	CALL	Z,KIDOU_E_UP
	CP	14
	CALL	Z,KIDOU_OK_END
	RET
;======================================================================
;	起動動作開始
;======================================================================
KIDOU_DW:			;KIDOU=1
	CALL	TX_SUUTI_P		;;;;;;;;;;;;;;;;;;; 20010922
	CALL	WAIT_01SEC
	CALL	TX_SUUTI_P		;;;;;;;;;;;;;;;;;;; 20010922
	CALL	WAIT_01SEC
	CALL	TX_SUUTI_P		;;;;;;;;;;;;;;;;;;; 20010922
	CALL	WAIT_01SEC
	CALL	SOL1U_ON		;下がる			上下センサー移動
	CALL	WAIT_1SEC	;1000ms
;down chack 
	call	IN_LOW_CHK
	BIT	3,A		;DOWN CH  2000WK　下;A2センサー下位置（SM）
	jp	NZ,OPEN_DR

	CALL	SOL2_ON			;内側			内センサー移動
	CALL	WAIT_1SEC	;1000ms
;move in chack 
	call	IN_LOW_CHK
	BIT	4,A		;IN CH  2000WK　　A3センサー内側(OLD戸）
	jp	NZ,OPEN_DR

	CALL	SOL1U_OFF	;上がる		上下センサー移動
	CALL	WAIT_1SEC	;1000ms

;up chack
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  2000 3/2
	CALL	DW170START		;砥石　下降
	LD	A,2
	LD	(KIDOU_P),A
	RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
KIDOU_UP:			;KIDOU=4
	CALL	WAIT_01SEC
	LD	A,5
	LD	(KIDOU_P),A
	CALL	UP170START
	CALL	WAIT_01SEC
	CALL	WAIT_01SEC
	CALL	WAIT_01SEC		;SAITEI 6 6/05
	CALL	TX_SUUTI_P		;;;;;;;;;;;;;;;;;;; 20010922
	RET
KIDOU_GOWK:			;KIDOU=7
	LD	A,8
	LD	(KIDOU_P),A
;
;;KIDOU_D20MM:		;;;;;;;;;;;;;;;;;;;;

	LD	C,20
UP255X:
	LD 	B,0
UP255:
	LD	A,080H
	OUT	(PIOAD),A
	CALL	WT100US	
	LD	A,00H
	OUT	(PIOAD),A
	CALL	WT100US	
	DJNZ	UP255
	DEC	C
	JR	NZ,UP255X
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  2000 3/2
	CALL	WAIT_1SEC	;1000ms
	CALL	WAIT_1SEC	;1000ms
	CALL	SOL1U_ON		;下がる		上下センサー移動
	CALL	WAIT_1SEC	;1000ms
;down chack 
	call	IN_LOW_CHK
	BIT	3,A		;DOWN CH  2000WK　下;A2センサー下位置（SM）
	jp	NZ,OPEN_DR

	CALL	SOL2_OFF	;外側			内外センサー移動
	CALL	WAIT_1SEC	;1000ms
;move out chack
	call	IN_LOW_CHK
	BIT	2,A		;  2000DW　A1センサー外位置(ER)
	JP	NZ,OPEN_DR

	CALL	SOL1U_OFF	;上がる		　　上下センサー移動
	CALL	WAIT_1SEC	;1000ms
;up chack
	call	IN_LOW_CHK
	BIT	0,A		;  2000DW  センサー上位置
	JP	NZ,OPEN_DR

	LD	C,178
DOWN255X:
	LD 	B,0
DOWN255:
	LD	A,040H
	OUT	(PIOAD),A
	CALL	WT100US	
	LD	A,00H
	OUT	(PIOAD),A
	CALL	WT100US	
	DJNZ	DOWN255
	DEC	C
	JR	NZ,DOWN255X
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2000 3/02   
	CALL	WAIT_01SEC
	CALL	WAIT_01SEC
	CALL	WAIT_01SEC		;SAITEI 6 6/05

	CALL	PNP_ON

	CALL	WAIT_01SEC
	CALL	WAIT_01SEC
	CALL	WAIT_01SEC		;SAITEI 6 6/05
					;[C0FE40]
;	CALL	WAIT_1SEC	;1000ms
	CALL	WKSP_ON		;SW5IN		;WKSP    [C0FE10]   980724
					;[C0FE50]
 	CALL	WAIT_01SEC
	CALL	WAIT_01SEC
	CALL	WAIT_01SEC		;SAITEI 6 6/05
	CALL	WAIT_01SEC

; 	CALL	WAIT_1SEC	;1000ms

	CALL	TOISI_ON	;	 [C0FE20]
					;[C0FE70] > [C0C670] MAG 123 ON
	CALL	TX_SUUTI_P		;;;;;;;;;;;;;;;;;;; 20010922

	LD	A,(STMC1 + 1)
	AND	0C0H				;0FOH > 0C0H
	LD	B,0C0H				;0CE0H > 0C0H
;;;;	CP	B
;;;;	JP	NZ,ERR_K_SUB			;ERRR   6/07
;DW3MM_DATA
	LD	A,(DW3MM_DATA+1)
	AND	0F0H				;0F8H>0F0H
	LD	B,0F0H				;0F8H>0F0H
;;;;;	CP	B
;;;;;	JP	NZ,ERR_K_SUB			;ERRR   6/07    ***************
;;
	LD	B,0D0H
	CALL	IN_HI_CHK
	AND	38H
;;;;;	CP	0
;;;;;	JP	NZ,ERR_K_SUB			;ERRR   6/07
;
	CALL	DW170START
	LD	A,0
	LD	(KIRI_STM_COU),A
	RET
KIDOU_KENMA:			;KIDOU=10
	LD	A,11
	LD	(KIDOU_P),A
	LD	A,0
	LD	(CTC1COU),A
	DI
	CALL	CTC1INT_ON
	EI
	RET
KIDOU_CTC1CHK:
			;KIDOU=11&12
;	LD	A,(KIRI_STM_COU)		;715
;	CP	2
;	JR	C,KIDOU_CTC1CHK0
;	DEC	A
;	LD	(KIRI_STM_COU),A
;	CALL	STM_DW_P
;	CALL	TX_PIODATA
KIDOU_CTC1CHK0:
	CALL	LOW_WK_CHK
	LD	A,(KIDOU_P)
	CP	11
	JR	Z,KIDOU_CTC1CHK1
	CP	12
	JR	Z,KIDOU_CTC1CHK1
	RET
;---------------------------------------
ERR_K_SUB:
	LD	A,B
	AND	0FH
	LD	B,A
	CALL	OPEN_DR
	JP	KIDOU_ERR_E
	RET
;------------------------------------
KIDOU_CTC1CHK1:
	LD	A,(CTC1DLC1)
	INC	A
	LD	(CTC1DLC1),A
	CP	0
	RET	NZ
	LD	A,(CTC1DLC2)
	INC	A
	LD	(CTC1DLC2),A
	AND	07H
	CP	0
	RET	NZ
	DI
	CALL	CTC1INT_ON
	EI
	RET
KIDOU_E_UP:		;13
	CALL	PNP_OFF
	CALL	WAIT_01SEC
	CALL	TX_PIODATA
	CALL	M_UP300START
;	CALL	WAIT_1SEC	;1000ms
	CALL	WAIT_01SEC
	CALL	TOISI_OFF		;;;;;;;;;;;;;;;;;;;; 20010928
	CALL	WAIT_01SEC
	CALL	WAIT_1SEC	;1000ms
	CALL	TX_PIODATA
	CALL	WAIT_01SEC
	CALL	UP300START
	LD	A,14
	LD	(KIDOU_P),A
	LD	A,0
	LD	(CTC1COU),A
	CALL	SW_STOP1
	LD	A,1
	LD	(KIDOU_OFF),A
	RET
KIDOU_OK_END:		;14
 	call	WAIT_01SEC
	LD	A,(MODE_P)
	BIT	5,A
	RET	NZ
	LD	A,(MODE_P)		;  TUIKA
	RES	4,A			;
	LD	(MODE_P),A		;
	LD	A,0			;
	LD	(KIDOU_P),A		;
	CALL	TOISI_OFF		;
	CALL	WKSP_OFF		;
	CALL	TX_PIODATA		;  6/07
	RET
;=================================================
ORGE_PRG:
	LD	A,(MODE_P)
	RES	7,A
	LD	(MODE_P),A
	CALL	SET_TX_F
	CALL	SW_STOP1
;							;+5/30
	CALL	TOISI_OFF
	CALL	WKSP_OFF
	CALL	PNP_OFF
	RET
USER_PRG:
	LD	A,(MODE_P)
	SET	7,A
	LD	(MODE_P),A
	CALL	SET_TX_F
	CALL	SW_STOP1
;							;+5/30
	CALL	TOISI_OFF
	CALL	WKSP_OFF
	CALL	PNP_OFF
	RET
SW_KIDOW:
;	アンクランプ中起動しない
	CALL	TX_ACK			;OLD  CALL	NZ,TX_ACK  980723
;
;	IN	A,(PIOBD)		;980723
;	BIT	0,A
;	RET	NZ

CHCK_UP_OUT:
	call	IN_LOW_CHK
	BIT	0,A		;  2000DW  センサー上位置
	JP	NZ,OPEN_DR
	BIT	2,A		;  2000DW　A1センサー外位置(ER)
	JP	NZ,OPEN_DR
	CALL	IN_HI_CHK
	BIT	2,A		;  2000DW　B1      DR戸
	JP	NZ,OPEN_DR


	LD	A,(MODE_P)
	CP	0
	RET	NZ
	LD	A,0
	LD	(ERR_P),A
;							;+5/30
	CALL	TOISI_OFF
	CALL	WKSP_OFF
	CALL	PNP_OFF
;
	LD	A,1
	LD	(KIDOU_P),A
	LD	A,(MODE_P)
	SET	4,A
	LD	(MODE_P),A
	CALL	PAT_G_ON
	RET
SW_EDIT:
	CALL	RX_KEISAN
 	call	WAIT_01SEC
	CALL	TX_SUUTI
SW_ED_STOP:
	CALL	TOISI_OFF
	CALL	WKSP_OFF
	CALL	PNP_OFF
;							;+5/30
	RET
;
;----------------------------------
SW7IN:				;ＩＭ１	ﾎﾟﾝﾌﾟﾓｰﾀ
	IN	A,(PIOBD)
	BIT	6,A
	JR	NZ,PNP_OFF
PNP_ON:
	IN	A,(PIOBD)
	SET	6,A
	OUT	(PIOBD),A
	RET
PNP_OFF:
	IN	A,(PIOBD)
	RES	6,A
	OUT	(PIOBD),A
	RET
;----------------------------------
SW6IN:				;ＩＭ２	トイシ軸 ﾓｰﾀ
	IN	A,(PIOBD)
	BIT	5,A
	JR	NZ,TOISI_OFF
TOISI_ON:
	IN	A,(PIOBD)
	SET	5,A
	OUT	(PIOBD),A
	RET
TOISI_OFF:
	IN	A,(PIOBD)
	RES	5,A
	OUT	(PIOBD),A
	RET
;----------------------------------
;	アンクランプ中テーブル回転させない
SW5IN:				;ＩＭ３	ﾃｰﾌﾞﾙ駆動ﾓｰﾀ
	IN	A,(PIOBD)
	BIT	4,A
	JR	NZ,WKSP_OFF
WKSP_ON:
	IN	A,(PIOBD)
	BIT	0,A		;	アンクランプ中
	RET	NZ
	SET	4,A
	OUT	(PIOBD),A
	RET
WKSP_OFF:
	IN	A,(PIOBD)
	RES	4,A
	OUT	(PIOBD),A
	RET
;----------------------------------
SW4IN:				;LED-R	PATLITE	ﾊﾟﾄﾗｲﾄ
	IN	A,(PIOBD)
	BIT	3,A
	JR	NZ,PW_RY_OFF
;PAT_R_ON:
PW_RY_ON:
	IN	A,(PIOBD)
	SET	3,A
	OUT	(PIOBD),A
	RET
;PAT_R_OFF:
PW_RY_OFF:
	IN	A,(PIOBD)
	RES	3,A
	OUT	(PIOBD),A
	RET
;----------------------------------
SW3IN:			;LED-G	PATLITE	ﾊﾟﾄﾗｲﾄ
	IN	A,(PIOBD)
	BIT	2,A
	JR	NZ,PAT_G_OFF
PAT_G_ON:
	IN	A,(PIOBD)
	SET	2,A
	OUT	(PIOBD),A
	RET
PAT_G_OFF:
	IN	A,(PIOBD)
	RES	2,A
	OUT	(PIOBD),A
	RET
;----------------------------------
SW2IN:			;PAT_R_ON	;OLD ｿﾚﾉｲﾄﾞ１半浮上
	IN	A,(PIOBD)
	BIT	1,A
	JR	NZ,SOL1U_OFF
PAT_R_ON:
SOL2_ON:
;SOL1U_ON:
	IN	A,(PIOBD)
	SET	1,A
	OUT	(PIOBD),A
	RET
PAT_R_OFF:
SOL2_OFF:
;SOL1U_OFF:
	IN	A,(PIOBD)
	RES	1,A
	OUT	(PIOBD),A
	RET
;------------------------------------------------------------
SW1IN:					;ｿﾚﾉｲﾄﾞ１半浮上ﾆ変更
;	IN	A,(PIOBD)		;980724
;	BIT	4,A
;	RET	NZ
;	IN	A,(PIOBD)
;	BIT	0,A
;	JR	NZ,SOL2K_OFF
;							;+5/30
;	CALL	TOISI_OFF
;	CALL	WKSP_OFF
;	CALL	PNP_OFF
SOL1U_ON:
;SOL2K_ON:
	IN	A,(PIOBD)
;	BIT	4,A
;	RET	NZ			;2000 2/1 coment out
	SET	0,A		
	OUT	(PIOBD),A
	RET
SOL1U_OFF:
;SOL2K_OFF:
	IN	A,(PIOBD)
;	BIT	4,A
;	RET	NZ
	RES	0,A		
	OUT	(PIOBD),A
	RET
;-----------------------------------------
SW_STOP_UP:
;	CALL	SOL1U_OFF
;	CALL	SOL2_OFF
	call	PW_RY_ON	;	PAT_R_ON ;;;;;;;;;;;;980417 980723
	call	PAT_G_OFF
;	CALL	PAT_R_OFF
;
	call	IN_LOW_CHK
	BIT	5,A
	JR	Z,SW_STOP_UP_S	;,CTC2INT_OFF		;UP_SW_CHK
	CALL	TX_SUUTI_P		;;;;;;;;;;;;;;;;;;; 20010922
;	CALL	TX_PIODATA		;  6/10
	CALL	WAIT_01SEC
	JP	SW_STOP_UP_E			;2000 ////////////////////////////////////////
	RET
;
SW_STOP_UP_S:
	LD	A,0H
	LD	(PUSHMV_SW),A
	LD	(PUSHMV_P),A
;
	LD	A,0
	LD	(ERR_P),A
;
	CALL	PNP_OFF
	CALL	SLOW_STOP
	CALL	STM_BR_SUB
;							;+5/31
	CALL	TX_ACK			;OLD  CALL	NZ,TX_ACK  980723
;
	CALL	WAIT_01SEC
	CALL	WAIT_01SEC
	CALL	WAIT_01SEC
	CALL	WAIT_01SEC
;;
	CALL	TOISI_OFF
	CALL	WKSP_OFF
;	CALL	SOL1U_OFF			;2000 //////////////////////////////////////
;	CALL	SET_TX_F
	CALL	SPM_STOP
	CALL	UP300START
;
	LD	A,(MODE_P)
	RES	4,A
	LD	(MODE_P),A
	LD	A,0
	LD	(KIDOU_P),A
	CALL	SET_TX_F
;
SW_STOP_UP_E:
	call	IN_LOW_CHK
	BIT	0,A		;  2000DW  センサー上位置
	RET	Z

	CALL	WAIT_1SEC	;1000ms
	CALL	SOL1U_ON		;下がる		上下センサー移動
	CALL	WAIT_1SEC	;1000ms
;down chack 
	call	IN_LOW_CHK
	BIT	3,A		;DOWN CH  2000WK　下;A2センサー下位置（SM）
	jp	NZ,OPEN_DR

	CALL	SOL2_OFF	;外側			内外センサー移動
	CALL	WAIT_1SEC	;1000ms
;move out chack
	call	IN_LOW_CHK
	BIT	2,A		;  2000DW　A1センサー外位置(ER)
	JP	NZ,OPEN_DR

	CALL	SOL1U_OFF	;上がる		　　上下センサー移動
	CALL	WAIT_1SEC	;1000ms

	RET
;-----------------------------------------
OPEN_DR:
;	call	PAT_G_OFF
	CALL	WKSP_OFF
	CALL	TOISI_OFF
;
	LD	A,(KIDOU_P)
	CP	0
	RET	Z
;
;	CALL	PAT_R_ON
	CALL	PNP_OFF
	LD	A,0
	LD	(KIDOU_P),A
	LD	A,(MODE_P)
	BIT	5,A	;MOVE ON
;	RET	Z
	CALL	NZ,SLOW_STOP
	CALL	WAIT_01SEC			;+6/05
	CALL	WAIT_01SEC			;+6/06
;
;	CALL	TX_PIODATA
	CALL	STM_BR_SUB
	LD	A,1
	LD	(TX_F),A
	CALL	WAIT_01SEC
;	CALL	SPM_STOP			;-6/07
	RET
STM_BR_SUB:
;							;+5/31
	LD	A,(MODE_P)
	RES	4,A
	LD	(MODE_P),A
	LD	A,0
	LD	(KIDOU_P),A
;	LD	A,(MODE_P)
;	BIT	5,A	;MOVE OFF
;	RET	Z
;	CALL	MODE_MV_OFF
;	CALL	CTC2INT_OFF
;	CALL	SET_TX_F
	RET
;-----------------------------------------
SW_UP_OFF:
	LD	A,0
	LD	(KIDOU_OFF),A
	CALL	TOISI_OFF
	CALL	WKSP_OFF
	RET
SW_STOP1:
;	CALL	TOISI_OFF
;	CALL	WKSP_OFF
	CALL	PNP_OFF
;	LD	A,(MODE_P)
;	RES	4,A
;	LD	(MODE_P),A
	DI
	CALL	CTC1INT_OFF
	EI
	CALL	SET_TX_F
	RET
SW_ALL_OFF:
	LD	A,0
	OUT	(PIOBD),A
	LD	A,(MODE_P)
	RES	4,A
	LD	(MODE_P),A
	DI
	CALL	CTC1INT_OFF
	EI
	CALL	SET_TX_F
	RET
;-----------------------------------------
SPM_STOP:
;
	LD	A,0
	LD	(IX_DEC_P),A
	CALL	MODE_MV_OFF
	CALL	CTC2INT_OFF
;
	LD	A,(KIDOU_P)
	CP	9
	JR	Z,KIDOU_UP_END
	CP	6
	JR	Z,KIDOU_UP_END
	CP	3
	RET	NZ
	INC	A
	LD	(KIDOU_P),A
	RET
KIDOU_UP_END:
	INC	A		;KIDOU 6>7&9>10
	LD	(KIDOU_P),A
;	CALL	TX_PIODATA	;;;;*** 後でとる
	RET
SLOW_STOP:
	LD	A,0H
	LD	(PUSHMV_SW),A
	LD	(PUSHMV_P),A
	LD	A,1
	LD	(IX_DEC_P),A
	CALL	IX_DEC
	RET
;
;-----------------------------------------
IN_HI_CHK:
	IN	A,(PIOBD)
	SET	7,A
	OUT	(PIOBD),A
	IN	A,(PIOAD)
	PUSH	AF
	IN	A,(PIOBD)
	RES	7,A
	OUT	(PIOBD),A
	POP	AF
	RET
;-----------------------------------------
IN_LOW_CHK:
	IN	A,(PIOBD)
	RES	7,A
	OUT	(PIOBD),A
	IN	A,(PIOAD)
	RET
;-----------------------------------------
RX_A2B_SUB:
	INC	HL
	LD	A,(HL)
	CALL	A2B
	RLA
	RLA
	RLA
	RLA
	AND	0F0H
	LD	C,A
	INC	HL
	LD	A,(HL)
	CALL	A2B
	ADD	A,C
	RET
;---------------------------------
RX_EDIT_D:
	INC	HL
	LD	A,(HL)
	CP	0FAH
	RET	NZ
	LD	IY,SUUTI_TOP
	LD	B,12
RX_EDIT_DL:
	CALL	RX_A2B_SUB
	LD	(IY),A
	INC	IY
	DJNZ	RX_EDIT_DL
;
	CALL	RX_KEISAN
 	call	WAIT_01SEC
	CALL	TX_SUUTI
;
	RET
;-----------------------------------------
RX_CHK:
	LD	A,0
	LD	(RX_F),A
	LD	HL,RX_Data
	LD	A,(HL)
	CP	0F8H
	JP	Z,RX_EDIT_D
	LD	A,(HL)
	CP	0FFH
	RET	NZ
	INC	HL
	LD	A,(HL)
	CP	0FEH
	RET	NZ
	INC	HL
	LD	A,(HL)
	CP	0FDH
	RET	NZ
	INC	HL
	LD	A,1
	LD	(ACK),A
;----------------------------------------------
	LD	A,(HL)
	CP	0C8H
	JP	Z,SW_STOP_UP
;	-	-	- 	--------  Check ---------
	IN	A,(PIOBD)				;;;;;;;980417> 2,A > 3,A 980724
	BIT	3,A
	ret	z

	LD	A,(MODE_P)
	BIT	4,A
	JR	Z,RX_CHK_NONKIDOU		
			;起動時は中断上昇以外働かない
	RET
;	-	-	-	-	-	-	-
RX_CHK_NONKIDOU:
;	LD	A,0		;
;	LD	(ERR_P),A
;
RX_CHK_3:
	LD	A,(HL)
;	CP	88H
;	JP	Z,SPM_STOP
;	CP	89H
;	JP	Z,SLOW_STOP
;	CP	0A0H
;	JP	Z,ORGE_PRG
;	CP	0B0H
;	JP	Z,USER_PRG
;	CP	0C0H
;	JP	Z,SW_ALL_OFF
;	CP	1
;	JP	Z,SW1IN		;ｿﾚﾉｲﾄ２クランプ
	CP	7
	JP	Z,SW7IN		;ＩＭ１	ﾎﾟﾝﾌﾟﾓｰﾀ ;;;;;;;;;;;;;;;;;;;
;	CP	80H
;	JP	Z,UP300START
	CP	81H
	JP	Z,M_UP300START
;	CP	82H
;	JP	Z,UP170START
;	CP	83H
;	JP	Z,UP150START
;	CP	0E0H
;	JP	Z,SW_EDIT
;	CP	0E1H
;	JP	Z,SW_ED_STOP
;	CP	0E8H
;	JP	Z,SUUTI1ROML
;	CP	0E9H
;	JP	Z,SUUTI2ROML
;	CP	0EAH
;	JP	Z,SUUTI3ROML
;	CP	0EBH
;	JP	Z,SUUTI4ROML
;	CP	0ECH
;	JP	Z,SUUTI5ROML
;	CP	0EDH
;	JP	Z,SUUTI6ROML
;	CP	0EEH
;	JP	Z,SUUTI7ROML
;	CP	0EFH
;	JP	Z,SUUTI8ROML
;
	CALL	IN_LOW_CHK
;	BIT	4,A		;SEN4扉開閉SW CHK	;971031  2000	PUSH
;	RET	Z
;	BIT	2,A		;SEN5エアー圧力SW
;	RET	NZ
;
	LD	A,(HL)
;	CP	90H
;	JP	Z,DW300START
	CP	91H
	JP	Z,M_DW300START
;	CP	92H
;	JP	Z,DW170START
;	CP	93H
;	JP	Z,DW150START
;	CP	2
;	JP	Z,SW2IN		;ｿﾚﾉｲﾄﾞ１半浮上
;	CP	3
;	JP	Z,SW3IN		;LED-G	PATLITE	ﾊﾟﾄﾗｲﾄ
;	CP	4
;	JP	Z,SW4IN		;LED-R	PATLITE	ﾊﾟﾄﾗｲﾄ
;	CP	5
;	JP	Z,SW5IN		;ＩＭ３	ﾃｰﾌﾞﾙ駆動ﾓｰﾀ
;	CP	6
;	JP	Z,SW6IN		;ＩＭ２	トイシ軸 ﾓｰﾀ
	CP	0D0H
	JP	Z,SW_KIDOW
	RET
;-----------------------------------------
;TX_ALL_DATA:
TX_SUUTI:
	CALL	TX_SUUTI_P
	CALL	WAIT_01SEC
	CALL	WAIT_01SEC
	CALL	TX_SUUTI_Q
	CALL	WAIT_01SEC
	CALL	WAIT_01SEC
;	CALL	TX_SUUTI_R
;	CALL	TX_SUUTI_S
	RET
TX_SUUTI_P:
	LD	A,'P'
 	call	tx1chb
	LD	A,'P'
 	call	tx1chb
	LD	HL,SUUTI_TOP
	LD	A,(HL)
	INC	HL
	CALL	PR_A_SUB	;KAKOU_RYOU LOW
	LD	A,(HL)
	INC	HL
	CALL	PR_A_SUB	;KAKOU_RYOU HI
	LD	A,(HL)
	INC	HL
	CALL	PR_A_SUB	;KIRI_RYOU LOW
	LD	A,(HL)
	INC	HL
	CALL	PR_A_SUB	;KIRI_RYOU HI
	LD	A,(HL)
	INC	HL
	CALL	PR_A_SUB	;KIRI_KAI LOW
	LD	A,(HL)
	INC	HL
	CALL	PR_A_SUB	;KIRI_KAI HI
	LD	A,(HL)
	INC	HL
	CALL	PR_A_SUB	;SP_OUT_KAI LOW
	LD	A,(HL)
	INC	HL
	CALL	PR_A_SUB	;SP_OUT_KAI HI
;
	LD	A,(HL)
	INC	HL
	CALL	PR_A_SUB	;EARCUT_D LOW
	LD	A,(HL)
	INC	HL
	CALL	PR_A_SUB	;EARCUT_D HI
	LD	A,(HL)
	INC	HL
	CALL	PR_A_SUB	;OBERRUN_D LOW
	LD	A,(HL)
	INC	HL
	CALL	PR_A_SUB	;OBERRUN_D HI
;
	LD	A,0DH
 	call	tx1chb
	RET
;
TX_SUUTI_Q:
	LD	A,'Q'
 	call	tx1chb
	LD	A,'Q'
 	call	tx1chb
;
	LD	A,(HL)
	INC	HL
	LD	A,(STM_P_MM)
	CALL	PR_A_SUB	;STM_P_MM LOW
	LD	A,(HL)
	INC	HL
	LD	A,(STM_P_MM + 1)
	CALL	PR_A_SUB	;STM_P_MM HI
	LD	A,(HL)
	INC	HL
	LD	A,(SOFT_UD_P)
	CALL	PR_A_SUB	;SOFT_UO_P LOW
	LD	A,(HL)
	INC	HL
	LD	A,(SOFT_UD_P + 1)
	CALL	PR_A_SUB	;SOFT_UO_P HI
	LD	A,(HL)
	INC	HL
	LD	A,(KAIHI_3M)
	CALL	PR_A_SUB	;KAIHI_3M LOW
	LD	A,(HL)
	INC	HL
	LD	A,(KAIHI_3M + 1)
	CALL	PR_A_SUB	;KAIHI_3M HI
;
	LD	A,(HL)
	INC	HL
	CALL	PR_A_SUB	;STOP1DATA LOW
	LD	A,(HL)
	INC	HL
	CALL	PR_A_SUB	;STOP1DATA HI
	LD	A,(HL)
	INC	HL
	CALL	PR_A_SUB	;DW3MM_DATA  LOW
	LD	A,(HL)
	INC	HL
	CALL	PR_A_SUB	;DW3MM_DATA  HI
	LD	A,(HL)
	INC	HL
	CALL	PR_A_SUB	;KAKOU_END  LOW
	LD	A,(HL)
	INC	HL
	CALL	PR_A_SUB	;KAKOU_END  HI
	LD	A,0DH
 	call	tx1chb
;	CALL	WAIT_01SEC
	RET
;----------------------------------------------------
TX_ACK:
;	LD	A,'R'
;	call	tx1chb
;	LD	A,'R'
; 	call	tx1chb
;	LD	A,6
; 	call	tx1chb
;	LD	A,0DH
; 	call	tx1chb
;
;	CALL	WAIT_001SEC
;
	LD	A,0
	LD	(ACK),A
	RET
;-----------------------------------------
TX_STM:
	RET
	LD	A,'S'
 	call	tx1chb
	LD	A,'S'
 	call	tx1chb
;
	CALL	PR_STM
	RET
;-------------------------------
TX_PIODATA:
	LD	A,0
	LD	(TX_F),A
;	LD	(RX_F),A
;
	LD	A,'T'
 	call	tx1chb
	LD	A,'T'
 	call	tx1chb
;
	LD	HL,TX_Data
	LD	A,(HL)
;							;+5/30
;	BIT	4,A		;SEN4扉開閉SW CHK	;971031  2000PUSH
;	CALL	Z,OPEN_DR

	CALL	IN_HI_CHK
	BIT	2,A		;  2000DW　B1      DR戸
	JP	NZ,OPEN_DR
	call	IN_LOW_CHK


	LD	A,(HL)
	INC	HL
	CALL	PR_A_SUB	;INA =LOW  1 12
	LD	A,(HL)
	INC	HL
	CALL	PR_A_SUB       ;INA  =HI   2 34
	LD	A,(HL)
	INC	HL
	CALL	PR_A_SUB       ;OUT B      3 56
	LD	A,(HL)
	CALL	PR_A_SUB       ;CTC1COU    4 78
	LD	A,(MODE_P)
	CALL	PR_A_SUB       ;MODE       5 910
	LD	A,(KIDOU_P)
	CALL	PR_A_SUB       ;KIDOU_P    6
	LD	A,(ERR_P)
	CALL	PR_A_SUB       ;ERR_P      7
	CALL	PR_STM
;	CALL	WAIT_001SEC
	RET
;-------------------------------
PR_STM:
	LD	HL,STMC1
	INC	HL
	INC	HL
	LD	A,(HL)
	CALL	PR_A_SUB
	DEC	HL
	LD	A,(HL)
	CALL	PR_A_SUB
	DEC	HL
	LD	A,(HL)
	CALL	PR_A_SUB
	LD	A,0DH
 	call	tx1chb
	LD	A,0DH
 	call	tx1chb
	RET
;---------------------------
PR_A_SUB:
	LD	D,A
	RRA
	RRA
	RRA
	RRA
	AND	0FH
	CALL	TX_B2A
	LD	A,D
	AND	0FH
	CALL	TX_B2A
	RET
;-----------------------------------------
rx_int:
rx1chb:
	EX	AF,AF'
	EXX
	DI
; 	in	a,(SIOBC)
; 	rrca
; 	ret	nc
 	in	a,(SIOBD)
	LD	B,A
; 	call	tx1chb
	CP	0DH
	JR	NZ,RX_INT1
	LD	A,0
	LD	(RX_D_P),A
;	call	TX_RX_D
	LD	A,1
	LD	(RX_F),A
	JR	RX_INT_E
RX_INT1:
	LD	HL,RX_Data
	LD	A,(RX_D_P)
	LD	L,A
	LD	A,B
	LD	(HL),A
; 	call	tx1chb
	INC	HL
	LD	A,L
	LD	(RX_D_P),A
RX_INT_E:
	EXX
	EX	AF,AF'
	EI
	reti
;
;-----------------------------------------------
; send 1 character procedure for channel a
;
tx1chb:
 	PUSH	AF
 	PUSH	BC
 	ld	b,a
tx1cblp:
 	in	a,(SIOBC)
 	bit	2,a	      ;test TxEmpty flag
 	jr	z,tx1cblp
 	ld	a,b
  	out	(SIOBD),a
tx1chbE:
;	ld	a,0		;0621  dl
;	ld	a,0		;0621  dl
;	ld	a,0		;0621  dl
;	ld	a,0		;0621  dl
;	ld	a,0		;0621  dl
;	ld	a,0		;0621  dl
;
 	POP	BC
 	POP	AF
 	ret
;
;*******************************************
MODE_UMV_ON:
	LD	A,(MODE_P)
	SET	5,A	;MOVE ON
	RES	6,A
	LD	(MODE_P),A
	CALL	SET_TX_F
	RET
MODE_DMV_ON:
	LD	A,(MODE_P)
	SET	5,A	;MOVE ON
	SET	6,A	;DOWN
	LD	(MODE_P),A
	CALL	SET_TX_F
	RET
MODE_MV_OFF:
	LD	A,(MODE_P)
	RES	5,A	;MOVE OFF
	RES	6,A     ;UP
	LD	(MODE_P),A
	CALL	SET_TX_F
	RET
;*******************************************
M_UP300START:
	LD	A,(MODE_P)
	bit	5,A	;mv = 1
	jr	z,M_UP300START0
;
	LD	A,(MODE_P)
	bit	4,A	;up = 0
	ret	nz
M_UP300START0:
;
	LD	A,0FFH
	LD	(PUSHMV_SW),A
	LD	(PUSHMV_P),A
;
	LD	A,0
	LD	(UP_DW_P),A
	LD	DE,UP300D
	JR	STM_INC_U_START
;
M_DW300START:
	LD	A,(MODE_P)
	bit	5,A	;mv = 1
	jr	z,M_DW300START0
;
	LD	A,(MODE_P)
	bit	4,A	;up = 0
	ret	z
;
M_DW300START0:
	LD	A,0FFH
	LD	(PUSHMV_SW),A
	LD	(PUSHMV_P),A
;
	LD	A,1
	LD	(UP_DW_P),A
	LD	DE,UP300D
	JR	STM_INC_DW_START
;
UP350START:
	LD	A,0
	LD	(UP_DW_P),A
	LD	DE,UP350D
	JR	STM_INC_U_START
UP300START:
	LD	A,0
	LD	(UP_DW_P),A
	LD	DE,UP300D
	JR	STM_INC_U_START
UP170START:
UP150START:
	LD	A,0
	LD	(UP_DW_P),A
	LD	DE,UP170D
STM_INC_U_START:
	IN	A,(PIOAD)
	BIT	5,A
	RET	NZ		;UP_SW_CHK
	LD	A,(MODE_P)
	AND	60H
	CP	20H		;UP 中なら無処理
	RET	Z
	PUSH 	DE
	POP	IX
	CALL	MODE_UMV_ON
	JR	STM_INC_START
DW350START:
	LD	A,1
	LD	(UP_DW_P),A
	LD	DE,UP350D
	JR	STM_INC_DW_START
DW300START:
	LD	A,1
	LD	(UP_DW_P),A
	LD	DE,UP300D
	JR	STM_INC_DW_START
DW170START:
DW150START:
	LD	A,1
	LD	(UP_DW_P),A
	LD	DE,UP170D
STM_INC_DW_START:
;	IN	A,(PIOAD)	;LOW SW CHK		;2000
;	BIT	5,A		;US = LOW 2000	OLD=0,A
;	RET	NZ
;
	LD	A,(MODE_P)
	AND	60H
	CP	60H		;DW 中なら無処理
	RET	Z
	PUSH 	DE
	POP	IX
	CALL	MODE_DMV_ON
STM_INC_START:
;	CALL	STMC_CLEAR
IX_INC:
	LD	A,(IX)
	CP	0
	JR	Z,IX_INC_F
	LD	B,A
	INC	IX
	INC	IX
	JR	IX_INC_END
IX_INC_F:
	INC	IX
	LD	A,(IX)
	CP	0
	JR	Z,IX_INC_MAX
	LD	B,A
	LD	(MAX_SP),A
	LD	A,0
	INC	IX
IX_INC_END:
	DI
	CALL	CTC2INT_B_ON
	EI
	RET
IX_INC_MAX:
	LD	A,(PUSHMV_SW)
	CP	0
	JP	Z,IX_INC_S
	LD	A,(PUSHMV_P)
	CP	0
	JP	NZ,IX_INC_S
	CALL	SLOW_STOP
	LD	A,0
	LD	(PUSHMV_SW),A
IX_INC_S:
	DEC	IX
;	IN	A,(PIOAD)
;	BIT	5,A
;	RET	NZ	;,CTC2INT_OFF		;UP_SW_CHK
;
	LD	A,(MAX_SP)
	CP	0
	RET	Z
	LD	B,A
	LD	A,0
	DI
	CALL	CTC2INT_B_ON
	EI
	RET
;-------------------------------
IX_DEC:
	LD	A,(IX)
	CP	250
	JP	NC,SPM_STOP
	DEC	IX
	LD	A,(IX)
	LD	B,A
	DEC	IX
	LD	A,(IX)
	CP	0
	JR	Z,IX_DEC_END
IX_DEC_F:
	LD	B,A
IX_DEC_END:
	DI
	CALL	CTC2INT_B_ON
	EI
	RET
;-----------------------------------------
INC_STM:
	LD	HL,STMC1
	LD	A,(HL)
	INC	A
	LD	(HL),A
	CP	0
	JR	NZ,INC_STM_E
	INC	HL
	LD	A,(HL)
	INC	A
	LD	(HL),A
	CP	0
	JR	NZ,INC_STM_E
	INC	HL
	LD	A,(HL)
	INC	A
	LD	(HL),A
INC_STM_E:
	RET
;---------------------------------------
DEC_STM:
	LD	HL,STMC1
	LD	A,(HL)
	DEC	A
	LD	(HL),A		;1
	CP	0FFH
	JR	NZ,DEC_STM_E
	INC	HL
	LD	A,(HL)
	DEC	A
	LD	(HL),A		;2
	CP	0FFH
	JR	NZ,DEC_STM_E
	INC	HL
	LD	A,(HL)
	DEC	A
	LD	(HL),A		;3
DEC_STM_E:
	RET
;------------------------
STMC_CLEAR:
	LD	HL,STMC1
	XOR	A
	LD	(HL),A
	INC	HL
	LD	(HL),A
	INC	HL
	LD	(HL),A
	RET
;-------------------------------
TX_B2A:
	CP	10
	JR	NC,TX_B2A1M
	ADD	A,030H
	JR	TX_B2A1E
TX_B2A1M:
	ADD	A,037H
TX_B2A1E:
	CALL	tx1chb
	RET
;------------------------------
A2B:
	CP	'A'
	JR	NC,A2B_M
	SUB	'0'
	JR	A2B_E
A2B_M:
	SUB	'A'-10
A2B_E:
	RET
;------------------------------
;*******************************************
; CTC interrupt process
;*******************************************
;
CTC0INT:
	DI
	EX	AF,AF'
	EXX
	EXX
	EX	AF,AF'
	EI
	reti
;---------------------------
CTC1INT:
	DI
	EX	AF,AF'
	EXX
;
	LD	DE,TX_Data + 3
;
	LD	A,(KIDOU_P)
	CP	12
	JR	Z,CTC1INT0
;
	LD	A,(KIRI_KAI)
	LD	B,A
	LD	A,(CTC1COU)
	INC	A
	CP	B
	JR	C,CTC1INT1
	CP	B
	CALL	Z,STM_DW_P
	LD	A,(KIRI_RYOU)
	LD	(KIRI_STM_COU),A
	LD	A,0
	JR	CTC1INT1
CTC1INT0:
	LD	A,1
	LD	(TX_F),A
	LD	A,(SP_OUT_KAI)
	LD	B,A
	LD	A,(CTC1COU)
	INC	A
	CP	B
	JR	NZ,CTC1INT1
	LD	A,13		;SP_OUT_END
	LD	(KIDOU_P),A
	LD	A,B
CTC1INT1:
	LD	(DE),A		;HL=3
	LD	(CTC1COU),A
	LD	(CTC1DLC1),A
	LD	(CTC1DLC2),A
	CALL	CTC1INT_OFF
	EXX
	EX	AF,AF'
	EI
	reti
;---------------------------
CTC2INT:
	DI
	EX	AF,AF'
	EXX
	LD	A,(UP_DW_P)
	CP	0		;UP=0
	JR	NZ,CTC2INT_DW
	CALL	CTC2SUB_UP
	JR	CTC2INT_PO
CTC2INT_DW:
	CALL	CTC2SUB_DW
CTC2INT_PO:
	LD	A,(IX_DEC_P)	;0で加速1で減速
	CP	0
	CALL	Z,IX_INC
	LD	A,(IX_DEC_P)
	CP	0
	CALL	NZ,IX_DEC
CTC2INT_P1:
	LD	A,00H
	OUT	(PIOAD),A
;	LD	(PIOAD_P),A
CTC2INT_E:
;	CALL	INC_STM
;	LD	A,'*'
;	call	tx1chb
	EXX
	EX	AF,AF'
	EI
	reti
;---------------------------
CTC3INT:
	reti
;---------------------------
CTC2SUB_UP:
	IN	A,(PIOBD)
	LD	B,A
	RES	7,A
	OUT	(PIOBD),A
;
	PUSH	BC

	CALL	IN_LOW_CHK
;	IN	A,(PIOAD)
	BIT	5,A		;UP_SW_CHK
	CALL	NZ,CTC2SUB_STOP	;5/30 CALL>JR 6/05 JR>CALL
	POP	BC
	LD	A,080H
	OUT	(PIOAD),A
;	IN	A,(PIOBD)
;	SET	7,A
	LD	A,B
	OUT	(PIOBD),A
	CALL	DEC_STM
	LD	A,(KIDOU_P)
	CP	5
	CALL	Z,UP_00_SUB
	RET
CTC2SUB_STOP:
;	LD	A,B
;	OUT	(PIOBD),A
;	CALL	SLOW_STOP

	CALL	TOISI_OFF
	CALL	WKSP_OFF
;	CALL	STM_BR_SUB
;	CALL	SPM_STOP
;	RET
				;KIDOU CHK
;	LD	A,(MODE_P)
;	BIT	4,A
;	RET	Z
;	LD	A,(KIDOU_P)
;	CP	0
;	RET	NZ
	LD	a,(IX_DEC_P)
	cp	1
	ret	z
	CALL	SLOW_STOP
	CALL	TOISI_OFF
	CALL	WKSP_OFF
	CALL	STM_BR_SUB
;	LD	A,1
;	LD	(KIDOU_P),A
	RET
;
UP_00_SUB:
	LD	HL,STMC1
	LD	IY,STOP1DATA
	LD	A,(HL)
	LD	B,A
	LD	A,(IY)
	CP	B
	RET	NZ
	INC	HL
	INC	IY
	LD	A,(HL)
	LD	B,A
	LD	A,(IY)
	CP	B
	RET	NZ
	LD	A,1
	LD	(IX_DEC_P),A
	LD	A,6		;5IN 00=6 GENNSOKU
	LD	(KIDOU_P),A
;	CALL	TX_PIODATA	;;;;*** 後でとる
	RET
;---------------------------
CTC2SUB_DW:
;;
	IN	A,(PIOBD)
	LD	B,A
	RES	7,A
	OUT	(PIOBD),A
	IN	A,(PIOAD)	;LOW SW CHK		;2000
;	BIT	5,A		;US = LOW 2000	OLD=0,A
;	IN	A,(PIOAD)
;	BIT	0,A		;LOW SW CHK
;	JR	NZ,CTC2SUB_STOP_DW
	BIT	1,A		;WK CHK---------------------------
	JR	NZ,CTC2SUB_WK	;97/05/28(NZ>Z)  980513 Z>NZ
CTC2SUB_E:
	LD	A,040H
	OUT	(PIOAD),A
	LD	A,B
	OUT	(PIOBD),A
	CALL	INC_STM
	LD	A,(KIDOU_P)
	CP	8
	CALL	Z,DW_00_SUB
	RET
CTC2SUB_STOP_DW:
	IN	A,(PIOBD)
	SET	7,A
	OUT	(PIOBD),A
	CALL	SPM_STOP
	RET
CTC2SUB_WK:
	LD	A,040H
	OUT	(PIOAD),A
	IN	A,(PIOBD)
	SET	7,A
	OUT	(PIOBD),A
;
				;KIDOU CHK
	LD	A,1
	LD	(IX_DEC_P),A
;	LD	A,(MODE_P)
;	BIT	4,A
;	RET	Z
	LD	A,(KIDOU_P)
	CP	2
	CALL	Z,WK_IN_SUB
	LD	A,040H
	OUT	(PIOAD),A
	LD	A,B
	OUT	(PIOBD),A
	CALL	INC_STM
	RET
WK_IN_SUB:
	CALL	STMC_CLEAR
	LD	A,3
	LD	(KIDOU_P),A
	RET
DW_00_SUB:
	LD	HL,STMC1
	LD	IY,DW3MM_DATA
	LD	A,(HL)
	LD	B,A
	LD	A,(IY)
	CP	B
	RET	NZ
	INC	HL
	INC	IY
	LD	A,(HL)
	LD	B,A
	LD	A,(IY)
	CP	B
	RET	NZ
	LD	A,1
	LD	(IX_DEC_P),A
	LD	A,9		;5IN 00=6 GENNSOKU
	LD	(KIDOU_P),A
;	CALL	TX_PIODATA	;;;;***後でとる  ???????????????????????????
	RET
;---------------------------
STM_DW_P:
	CALL	IN_HI_CHK
	AND	38H
	CP	0
	JR	Z,STM_DW_P_L0
	LD	B,030H
	CALL	ERR_K_S_NC			;ERRR   6/07
	CALL	NZ,SET_TX_F
	JR	STM_DW_PSS
;
STM_DW_P_L0:
	CALL	TX_PIODATA	;0715
;	LD	A,(KIRI_RYOU)
;	LD	B,A
STM_DW_P_L:
	LD	A,040H
	OUT	(PIOAD),A
	CALL	WT10US	
;	CALL	WT10US			;0715
	LD	A,00H
	OUT	(PIOAD),A
STM_DW_PSS:
	CALL	INC_STM
;	LD	A,00H
;	OUT	(PIOAD),A
;
	LD	A,(KIDOU_P)
	CP	11
	CALL	Z,DW_WKE_CHK
	LD	A,(KIRI_STM_COU)		;715
	AND	0F8H
	CP	0
	JR	NZ,STM_DW_F8B
	LD	A,(KIRI_STM_COU)		;715
	AND	1
	CP	1
	CALL	Z,TX_STM
	JR	STM_DW_F8C
STM_DW_F8B:
	LD	A,(KIRI_STM_COU)		;715
	AND	03H
	CP	1
	CALL	Z,TX_STM
STM_DW_F8C:
;	CALL	SET_TX_F		;0617/0623
;	CALL	WAIT_STM		;10-100ms
	LD	A,(KIRI_STM_COU)		;715
	CP	2
	JR	C,LOW_WK_CHK
	DEC	A
	LD	(KIRI_STM_COU),A
	JR	NZ,STM_DW_P_L
;	DJNZ	STM_DW_P_L
LOW_WK_CHK:
	IN	A,(PIOBD)
	LD	D,A
	RES	7,A
	OUT	(PIOBD),A
	IN	A,(PIOAD)
	LD	C,A
	LD	A,D
	OUT	(PIOBD),A
	LD	A,C
;	BIT	5,A		;US = LOW 2000	OLD=0,A
;	BIT	0,A		;LOW SW CHK
;	JR	NZ,KIDOU_ERR11
	BIT	1,A		;WK CHK
	JR	NZ,KIDOU_ERR12	;97/05/28(NZ>Z) 980513 Z>NZ
	RET
;-------------------------------------
DW_WKE_CHK:
	LD	HL,STMC1
	LD	IY,KAKOU_END
	LD	A,(HL)
	LD	B,A
	LD	A,(IY)
	CP	B
	RET	NZ
	INC	HL
	INC	IY
	LD	A,(HL)
	LD	B,A
	LD	A,(IY)
	CP	B
	RET	NZ
	LD	A,12		;DW_END
	LD	(KIDOU_P),A
	CALL	SET_TX_F		;
	RET
;-------------------------------------
ERR_K_S_NC:
	LD	A,(KIDOU_P)
	OR	B
	LD	(ERR_P),A
	RET
KIDOU_ERR11:
	LD	B,010H		;
	JR	KIDOU_ERR_E
KIDOU_ERR12:
	LD	B,020H		;
	JR	KIDOU_ERR_E
KIDOU_ERR_E:
	LD	A,(KIDOU_P)
	OR	B
	LD	(ERR_P),A
	LD	A,(MODE_P)
	RES	4,A
	LD	(MODE_P),A
	LD	A,0
	LD	(KIDOU_P),A
;
	CALL	SW_STOP1
	CALL	TX_PIODATA
;	CALL	PAT_R_ON
	RET
;=================================================
;DW3MM_DATA	DS	2 ;-OBERRUN_D - EARCUT_D
;-------------------------------------------------
RX_KEISAN:
MAKE_DW3MM:
	LD	IY,OBERRUN_D
	CALL	SUB_00_IY
	LD	IY,EARCUT_D
	CALL	SUB_DE_IY
	LD	IY,DW3MM_DATA
	LD	(IY),E
	LD	(IY+1),D
MAKE_STOP1:
	LD	IY,KAIHI_3M
	CALL	SUB_DE_IY
	LD	IY,SOFT_UD_P
	CALL	ADD_DE_IY
	CALL	ADD_DE_IY
	LD	IY,STOP1DATA
	LD	(IY),E
	LD	(IY+1),D
MAKE_KAKOU:
	LD	IY,OBERRUN_D
	CALL	SUB_00_IY
	LD	IY,SOFT_UD_P
	CALL	ADD_DE_IY
	LD	IY,KAKOU_RYOU
	CALL	ADD_DE_IY
	LD	IY,KAKOU_END
	LD	(IY),E
	LD	(IY+1),D
	RET
;  0000-(IY)-(IY+1)=DE
SUB_00_IY:
	LD	A,(IY)
	LD	B,A
	LD	A,0
	SUB	B
	LD	E,A
	LD	A,(IY+1)
	INC	A
	LD	B,A
	LD	A,0
	SUB	B
	LD	D,A
	RET
;  DE-(IY)-(IY+1)=DE
SUB_DE_IY:
	LD	A,(IY)
	LD	B,A
	LD	A,E
	SUB	B
	LD	E,A
	LD	A,(IY+1)
	JR	NC,SUB_DE_IY_NC
	INC	A
SUB_DE_IY_NC:
	LD	B,A
	LD	A,D
	SUB	B
	LD	D,A
	RET
ADD_DE_IY:
	LD	A,(IY)
	LD	B,A
	LD	A,E
	ADD	A,B
	LD	E,A
	LD	A,(IY+1)
	JR	NC,ADD_DE_IY_NC
	INC	A
ADD_DE_IY_NC:
	LD	B,A
	LD	A,D
	ADD	A,B
	LD	D,A
	RET
;=================================================
;	１０ｕＳＥＣ程度のウエイト
;=================================================
WT10US:
LITLE_WAIT:
	PUSH	BC
	LD	B, 8			; 
LITLE_WAIT_0:
	DJNZ	LITLE_WAIT_0		; 
	POP	BC
	RET				; 
WT100US:
LITLE_WAIT111:
	PUSH	BC
	LD	B, 16			; 
LITLE_WAIT_011:
	DJNZ	LITLE_WAIT_011		; 
	POP	BC
	RET				; 
;
;=================================================
;	フォトセンサー用のウエイト
;=================================================
WT50MS:
	PUSH	BC
	LD	B, 5			; 50mSEC
	CALL	WAIT			; 
	POP	BC
	RET				; 
WT100MS:
	PUSH	BC
	LD	B, 10			; 
	CALL	WAIT			; 
	POP	BC
	RET				; 
WT200MS:
	PUSH	BC
	LD	B, 20			; 
	CALL	WAIT			; 
	POP	BC
	RET				; 
;
;=================================================
;	汎用ウエイトルーチン
;
;	引数：	Ｂレジスタ	ウエイトする時間
;
;	ウエイトする時間　＝　Ｂレジスタ　×　１０ms
;
;=================================================
WAIT:
	PUSH	HL;
WAIT_L:
	CALL	WAIT_SUB		; 
	DJNZ	WAIT_L			; 
	POP	HL
	RET				; 
;
WAIT_SUB:
	LD	HL, 1900H		; 
WAIT_SUB_LOOP:
	DEC	L			; 
	JR	NZ, WAIT_SUB_LOOP	; 
	DEC	H			; 
	JR	NZ, WAIT_SUB_LOOP	; 
	RET				; 
;
WAIT_STM:
	PUSH	BC
	LD	B, 5			; 
	CALL	WAIT			; 
	POP	BC			;
	RET				; 
;
;=================================================
;	100mS秒間のウエイトルーチン
;=================================================
WAIT_001SEC:
	PUSH	BC
	LD	B, 1			; 
	CALL	WAIT			; 
	POP	BC			;
	RET				; 
;=================================================
;	100mS秒間のウエイトルーチン
;=================================================
WAIT_01SEC:
	PUSH	BC
	LD	B, 10			; 
	CALL	WAIT			; 
	POP	BC			;
	RET				; 
;=================================================
;	１秒間のウエイトルーチン
;=================================================
WAIT_1SEC:
;	ld	a,'r'
; 	call	tx1chb
;	ld	a,0Ah
; 	call	tx1chb
;	ld	a,0dh
; 	call	tx1chb
;
	PUSH	BC
	LD	B, 100			; 
	CALL	WAIT			; 
	POP	BC			;
	RET				; 
;
;
;=================================================
;	５秒間のウエイトルーチン
;=================================================
START_WAIT_5SEC:
;
	LD	B, 005h			; 
START_WAIT_5SEC_0:
	PUSH	BC
	CALL	WAIT_1SEC
	POP	BC 
	DJNZ	START_WAIT_5SEC_0
;
	RET
;=================================================
WAIT_SL_STOP:
	LD	B, 005h			; 
WAIT_SL_STOP_L:

	PUSH	BC
	CALL	WAIT_01SEC
	POP	BC 
	DJNZ	WAIT_SL_STOP_L
	RET
;=================================================
;=================================================
;=================================================
; PIO initialize procedure
;=================================================
;
initpio:
	ld	hl,PIO_INIT
	LD	B,PIO_INIT_LEN
init0lp:ld	c,(hl)
	inc	hl
	outi
	jr	nz,init0lp
	xor	a
	out	(PIOBD),a
	RET
;
;=================================================
; CTC イニシャル ********
;=================================================
initCTC:
;........ CTC0   INT OFF	ﾎﾞｰﾚｰﾄ
	ld	a,00000101b	
                ;b1:riset,2:ﾀｲﾑ･ｺﾝｽﾀﾝﾄ,3=ﾄﾘｶﾞ 4:0=ﾀﾁｻｶﾞﾘ
;		,5:ﾌﾟﾘｽｰｽｹｰﾗ 0=1/16 6:0=TM,7:0=INT ON
	out	(CTC0),a
	ld	a,13	;52 > 208=2400 104=4800  52=9600
	out	(CTC0),a
	LD	A,low CTC_INT0  ;INTvector addr
	out	(CTC0),a
;........ CTC1		ﾃｰﾌﾞﾙ回転SEN3
	CALL	CTC1INT_OFF
;........ CTC2		ﾀｲﾏｰ　ｽﾃｯﾋﾟﾝｸﾞﾊﾟﾙｽ用
	CALL	CTC2INT_OFF
;....... CTC3 ﾀｲﾏｰ
	ld	a,00100111b
                ;b1:riset,2:ﾀｲﾑ･ｺﾝｽﾀﾝﾄ,3=ﾄﾘｶﾞ 4:0=ﾀﾁｻｶﾞﾘ
;		,5:ﾌﾟﾘｽｰｽｹｰﾗ 1=1/256 6:ﾀｲﾏｰﾓｰﾄﾞ,7:割り込みｵﾝ
	out	(CTC3),a
	ld	a,8	; ﾀｲﾑ･ｺﾝｽﾀﾝﾄ  2=9600bps 8=2400=0.4166ms
	out	(CTC3),a        ;0.4166x256=0.106ms
	RET
;---------------------------
;........ CTC2	ﾀｲﾏｰ　ｽﾃｯﾋﾟﾝｸﾞﾊﾟﾙｽ用
CTC2INT_B_ON:
	CP	0
	JR	Z,CTC2INT_B1
	ld	a,10100111b
                ;b1:riset,2:ﾀｲﾑ･ｺﾝｽﾀﾝﾄ,3=ﾄﾘｶﾞ 4:0=ﾀﾁｻｶﾞﾘ
;		,5:ﾌﾟﾘｽｰｽｹｰﾗ 1=1/256 6:ﾀｲﾏｰﾓｰﾄﾞ,7:割り込みｵﾝ
	JR	CTC2INT_B2
CTC2INT_B1:
	ld	a,10000111b
                ;b1:riset,2:ﾀｲﾑ･ｺﾝｽﾀﾝﾄ,3=ﾄﾘｶﾞ 4:0=ﾀﾁｻｶﾞﾘ
;		,5:ﾌﾟﾘｽｰｽｹｰﾗ 0=1/16   6:ﾀｲﾏｰﾓｰﾄﾞ,7:割り込みｵﾝ
CTC2INT_B2:
	out	(CTC2),a
	LD	A,B
;	ld	a,43	; ﾀｲﾑ･ｺﾝｽﾀﾝﾄ  8M> 0=512us 1=2us
	out	(CTC2),a;                 MAX 86us =43
	RET
CTC2INT_OFF:
	ld	a,00100111b
                ;b1:riset,2:ﾀｲﾑ･ｺﾝｽﾀﾝﾄ,3=ﾄﾘｶﾞ 4:0=ﾀﾁｻｶﾞﾘ
;		,5:ﾌﾟﾘｽｰｽｹｰﾗ 0=1/16  6:ﾀｲﾏｰﾓｰﾄﾞ,7:割り込みｵﾝ
	out	(CTC2),a
	ld	a,0	; ﾀｲﾑ･ｺﾝｽﾀﾝﾄ  8M> 0=512us 1=2us
	out	(CTC2),a;                 MAX 86us =43
	LD	(MAX_SP),A
	RET
;---------------------------
;........ CTC1　　INT ON        ﾃｰﾌﾞﾙ回転SEN3
CTC1INT_ON:
	ld	a,11000111b
                ;b1:riset,2:ﾀｲﾑ･ｺﾝｽﾀﾝﾄ,3=ﾄﾘｶﾞ 4:0=ﾀﾁｻｶﾞﾘ
;		,5:ﾌﾟﾘｽｰｽｹｰﾗ 0=1/16 6:ｶｳﾝﾀﾀｲﾏｰﾓｰﾄﾞ,7:割り込みON
	out	(CTC1),a
;	LD	A,(KIRI_KAI)	; ｲﾑ･ｺﾝｽﾀﾝﾄ
	LD	A,1
	out	(CTC1),a
	RET
CTC1INT_OFF:
	ld	a,01000111b
                ;b1:riset,2:ﾀｲﾑ･ｺﾝｽﾀﾝﾄ,3=ﾄﾘｶﾞ 4:0=ﾀﾁｻｶﾞﾘ
;		,5:ﾌﾟﾘｽｰｽｹｰﾗ 0=1/16 6:ｶｳﾝﾀﾀｲﾏｰﾓｰﾄﾞ,7:割り込みON
	out	(CTC1),a
;	LD	A,(KIRI_KAI)	; ｲﾑ･ｺﾝｽﾀﾝﾄ
	ld	a,1	; ﾀｲﾑ･ｺﾝｽﾀﾝﾄ  2.45M/4.915M  4800bps/9600bps
	out	(CTC1),a
	RET
;=================================================
; SIO initialize procedure
;=================================================
;*************Z80 SIO（ﾁｬﾝﾈﾙB） イニシャル*****
initsio:
	ld	hl,siob_cmd
	ld	b,siob_cmd_end - siob_cmd
	ld	c,SIOBC
	otir
	RET
;=================================================
; SIO initialize data
siob_cmd:
	db	18h		;ﾁｬﾈﾙA･ﾘｾｯﾄ
	db	4,01001100b	;ｸﾛｯｸ倍率*16、ｽﾄｯﾌﾟﾋﾞｯﾄ=1ﾋﾞｯﾄ
;	db	4,00001100b	;ｸﾛｯｸ倍率*00、ｽﾄｯﾌﾟﾋﾞｯﾄ=2ﾋﾞｯﾄ
	db	3,11000001b	;受信８ビット／キャラクタ受信許可
	db	5,01101010b	;送信ｷｬﾗｸﾀ長８ﾋﾞｯﾄ、ｲﾈｰﾌﾞﾙ･ﾄﾗﾝｽﾐｯﾀ、RTS
	db	1,00010000b	;全ての割り込み 
	db	2,low SIO_INT   ;        
siob_cmd_end:
;=================================================
; PIO initialize data
PIO_INIT:
	db	PIOAC,  11111111b	;mode 3
	db	PIOAC,  00111111b	;0-5 IN   KEY
	db	PIOBC,  11111111b	;mode 3
	db	PIOBC,  00000000b	;ALL OUT  KEY
PIO_INIT_LEN	equ	$ - PIO_INIT
;=================================================
;=================================================
SUUTI1ROML:
	LD	DE,SUUTI1ROMD
	JR	SUUTI_ROML
SUUTI2ROML:
	LD	DE,SUUTI2ROMD
	JR	SUUTI_ROML
SUUTI3ROML:
	LD	DE,SUUTI3ROMD
	JR	SUUTI_ROML
SUUTI4ROML:
	LD	DE,SUUTI4ROMD
	JR	SUUTI_ROML
SUUTI5ROML:
	LD	DE,SUUTI5ROMD
	JR	SUUTI_ROML
SUUTI6ROML:
	LD	DE,SUUTI6ROMD
	JR	SUUTI_ROML
SUUTI7ROML:
	LD	DE,SUUTI7ROMD
	JR	SUUTI_ROML
SUUTI8ROML:
	LD	DE,SUUTI8ROMD
SUUTI_ROML:
;	LD	DE,SUUTI_ROMD
	LD	HL,SUUTI_TOP
	LD	B,26
SUUTI_ROM_LP:
	LD	A,(DE)
	LD	(HL),A
	INC	DE
	INC	HL
	DJNZ	SUUTI_ROM_LP
	CALL	TX_SUUTI
	RET
;-----------------------------------------------
SUUTI1ROMD:
	DB	090H,001H	;0.2mm = 400  	KAKOU_RYOU
	DB	001H,000H	;0.0005mm     	KIRI_RYOU
	DB	003H,000H	;;3	     	KIRI_KAI
	DB	032H,000H	;;50          	SP_OUT_KAI
	DB	03CH,000H	;;60=3CH	EARCUT_D
        DB      090H,001H	;;0.2mm=400	OBERRUN_D
	DB	005H,000H	;;0.0005	STM_P_MM
	DB	0B1H,000H	;;177=0B1H      SOFT_UD_P
	DB	070H,017H	;;3mm=6000      KAIHE_3M
	DB	026H,0E8H	;-6106(E826)  	;STOP1DATA
	DB	034H,0FEH	; -460(FE34)    ;DW3MM_DATA
	DB	0B1H,000H	;  -23(00B1)  	;KAKOU_END:
;
SUUTI2ROMD:
	DB	090H,001H	;0.2mm = 400  	KAKOU_RYOU
	DB	001H,000H	;0.0005mm     	KIRI_RYOU
	DB	002H,000H	;;2	     	KIRI_KAI
	DB	032H,000H	;;50          	SP_OUT_KAI
	DB	03CH,000H	;;60=3CH	EARCUT_D
        DB      090H,001H	;;0.2mm=400	OBERRUN_D
	DB	005H,000H	;;0.0005	STM_P_MM
	DB	0B1H,000H	;;177=0B1H      SOFT_UD_P
	DB	070H,017H	;;3mm=6000      KAIHE_3M
	DB	026H,0E8H	;-6106(E826)  	;STOP1DATA
	DB	034H,0FEH	; -460(FE34)    ;DW3MM_DATA
	DB	0B1H,000H	;  -23(00B1)  	;KAKOU_END:
SUUTI3ROMD:
	DB	0C8H,000H	;0.1mm = 200  	KAKOU_RYOU
	DB	001H,000H	;0.0005mm     	KIRI_RYOU
	DB	001H,000H	;;1	     	KIRI_KAI
	DB	00AH,000H	;;10          	SP_OUT_KAI
	DB	03CH,000H	;;60=3CH	EARCUT_D
        DB      090H,001H	;;0.2mm=400	OBERRUN_D
	DB	005H,000H	;;0.0005	STM_P_MM
	DB	0B1H,000H	;;177=0B1H      SOFT_UD_P
	DB	070H,017H	;;3mm=6000      KAIHE_3M
	DB	026H,0E8H	;-6106(E826)  	;STOP1DATA
	DB	034H,0FEH	; -460(FE34)    ;DW3MM_DATA
	DB	0E9H,0FFH	;  -23(FFE9)  	;KAKOU_END:
SUUTI4ROMD:
SUUTI5ROMD:
SUUTI6ROMD:
SUUTI7ROMD:
SUUTI8ROMD:
	DB	03CH,000H	;0.03  = 60   	KAKOU_RYOU
	DB	001H,000H	;0.0005mm     	KIRI_RYOU
	DB	001H,000H	;;1	     	KIRI_KAI
	DB	00AH,000H	;;10          	SP_OUT_KAI
	DB	03CH,000H	;;60=3CH	EARCUT_D
        DB      090H,001H	;;0.2mm=400	OBERRUN_D
	DB	005H,000H	;;0.0005	STM_P_MM
	DB	0B1H,000H	;;177=0B1H      SOFT_UD_P
	DB	070H,017H	;;3mm=6000      KAIHE_3M
	DB	026H,0E8H	;-6106(E826)  	;STOP1DATA
	DB	034H,0FEH	; -460(FE34)    ;DW3MM_DATA
	DB	05DH,0FFH	; -163(FF5D)  	;KAKOU_END:
;
STM_P_MM:
	DB	005H,000H	;;0.0005	STM_P_MM
SOFT_UD_P:
	DB	0B1H,000H	;;177=0B1H      SOFT_UD_P
KAIHI_3M:
	DB	070H,017H	;;3mm=6000      KAIHE_3M
	org	START_ADDRESS + 2000H
UP350D:
UP300D:
  db  255,0    ;8160,0.00816 ,1,0
  db  80,0    ;2560,0.01072 ,2,1
  db  60,0    ;1920,0.01264 ,3,2
  db  50,0    ;1600,0.01424 ,4,3
  db  44,0    ;1408,0.01565 ,5,4
  db  33,0    ;1056,0.01670 ,6,5
  db  30,0    ;960,0.01766 ,7,6
  db  28,0    ;896,0.01856 ,8,7
  db  26,0    ;832,0.01939 ,9,8
  db  25,0    ;800,0.02019 ,10,9
  db  23,0    ;736,0.02093 ,11,A
  db  22,0    ;704,0.02163 ,12,B
  db  21,0    ;672,0.02230 ,13,C
  db  20,0    ;640,0.02294 ,14,D
  db  20,0    ;640,0.02358 ,15,E
  db  19,0    ;608,0.02419 ,16,F
  db  18,0    ;576,0.02477 ,17,10
  db  18,0    ;576,0.02534 ,18,11
  db  17,0    ;544,0.02589 ,19,12
  db  17,0    ;544,0.02643 ,20,13
  db  16,0    ;512,0.02694 ,21,14
  db  0,253    ;506,0.02745 ,22,15
  db  0,246    ;492,0.02794 ,23,16
  db  0,240    ;480,0.02842 ,24,17
  db  0,235    ;470,0.02889 ,25,18
  db  0,230    ;460,0.02935 ,26,19
  db  0,225    ;450,0.02980 ,27,1A
  db  0,220    ;440,0.03024 ,28,1B
  db  0,216    ;432,0.03067 ,29,1C
  db  0,211    ;422,0.03110 ,30,1D
  db  0,207    ;414,0.03151 ,31,1E
  db  0,204    ;408,0.03192 ,32,1F
  db  0,200    ;400,0.03232 ,33,20
  db  0,197    ;394,0.03271 ,34,21
  db  0,193    ;386,0.03310 ,35,22
  db  0,190    ;380,0.03348 ,36,23
  db  0,187    ;374,0.03385 ,37,24
  db  0,184    ;368,0.03422 ,38,25
  db  0,181    ;362,0.03458 ,39,26
  db  0,179    ;358,0.03494 ,40,27
  db  0,176    ;352,0.03529 ,41,28
  db  0,174    ;348,0.03564 ,42,29
  db  0,171    ;342,0.03598 ,43,2A
  db  0,169    ;338,0.03632 ,44,2B
  db  0,167    ;334,0.03665 ,45,2C
  db  0,164    ;328,0.03698 ,46,2D
  db  0,162    ;324,0.03731 ,47,2E
  db  0,160    ;320,0.03763 ,48,2F
  db  0,158    ;316,0.03794 ,49,30
  db  0,156    ;312,0.03825 ,50,31
  db  0,154    ;308,0.03856 ,51,32
  db  0,153    ;306,0.03887 ,52,33
  db  0,151    ;302,0.03917 ,53,34
  db  0,149    ;298,0.03947 ,54,35
  db  0,148    ;296,0.03976 ,55,36
  db  0,146    ;292,0.04006 ,56,37
  db  0,144    ;288,0.04034 ,57,38
  db  0,143    ;286,0.04063 ,58,39
  db  0,141    ;282,0.04091 ,59,3A
  db  0,140    ;280,0.04119 ,60,3B
  db  0,139    ;278,0.04147 ,61,3C
  db  0,137    ;274,0.04174 ,62,3D
  db  0,136    ;272,0.04202 ,63,3E
  db  0,135    ;270,0.04229 ,64,3F
  db  0,133    ;266,0.04255 ,65,40
  db  0,132    ;264,0.04282 ,66,41
  db  0,131    ;262,0.04308 ,67,42
  db  0,130    ;260,0.04334 ,68,43
  db  0,128    ;256,0.04359 ,69,44
  db  0,127    ;254,0.04385 ,70,45
  db  0,126    ;252,0.04410 ,71,46
  db  0,125    ;250,0.04435 ,72,47
  db  0,124    ;248,0.04460 ,73,48
  db  0,123    ;246,0.04484 ,74,49
  db  0,122    ;244,0.04509 ,75,4A
  db  0,121    ;242,0.04533 ,76,4B
  db  0,120    ;240,0.04557 ,77,4C
  db  0,119    ;238,0.04581 ,78,4D
  db  0,118    ;236,0.04604 ,79,4E
  db  0,117    ;234,0.04628 ,80,4F
  db  0,116    ;232,0.04651 ,81,50
  db  0,115    ;230,0.04674 ,82,51
  db  0,114    ;228,0.04697 ,83,52
  db  0,113    ;226,0.04719 ,84,53
  db  0,113    ;226,0.04742 ,85,54
  db  0,112    ;224,0.04764 ,86,55
  db  0,111    ;222,0.04787 ,87,56
  db  0,110    ;220,0.04809 ,88,57
  db  0,109    ;218,0.04830 ,89,58
  db  0,109    ;218,0.04852 ,90,59
  db  0,108    ;216,0.04874 ,91,5A
  db  0,107    ;214,0.04895 ,92,5B
  db  0,106    ;212,0.04916 ,93,5C
  db  0,106    ;212,0.04938 ,94,5D
  db  0,105    ;210,0.04959 ,95,5E
  db  0,104    ;208,0.04979 ,96,5F
  db  0,103    ;206,0.05000 ,97,60
  db  0,103    ;206,0.05021 ,98,61
  db  0,102    ;204,0.05041 ,99,62
  db  0,101    ;202,0.05061 ,100,63
  db  0,101    ;202,0.05081 ,101,64
  db  0,100    ;200,0.05101 ,102,65
  db  0,99    ;198,0.05121 ,103,66
  db  0,99    ;198,0.05141 ,104,67
  db  0,98    ;196,0.05161 ,105,68
  db  0,98    ;196,0.05180 ,106,69
  db  0,97    ;194,0.05200 ,107,6A
  db  0,96    ;192,0.05219 ,108,6B
  db  0,96    ;192,0.05238 ,109,6C
  db  0,95    ;190,0.05257 ,110,6D
  db  0,95    ;190,0.05276 ,111,6E
  db  0,94    ;188,0.05295 ,112,6F
  db  0,94    ;188,0.05314 ,113,70
  db  0,93    ;186,0.05332 ,114,71
  db  0,93    ;186,0.05351 ,115,72
  db  0,92    ;184,0.05369 ,116,73
  db  0,91    ;182,0.05387 ,117,74
  db  0,91    ;182,0.05406 ,118,75
  db  0,90    ;180,0.05424 ,119,76
  db  0,90    ;180,0.05442 ,120,77
  db  0,89    ;178,0.05459 ,121,78
  db  0,89    ;178,0.05477 ,122,79
  db  0,88    ;176,0.05495 ,123,7A
  db  0,88    ;176,0.05512 ,124,7B
  db  0,87    ;174,0.05530 ,125,7C
  db  0,87    ;174,0.05547 ,126,7D
  db  0,87    ;174,0.05565 ,127,7E
  db  0,86    ;172,0.05582 ,128,7F
  db  0,86    ;172,0.05599 ,129,80
  db  0,85    ;170,0.05616 ,130,81
  db  0,85    ;170,0.05633 ,131,82
  db  0,84    ;168,0.05650 ,132,83
  db  0,84    ;168,0.05667 ,133,84
  db  0,83    ;166,0.05683 ,134,85
  db  0,83    ;166,0.05700 ,135,86
  db  0,83    ;166,0.05716 ,136,87
  db  0,82    ;164,0.05733 ,137,88
  db  0,82    ;164,0.05749 ,138,89
  db  0,81    ;162,0.05765 ,139,8A
  db  0,81    ;162,0.05782 ,140,8B
  db  0,81    ;162,0.05798 ,141,8C
  db  0,80    ;160,0.05814 ,142,8D
  db  0,80    ;160,0.05830 ,143,8E
  db  0,79    ;158,0.05846 ,144,8F
  db  0,79    ;158,0.05861 ,145,90
  db  0,79    ;158,0.05877 ,146,91
  db  0,78    ;156,0.05893 ,147,92
  db  0,78    ;156,0.05908 ,148,93
  db  0,78    ;156,0.05924 ,149,94
  db  0,77    ;154,0.05939 ,150,95
  db  0,77    ;154,0.05955 ,151,96
  db  0,77    ;154,0.05970 ,152,97
  db  0,76    ;152,0.05985 ,153,98
  db  0,76    ;152,0.06001 ,154,99
  db  0,75    ;150,0.06016 ,155,9A
  db  0,75    ;150,0.06031 ,156,9B
  db  0,75    ;150,0.06046 ,157,9C
  db  0,74    ;148,0.06060 ,158,9D
  db  0,74    ;148,0.06075 ,159,9E
  db  0,74    ;148,0.06090 ,160,9F
  db  0,73    ;146,0.06105 ,161,A0
  db  0,73    ;146,0.06119 ,162,A1
  db  0,73    ;146,0.06134 ,163,A2
  db  0,73    ;146,0.06148 ,164,A3
  db  0,72    ;144,0.06163 ,165,A4
  db  0,72    ;144,0.06177 ,166,A5
  db  0,72    ;144,0.06192 ,167,A6
  db  0,71    ;142,0.06206 ,168,A7
  db  0,71    ;142,0.06220 ,169,A8
  db  0,71    ;142,0.06234 ,170,A9
  db  0,70    ;140,0.06248 ,171,AA
  db  0,70    ;140,0.06262 ,172,AB
  db  0,70    ;140,0.06276 ,173,AC
  db  0,70    ;140,0.06290 ,174,AD
  db  0,69    ;138,0.06304 ,175,AE
  db  0,69    ;138,0.06318 ,176,AF
  db  0,69    ;138,0.06332 ,177,B0
  db  0,68    ;136,0.06345 ,178,B1
  db  0,68    ;136,0.06359 ,179,B2
  db  0,68    ;136,0.06372 ,180,B3
  db  0,68    ;136,0.06386 ,181,B4
  db  0,67    ;134,0.06399 ,182,B5
  db  0,67    ;134,0.06413 ,183,B6
  db  0,67    ;134,0.06426 ,184,B7
  db  0,67    ;134,0.06440 ,185,B8
  db  0,66    ;132,0.06453 ,186,B9
  db  0,66    ;132,0.06466 ,187,BA
  db  0,66    ;132,0.06479 ,188,BB
  db  0,65    ;130,0.06492 ,189,BC
  db  0,65    ;130,0.06505 ,190,BD
  db  0,65    ;130,0.06518 ,191,BE
  db  0,65    ;130,0.06531 ,192,BF
  db  0,64    ;128,0.06544 ,193,C0
  db  0,64    ;128,0.06557 ,194,C1
  db  0,64    ;128,0.06570 ,195,C2
  db  0,64    ;128,0.06582 ,196,C3
  db  0,64    ;128,0.06595 ,197,C4
  db  0,63    ;126,0.06608 ,198,C5
  db  0,63    ;126,0.06620 ,199,C6
  db  0,63    ;126,0.06633 ,200,C7
  db  0,63    ;126,0.06646 ,201,C8
  db  0,62    ;124,0.06658 ,202,C9
  db  0,62    ;124,0.06670 ,203,CA
  db  0,62    ;124,0.06683 ,204,CB
  db  0,62    ;124,0.06695 ,205,CC
  db  0,61    ;122,0.06707 ,206,CD
  db  0,61    ;122,0.06720 ,207,CE
  db  0,61    ;122,0.06732 ,208,CF
  db  0,61    ;122,0.06744 ,209,D0
  db  0,61    ;122,0.06756 ,210,D1
  db  0,60    ;120,0.06768 ,211,D2
  db  0,60    ;120,0.06780 ,212,D3
  db  0,60    ;120,0.06792 ,213,D4
  db  0,60    ;120,0.06804 ,214,D5
  db  0,60    ;120,0.06816 ,215,D6
  db  0,59    ;118,0.06828 ,216,D7
  db  0,59    ;118,0.06840 ,217,D8
  db  0,59    ;118,0.06852 ,218,D9
  db  0,59    ;118,0.06863 ,219,DA
  db  0,58    ;116,0.06875 ,220,DB
  db  0,58    ;116,0.06887 ,221,DC
  db  0,58    ;116,0.06898 ,222,DD
  db  0,58    ;116,0.06910 ,223,DE
  db  0,58    ;116,0.06921 ,224,DF
  db  0,57    ;114,0.06933 ,225,E0
  db  0,57    ;114,0.06944 ,226,E1
  db  0,57    ;114,0.06956 ,227,E2
  db  0,57    ;114,0.06967 ,228,E3
  db  0,57    ;114,0.06978 ,229,E4
  db  0,57    ;114,0.06990 ,230,E5
  db  0,56    ;112,0.07001 ,231,E6
  db  0,56    ;112,0.07012 ,232,E7
  db  0,56    ;112,0.07023 ,233,E8
  db  0,56    ;112,0.07035 ,234,E9
  db  0,56    ;112,0.07046 ,235,EA
  db  0,55    ;110,0.07057 ,236,EB
  db  0,55    ;110,0.07068 ,237,EC
  db  0,55    ;110,0.07079 ,238,ED
  db  0,55    ;110,0.07090 ,239,EE
  db  0,55    ;110,0.07101 ,240,EF
  db  0,55    ;110,0.07112 ,241,F0
  db  0,54    ;108,0.07123 ,242,F1
  db  0,54    ;108,0.07133 ,243,F2
  db  0,54    ;108,0.07144 ,244,F3
  db  0,54    ;108,0.07155 ,245,F4
  db  0,54    ;108,0.07166 ,246,F5
  db  0,54    ;108,0.07177 ,247,F6
  db  0,53    ;106,0.07187 ,248,F7
  db  0,53    ;106,0.07198 ,249,F8
  db  0,53    ;106,0.07208 ,250,F9
  db  0,53    ;106,0.07219 ,251,FA
  db  0,53    ;106,0.07230 ,252,FB
  db  0,53    ;106,0.07240 ,253,FC
  db  0,52    ;104,0.07251 ,254,FD
  db  0,52    ;104,0.07261 ,255,FE
  db  0,52    ;104,0.07271 ,256,FF
  db  0,52    ;104,0.07282 ,257,100
  db  0,52    ;104,0.07292 ,258,101
  db  0,52    ;104,0.07303 ,259,102
  db  0,51    ;102,0.07313 ,260,103
  db  0,51    ;102,0.07323 ,261,104
  db  0,51    ;102,0.07333 ,262,105
  db  0,51    ;102,0.07343 ,263,106
  db  0,51    ;102,0.07354 ,264,107
  db  0,51    ;102,0.07364 ,265,108
  db  0,50    ;100,0.07374 ,266,109
  db  0,50    ;100,0.07384 ,267,10A
  db  0,50    ;100,0.07394 ,268,10B
  db  0,50    ;100,0.07404 ,269,10C
  db  0,50    ;100,0.07414 ,270,10D
  db  0,50    ;100,0.07424 ,271,10E
  db  0,50    ;100,0.07434 ,272,10F
  db  0,49    ;98,0.07444 ,273,110
  db  0,49    ;98,0.07453 ,274,111
  db  0,49    ;98,0.07463 ,275,112
  db  0,49    ;98,0.07473 ,276,113
  db  0,49    ;98,0.07483 ,277,114
  db  0,49    ;98,0.07493 ,278,115
  db  0,49    ;98,0.07502 ,279,116
  db  0,48    ;96,0.07512 ,280,117
  db  0,48    ;96,0.07522 ,281,118
  db  0,48    ;96,0.07531 ,282,119
  db  0,48    ;96,0.07541 ,283,11A
  db  0,48    ;96,0.07550 ,284,11B
  db  0,48    ;96,0.07560 ,285,11C
  db  0,48    ;96,0.07570 ,286,11D
  db  0,47    ;94,0.07579 ,287,11E
  db  0,47    ;94,0.07588 ,288,11F
  db  0,47    ;94,0.07598 ,289,120
  db  0,47    ;94,0.07607 ,290,121
  db  0,47    ;94,0.07617 ,291,122
  db  0,47    ;94,0.07626 ,292,123
  db  0,47    ;94,0.07635 ,293,124
  db  0,47    ;94,0.07645 ,294,125
  db  0,46    ;92,0.07654 ,295,126
  db  0,46    ;92,0.07663 ,296,127
  db  0,46    ;92,0.07672 ,297,128
  db  0,46    ;92,0.07682 ,298,129
  db  0,46    ;92,0.07691 ,299,12A
  db  0,46    ;92,0.07700 ,300,12B
  db  0,46    ;92,0.07709 ,301,12C
  db  0,46    ;92,0.07718 ,302,12D
  db  0,45    ;90,0.07727 ,303,12E
  db  0,45    ;90,0.07736 ,304,12F
  db  0,45    ;90,0.07745 ,305,130
  db  0,45    ;90,0.07754 ,306,131
  db  0,45    ;90,0.07763 ,307,132
  db  0,45    ;90,0.07772 ,308,133
  db  0,45    ;90,0.07781 ,309,134
  db  0,45    ;90,0.07790 ,310,135
  db  0,44    ;88,0.07799 ,311,136
  db  0,44    ;88,0.07808 ,312,137
  db  0,44    ;88,0.07817 ,313,138
  db  0,44    ;88,0.07826 ,314,139
  db  0,44    ;88,0.07834 ,315,13A
  db  0,44    ;88,0.07843 ,316,13B
  db  0,44    ;88,0.07852 ,317,13C
  db  0,44    ;88,0.07861 ,318,13D
  db  0,43    ;86,0.07869 ,319,13E
  db  0,43    ;86,0.07878 ,320,13F
  db  0,43    ;86,0.07887 ,321,140
  db  0,43    ;86,0.07895 ,322,141
  db  0,43    ;86,0.07904 ,323,142
  db  0,43    ;86,0.07912 ,324,143
  db  0,43    ;86,0.07921 ,325,144
  db  0,43    ;86,0.07930 ,326,145
  db  0,43    ;86,0.07938 ,327,146
  db  0,42    ;84,0.07947 ,328,147
  db  0,42    ;84,0.07955 ,329,148
  db  0,42    ;84,0.07963 ,330,149
  db  0,42    ;84,0.07972 ,331,14A
  db  0,42    ;84,0.07980 ,332,14B
  db  0,42    ;84,0.07989 ,333,14C
  db  0,42    ;84,0.07997 ,334,14D
  db  0,42    ;84,0.08005 ,335,14E
  db  0,42    ;84,0.08014 ,336,14F
  db  0,41    ;82,0.08022 ,337,150
  db  0,41    ;82,0.08030 ,338,151
  db  0,41    ;82,0.08038 ,339,152
  db  0,41    ;82,0.08047 ,340,153
  db  0,41    ;82,0.08055 ,341,154
  db  0,41    ;82,0.08063 ,342,155
  db  0,41    ;82,0.08071 ,343,156
  db  0,41    ;82,0.08079 ,344,157
  db  0,41    ;82,0.08088 ,345,158
  db  0,41    ;82,0.08096 ,346,159
  db  0,40    ;80,0.08104 ,347,15A
  db  0,40    ;80,0.08112 ,348,15B
  db  0,40    ;80,0.08120 ,349,15C
  db  0,40    ;80,0.08128 ,350,15D
  db  0,40    ;80,0.08136 ,351,15E
  db  0,40    ;80,0.08144 ,352,15F
  db  0,40    ;80,0.08152 ,353,160
  db  0,40    ;80,0.08160 ,354,161
  db  0,40    ;80,0.08168 ,355,162
  db  0,40    ;80,0.08176 ,356,163
  db  0,39    ;78,0.08184 ,357,164
  db  0,39    ;78,0.08191 ,358,165
  db  0,39    ;78,0.08199 ,359,166
  db  0,39    ;78,0.08207 ,360,167
  db  0,39    ;78,0.08215 ,361,168
  db  0,39    ;78,0.08223 ,362,169
  db  0,39    ;78,0.08230 ,363,16A
  db  0,39    ;78,0.08238 ,364,16B
  db  0,39    ;78,0.08246 ,365,16C
  db  0,39    ;78,0.08254 ,366,16D
  db  0,38    ;76,0.08261 ,367,16E
  db  0,38    ;76,0.08269 ,368,16F
  db  0,38    ;76,0.08277 ,369,170
  db  0,38    ;76,0.08284 ,370,171
  db  0,38    ;76,0.08292 ,371,172
  db  0,38    ;76,0.08299 ,372,173
  db  0,38    ;76,0.08307 ,373,174
  db  0,38    ;76,0.08315 ,374,175
  db  0,38    ;76,0.08322 ,375,176
  db  0,38    ;76,0.08330 ,376,177
  db  0,38    ;76,0.08337 ,377,178
  db  0,37    ;74,0.08345 ,378,179
  db  0,37    ;74,0.08352 ,379,17A
  db  0,37    ;74,0.08360 ,380,17B
  db  0,37    ;74,0.08367 ,381,17C
  db  0,37    ;74,0.08374 ,382,17D
  db  0,37    ;74,0.08382 ,383,17E
  db  0,37    ;74,0.08389 ,384,17F
  db  0,37    ;74,0.08397 ,385,180
  db  0,37    ;74,0.08404 ,386,181
  db  0,37    ;74,0.08411 ,387,182
  db  0,37    ;74,0.08419 ,388,183
  db  0,37    ;74,0.08426 ,389,184
  db  0,36    ;72,0.08433 ,390,185
  db  0,36    ;72,0.08441 ,391,186
  db  0,36    ;72,0.08448 ,392,187
  db  0,36    ;72,0.08455 ,393,188
  db  0,36    ;72,0.08462 ,394,189
  db  0,36    ;72,0.08469 ,395,18A
  db  0,36    ;72,0.08477 ,396,18B
  db  0,36    ;72,0.08484 ,397,18C
  db  0,36    ;72,0.08491 ,398,18D
  db  0,36    ;72,0.08498 ,399,18E
  db  0,36    ;72,0.08505 ,400,18F
  db  0,36    ;72,0.08513 ,401,190
  db  0,35    ;70,0.08520 ,402,191
  db  0,35    ;70,0.08527 ,403,192
  db  0,35    ;70,0.08534 ,404,193
  db  0,35    ;70,0.08541 ,405,194
  db  0,35    ;70,0.08548 ,406,195
  db  0,35    ;70,0.08555 ,407,196
  db  0,35    ;70,0.08562 ,408,197
  db  0,35    ;70,0.08569 ,409,198
  db  0,35    ;70,0.08576 ,410,199
  db  0,35    ;70,0.08583 ,411,19A
  db  0,35    ;70,0.08590 ,412,19B
  db  0,35    ;70,0.08597 ,413,19C
  db  0,34    ;68,0.08603 ,414,19D
  db  0,34    ;68,0.08610 ,415,19E
  db  0,34    ;68,0.08617 ,416,19F
  db  0,34    ;68,0.08624 ,417,1A0
  db  0,34    ;68,0.08631 ,418,1A1
  db  0,34    ;68,0.08637 ,419,1A2
  db  0,34    ;68,0.08644 ,420,1A3
  db  0,34    ;68,0.08651 ,421,1A4
  db  0,34    ;68,0.08658 ,422,1A5
  db  0,34    ;68,0.08665 ,423,1A6
  db  0,34    ;68,0.08671 ,424,1A7
  db  0,34    ;68,0.08678 ,425,1A8
  db  0,34    ;68,0.08685 ,426,1A9
  db  0,33    ;66,0.08692 ,427,1AA
  db  0,33    ;66,0.08698 ,428,1AB
  db  0,33    ;66,0.08705 ,429,1AC
  db  0,33    ;66,0.08711 ,430,1AD
  db  0,33    ;66,0.08718 ,431,1AE
  db  0,33    ;66,0.08725 ,432,1AF
  db  0,33    ;66,0.08731 ,433,1B0
  db  0,33    ;66,0.08738 ,434,1B1
  db  0,33    ;66,0.08744 ,435,1B2
  db  0,33    ;66,0.08751 ,436,1B3
  db  0,33    ;66,0.08758 ,437,1B4
  db  0,33    ;66,0.08764 ,438,1B5
  db  0,33    ;66,0.08771 ,439,1B6
  db  0,33    ;66,0.08777 ,440,1B7
  db  0,32    ;64,0.08784 ,441,1B8
  db  0,32    ;64,0.08790 ,442,1B9
  db  0,32    ;64,0.08797 ,443,1BA
  db  0,32    ;64,0.08803 ,444,1BB
  db  0,32    ;64,0.08809 ,445,1BC
  db  0,32    ;64,0.08816 ,446,1BD
  db  0,32    ;64,0.08822 ,447,1BE
  db  0,32    ;64,0.08829 ,448,1BF
  db  0,32    ;64,0.08835 ,449,1C0
  db  0,32    ;64,0.08841 ,450,1C1
  db  0,32    ;64,0.08848 ,451,1C2
  db  0,32    ;64,0.08854 ,452,1C3
  db  0,32    ;64,0.08861 ,453,1C4
  db  0,32    ;64,0.08867 ,454,1C5
  db  0,31    ;62,0.08873 ,455,1C6
  db  0,31    ;62,0.08879 ,456,1C7
  db  0,31    ;62,0.08886 ,457,1C8
  db  0,31    ;62,0.08892 ,458,1C9
  db  0,31    ;62,0.08898 ,459,1CA
  db  0,31    ;62,0.08904 ,460,1CB
  db  0,31    ;62,0.08910 ,461,1CC
  db  0,31    ;62,0.08917 ,462,1CD
  db  0,31    ;62,0.08923 ,463,1CE
  db  0,31    ;62,0.08929 ,464,1CF
  db  0,31    ;62,0.08935 ,465,1D0
  db  0,31    ;62,0.08941 ,466,1D1
  db  0,31    ;62,0.08948 ,467,1D2
  db  0,31    ;62,0.08954 ,468,1D3
  db  0,31    ;62,0.08960 ,469,1D4
  db  0,31    ;62,0.08966 ,470,1D5
  db  0,30    ;60,0.08972 ,471,1D6
  db  0,30    ;60,0.08978 ,472,1D7
  db  0,30    ;60,0.08984 ,473,1D8
  db  0,30    ;60,0.08990 ,474,1D9
  db  0,30    ;60,0.08996 ,475,1DA
  db  0,30    ;60,0.09002 ,476,1DB
  db  0,30    ;60,0.09008 ,477,1DC
  db  0,30    ;60,0.09014 ,478,1DD
  db  0,30    ;60,0.09020 ,479,1DE
  db  0,30    ;60,0.09026 ,480,1DF
  db  0,30    ;60,0.09032 ,481,1E0
  db  0,30    ;60,0.09038 ,482,1E1
  db  0,30    ;60,0.09044 ,483,1E2
  db  0,30    ;60,0.09050 ,484,1E3
  db  0,30    ;60,0.09056 ,485,1E4
  db  0,29    ;58,0.09062 ,486,1E5
  db  0,29    ;58,0.09068 ,487,1E6
  db  0,29    ;58,0.09074 ,488,1E7
  db  0,29    ;58,0.09079 ,489,1E8
  db  0,29    ;58,0.09085 ,490,1E9
  db  0,29    ;58,0.09091 ,491,1EA
  db  0,29    ;58,0.09097 ,492,1EB
  db  0,29    ;58,0.09103 ,493,1EC
  db  0,29    ;58,0.09108 ,494,1ED
  db  0,29    ;58,0.09114 ,495,1EE
  db  0,29    ;58,0.09120 ,496,1EF
  db  0,29    ;58,0.09126 ,497,1F0
  db  0,29    ;58,0.09132 ,498,1F1
  db  0,29    ;58,0.09137 ,499,1F2
  db  0,29    ;58,0.09143 ,500,1F3
  db  0,29    ;58,0.09149 ,501,1F4
  db  0,29    ;58,0.09155 ,502,1F5
  db  0,28    ;56,0.09160 ,503,1F6
  db  0,28    ;56,0.09166 ,504,1F7
  db  0,28    ;56,0.09172 ,505,1F8
  db  0,28    ;56,0.09177 ,506,1F9
  db  0,28    ;56,0.09183 ,507,1FA
  db  0,28    ;56,0.09188 ,508,1FB
  db  0,28    ;56,0.09194 ,509,1FC
  db  0,28    ;56,0.09200 ,510,1FD
  db  0,28    ;56,0.09205 ,511,1FE
  db  0,28    ;56,0.09211 ,512,1FF
  db  0,28    ;56,0.09216 ,513,200
  db  0,28    ;56,0.09222 ,514,201
  db  0,28    ;56,0.09228 ,515,202
  db  0,28    ;56,0.09233 ,516,203
  db  0,28    ;56,0.09239 ,517,204
  db  0,28    ;56,0.09244 ,518,205
  db  0,28    ;56,0.09250 ,519,206
  db  0,28    ;56,0.09256 ,520,207
  db  0,27    ;54,0.09261 ,521,208
  db  0,27    ;54,0.09266 ,522,209
  db  0,27    ;54,0.09272 ,523,20A
  db  0,27    ;54,0.09277 ,524,20B
  db  0,27    ;54,0.09283 ,525,20C
  db  0,27    ;54,0.09288 ,526,20D
  db  0,27    ;54,0.09293 ,527,20E
  db  0,27    ;54,0.09299 ,528,20F
  db  0,27    ;54,0.09304 ,529,210
  db  0,27    ;54,0.09310 ,530,211
  db  0,27    ;54,0.09315 ,531,212
  db  0,27    ;54,0.09320 ,532,213
  db  0,27    ;54,0.09326 ,533,214
  db  0,27    ;54,0.09331 ,534,215
  db  0,27    ;54,0.09337 ,535,216
  db  0,27    ;54,0.09342 ,536,217
  db  0,27    ;54,0.09347 ,537,218
  db  0,27    ;54,0.09353 ,538,219
  db  0,26    ;52,0.09358 ,539,21A
  db  0,26    ;52,0.09363 ,540,21B
  db  0,26    ;52,0.09368 ,541,21C
  db  0,26    ;52,0.09374 ,542,21D
  db  0,26    ;52,0.09379 ,543,21E
  db  0,26    ;52,0.09384 ,544,21F
  db  0,26    ;52,0.09389 ,545,220
  db  0,26    ;52,0.09394 ,546,221
  db  0,26    ;52,0.09400 ,547,222
  db  0,26    ;52,0.09405 ,548,223
  db  0,26    ;52,0.09410 ,549,224
  db  0,26    ;52,0.09415 ,550,225
  db  0,26    ;52,0.09420 ,551,226
  db  0,26    ;52,0.09426 ,552,227
  db  0,26    ;52,0.09431 ,553,228
  db  0,26    ;52,0.09436 ,554,229
  db  0,26    ;52,0.09441 ,555,22A
  db  0,26    ;52,0.09446 ,556,22B
  db  0,26    ;52,0.09452 ,557,22C
  db  0,26    ;52,0.09457 ,558,22D
  db  0,25    ;50,0.09462 ,559,22E
  db  0,25    ;50,0.09467 ,560,22F
  db  0,25    ;50,0.09472 ,561,230
  db  0,25    ;50,0.09477 ,562,231
  db  0,25    ;50,0.09482 ,563,232
  db  0,25    ;50,0.09487 ,564,233
  db  0,25    ;50,0.09492 ,565,234
  db  0,25    ;50,0.09497 ,566,235
  db  0,25    ;50,0.09502 ,567,236
  db  0,25    ;50,0.09507 ,568,237
  db  0,25    ;50,0.09512 ,569,238
  db  0,25    ;50,0.09517 ,570,239
  db  0,25    ;50,0.09522 ,571,23A
  db  0,25    ;50,0.09527 ,572,23B
  db  0,25    ;50,0.09532 ,573,23C
  db  0,25    ;50,0.09537 ,574,23D
  db  0,25    ;50,0.09542 ,575,23E
  db  0,25    ;50,0.09547 ,576,23F
  db  0,25    ;50,0.09552 ,577,240
  db  0,25    ;50,0.09557 ,578,241
  db  0,25    ;50,0.09562 ,579,242
  db  0,24    ;48,0.09567 ,580,243
  db  0,24    ;48,0.09571 ,581,244
  db  0,24    ;48,0.09576 ,582,245
  db  0,24    ;48,0.09581 ,583,246
  db  0,24    ;48,0.09586 ,584,247
  db  0,24    ;48,0.09591 ,585,248
  db  0,24    ;48,0.09595 ,586,249
  db  0,24    ;48,0.09600 ,587,24A
  db  0,24    ;48,0.09605 ,588,24B
  db  0,24    ;48,0.09610 ,589,24C
  db  0,24    ;48,0.09615 ,590,24D
  db  0,24    ;48,0.09619 ,591,24E
  db  0,24    ;48,0.09624 ,592,24F
  db  0,24    ;48,0.09629 ,593,250
  db  0,24    ;48,0.09634 ,594,251
  db  0,24    ;48,0.09639 ,595,252
  db  0,24    ;48,0.09643 ,596,253
  db  0,24    ;48,0.09648 ,597,254
  db  0,24    ;48,0.09653 ,598,255
  db  0,24    ;48,0.09658 ,599,256
  db  0,24    ;48,0.09663 ,600,257
  db  0,23    ;46,0.09667 ,601,258
  db  0,23    ;46,0.09672 ,602,259
  db  0,23    ;46,0.09676 ,603,25A
  db  0,23    ;46,0.09681 ,604,25B
  db  0,23    ;46,0.09686 ,605,25C
  db  0,23    ;46,0.09690 ,606,25D
  db  0,23    ;46,0.09695 ,607,25E
  db  0,23    ;46,0.09699 ,608,25F
  db  0,23    ;46,0.09704 ,609,260
  db  0,23    ;46,0.09709 ,610,261
  db  0,23    ;46,0.09713 ,611,262
  db  0,23    ;46,0.09718 ,612,263
  db  0,23    ;46,0.09722 ,613,264
  db  0,23    ;46,0.09727 ,614,265
  db  0,23    ;46,0.09732 ,615,266
  db  0,23    ;46,0.09736 ,616,267
  db  0,23    ;46,0.09741 ,617,268
  db  0,23    ;46,0.09745 ,618,269
  db  0,23    ;46,0.09750 ,619,26A
  db  0,23    ;46,0.09755 ,620,26B
  db  0,23    ;46,0.09759 ,621,26C
  db  0,23    ;46,0.09764 ,622,26D
  db  0,23    ;46,0.09768 ,623,26E
  db  0,23    ;46,0.09773 ,624,26F
  db  0,22    ;44,0.09777 ,625,270
  db  0,22    ;44,0.09782 ,626,271
  db  0,22    ;44,0.09786 ,627,272
  db  0,22    ;44,0.09791 ,628,273
  db  0,22    ;44,0.09795 ,629,274
  db  0,22    ;44,0.09799 ,630,275
  db  0,22    ;44,0.09804 ,631,276
  db  0,22    ;44,0.09808 ,632,277
  db  0,22    ;44,0.09813 ,633,278
  db  0,22    ;44,0.09817 ,634,279
  db  0,22    ;44,0.09821 ,635,27A
  db  0,22    ;44,0.09826 ,636,27B
  db  0,22    ;44,0.09830 ,637,27C
  db  0,22    ;44,0.09835 ,638,27D
  db  0,22    ;44,0.09839 ,639,27E
  db  0,22    ;44,0.09843 ,640,27F
  db  0,22    ;44,0.09848 ,641,280
  db  0,22    ;44,0.09852 ,642,281
  db  0,22    ;44,0.09857 ,643,282
  db  0,22    ;44,0.09861 ,644,283
  db  0,22    ;44,0.09865 ,645,284
  db  0,22    ;44,0.09870 ,646,285
  db  0,22    ;44,0.09874 ,647,286
  db  0,22    ;44,0.09879 ,648,287
  db  0,21    ;42,0.09883 ,649,288
  db  0,21    ;42,0.09887 ,650,289
  db  0,21    ;42,0.09891 ,651,28A
  db  0,21    ;42,0.09895 ,652,28B
  db  0,21    ;42,0.09900 ,653,28C
  db  0,21    ;42,0.09904 ,654,28D
  db  0,21    ;42,0.09908 ,655,28E
  db  0,21    ;42,0.09912 ,656,28F
  db  0,21    ;42,0.09916 ,657,290
  db  0,21    ;42,0.09921 ,658,291
  db  0,21    ;42,0.09925 ,659,292
  db  0,21    ;42,0.09929 ,660,293
  db  0,21    ;42,0.09933 ,661,294
  db  0,21    ;42,0.09937 ,662,295
  db  0,21    ;42,0.09942 ,663,296
  db  0,21    ;42,0.09946 ,664,297
  db  0,21    ;42,0.09950 ,665,298
  db  0,21    ;42,0.09954 ,666,299
  db  0,21    ;42,0.09958 ,667,29A
  db  0,21    ;42,0.09963 ,668,29B
  db  0,21    ;42,0.09967 ,669,29C
  db  0,21    ;42,0.09971 ,670,29D
  db  0,21    ;42,0.09975 ,671,29E
  db  0,21    ;42,0.09979 ,672,29F
  db  0,21    ;42,0.09984 ,673,2A0
  db  0,21    ;42,0.09988 ,674,2A1
  db  0,20    ;40,0.09992 ,675,2A2
  db  0,20    ;40,0.09996 ,676,2A3
  db  0,20    ;40,0.10000 ,677,2A4
  db  0,20    ;40,0.10004 ,678,2A5
  db  0,20    ;40,0.10008 ,679,2A6
  db  0,20    ;40,0.10012 ,680,2A7
  db  0,20    ;40,0.10016 ,681,2A8
  db  0,20    ;40,0.10020 ,682,2A9
  db  0,20    ;40,0.10024 ,683,2AA
  db  0,20    ;40,0.10028 ,684,2AB
  db  0,20    ;40,0.10032 ,685,2AC
  db  0,20    ;40,0.10036 ,686,2AD
  db  0,20    ;40,0.10040 ,687,2AE
  db  0,20    ;40,0.10044 ,688,2AF
  db  0,20    ;40,0.10048 ,689,2B0
  db  0,20    ;40,0.10052 ,690,2B1
  db  0,20    ;40,0.10056 ,691,2B2
  db  0,20    ;40,0.10060 ,692,2B3
  db  0,20    ;40,0.10064 ,693,2B4
  db  0,20    ;40,0.10068 ,694,2B5
  db  0,20    ;40,0.10072 ,695,2B6
  db  0,20    ;40,0.10076 ,696,2B7
  db  0,20    ;40,0.10080 ,697,2B8
  db  0,20    ;40,0.10084 ,698,2B9
  db  0,20    ;40,0.10088 ,699,2BA
  db  0,20    ;40,0.10092 ,700,2BB
  db  0,20    ;40,0.10096 ,701,2BC
  db  0,19    ;38,0.10100 ,702,2BD
  db  0,19    ;38,0.10103 ,703,2BE
  db  0,19    ;38,0.10107 ,704,2BF
  db  0,19    ;38,0.10111 ,705,2C0
  db  0,19    ;38,0.10115 ,706,2C1
  db  0,19    ;38,0.10119 ,707,2C2
  db  0,19    ;38,0.10122 ,708,2C3
  db  0,19    ;38,0.10126 ,709,2C4
  db  0,19    ;38,0.10130 ,710,2C5
  db  0,19    ;38,0.10134 ,711,2C6
  db  0,19    ;38,0.10138 ,712,2C7
  db  0,19    ;38,0.10141 ,713,2C8
  db  0,19    ;38,0.10145 ,714,2C9
  db  0,19    ;38,0.10149 ,715,2CA
  db  0,19    ;38,0.10153 ,716,2CB
  db  0,19    ;38,0.10157 ,717,2CC
  db  0,19    ;38,0.10160 ,718,2CD
  db  0,19    ;38,0.10164 ,719,2CE
  db  0,19    ;38,0.10168 ,720,2CF
  db  0,19    ;38,0.10172 ,721,2D0
  db  0,19    ;38,0.10176 ,722,2D1
  db  0,19    ;38,0.10179 ,723,2D2
  db  0,19    ;38,0.10183 ,724,2D3
  db  0,19    ;38,0.10187 ,725,2D4
  db  0,19    ;38,0.10191 ,726,2D5
  db  0,19    ;38,0.10195 ,727,2D6
  db  0,19    ;38,0.10198 ,728,2D7
  db  0,19    ;38,0.10202 ,729,2D8
  db  0,19    ;38,0.10206 ,730,2D9
  db  0,19    ;38,0.10210 ,731,2DA
  db  0,18    ;36,0.10213 ,732,2DB
  db  0,18    ;36,0.10217 ,733,2DC
  db  0,18    ;36,0.10221 ,734,2DD
  db  0,18    ;36,0.10224 ,735,2DE
  db  0,18    ;36,0.10228 ,736,2DF
  db  0,18    ;36,0.10231 ,737,2E0
  db  0,18    ;36,0.10235 ,738,2E1
  db  0,18    ;36,0.10239 ,739,2E2
  db  0,18    ;36,0.10242 ,740,2E3
  db  0,18    ;36,0.10246 ,741,2E4
  db  0,18    ;36,0.10249 ,742,2E5
  db  0,18    ;36,0.10253 ,743,2E6
  db  0,18    ;36,0.10257 ,744,2E7
  db  0,18    ;36,0.10260 ,745,2E8
  db  0,18    ;36,0.10264 ,746,2E9
  db  0,18    ;36,0.10267 ,747,2EA
  db  0,18    ;36,0.10271 ,748,2EB
  db  0,18    ;36,0.10275 ,749,2EC
  db  0,18    ;36,0.10278 ,750,2ED
  db  0,18    ;36,0.10282 ,751,2EE
  db  0,18    ;36,0.10285 ,752,2EF
  db  0,18    ;36,0.10289 ,753,2F0
  db  0,18    ;36,0.10293 ,754,2F1
  db  0,18    ;36,0.10296 ,755,2F2
  db  0,18    ;36,0.10300 ,756,2F3
  db  0,18    ;36,0.10303 ,757,2F4
  db  0,18    ;36,0.10307 ,758,2F5
  db  0,18    ;36,0.10311 ,759,2F6
  db  0,18    ;36,0.10314 ,760,2F7
  db  0,18    ;36,0.10318 ,761,2F8
  db  0,18    ;36,0.10321 ,762,2F9
  db  0,17    ;34,0.10325 ,763,2FA
  db  0,17    ;34,0.10328 ,764,2FB
  db  0,17    ;34,0.10332 ,765,2FC
  db  0,17    ;34,0.10335 ,766,2FD
  db  0,17    ;34,0.10338 ,767,2FE
  db  0,17    ;34,0.10342 ,768,2FF
  db  0,17    ;34,0.10345 ,769,300
  db  0,17    ;34,0.10349 ,770,301
  db  0,17    ;34,0.10352 ,771,302
  db  0,17    ;34,0.10355 ,772,303
  db  0,17    ;34,0.10359 ,773,304
  db  0,17    ;34,0.10362 ,774,305
  db  0,17    ;34,0.10366 ,775,306
  db  0,17    ;34,0.10369 ,776,307
  db  0,17    ;34,0.10372 ,777,308
  db  0,17    ;34,0.10376 ,778,309
  db  0,17    ;34,0.10379 ,779,30A
  db  0,17    ;34,0.10383 ,780,30B
  db  0,17    ;34,0.10386 ,781,30C
  db  0,17    ;34,0.10389 ,782,30D
  db  0,17    ;34,0.10393 ,783,30E
  db  0,17    ;34,0.10396 ,784,30F
  db  0,17    ;34,0.10400 ,785,310
  db  0,17    ;34,0.10403 ,786,311
  db  0,17    ;34,0.10406 ,787,312
  db  0,17    ;34,0.10410 ,788,313
  db  0,17    ;34,0.10413 ,789,314
  db  0,17    ;34,0.10417 ,790,315
  db  0,17    ;34,0.10420 ,791,316
  db  0,17    ;34,0.10423 ,792,317
  db  0,17    ;34,0.10427 ,793,318
  db  0,17    ;34,0.10430 ,794,319
  db  0,17    ;34,0.10434 ,795,31A
  db  0,16    ;32,0.10437 ,796,31B
  db  0,16    ;32,0.10440 ,797,31C
  db  0,16    ;32,0.10443 ,798,31D
  db  0,16    ;32,0.10446 ,799,31E
  db  0,16    ;32,0.10450 ,800,31F
  db  0,16    ;32,0.10453 ,801,320
  db  0,16    ;32,0.10456 ,802,321
  db  0,16    ;32,0.10459 ,803,322
  db  0,16    ;32,0.10462 ,804,323
  db  0,16    ;32,0.10466 ,805,324
  db  0,16    ;32,0.10469 ,806,325
  db  0,16    ;32,0.10472 ,807,326
  db  0,16    ;32,0.10475 ,808,327
  db  0,16    ;32,0.10478 ,809,328
  db  0,16    ;32,0.10482 ,810,329
  db  0,16    ;32,0.10485 ,811,32A
  db  0,16    ;32,0.10488 ,812,32B
  db  0,16    ;32,0.10491 ,813,32C
  db  0,16    ;32,0.10494 ,814,32D
  db  0,16    ;32,0.10498 ,815,32E
  db  0,16    ;32,0.10501 ,816,32F
  db  0,16    ;32,0.10504 ,817,330
  db  0,16    ;32,0.10507 ,818,331
  db  0,16    ;32,0.10510 ,819,332
  db  0,16    ;32,0.10514 ,820,333
  db  0,16    ;32,0.10517 ,821,334
  db  0,16    ;32,0.10520 ,822,335
  db  0,16    ;32,0.10523 ,823,336
  db  0,16    ;32,0.10526 ,824,337
  db  0,16    ;32,0.10530 ,825,338
  db  0,16    ;32,0.10533 ,826,339
  db  0,16    ;32,0.10536 ,827,33A
  db  0,16    ;32,0.10539 ,828,33B
  db  0,16    ;32,0.10542 ,829,33C
  db  0,16    ;32,0.10546 ,830,33D
  db  0,15    ;30,0.10549 ,831,33E
  db  0,15    ;30,0.10552 ,832,33F
  db  0,15    ;30,0.10555 ,833,340
  db  0,15    ;30,0.10558 ,834,341
  db  0,15    ;30,0.10561 ,835,342
  db  0,15    ;30,0.10564 ,836,343
  db  0,15    ;30,0.10567 ,837,344
  db  0,15    ;30,0.10570 ,838,345
  db  0,15    ;30,0.10573 ,839,346
  db  0,15    ;30,0.10576 ,840,347
  db  0,15    ;30,0.10579 ,841,348
  db  0,15    ;30,0.10582 ,842,349
  db  0,15    ;30,0.10585 ,843,34A
  db  0,15    ;30,0.10588 ,844,34B
  db  0,15    ;30,0.10591 ,845,34C
  db  0,15    ;30,0.10594 ,846,34D
  db  0,15    ;30,0.10597 ,847,34E
  db  0,15    ;30,0.10600 ,848,34F
  db  0,15    ;30,0.10603 ,849,350
  db  0,15    ;30,0.10606 ,850,351
  db  0,15    ;30,0.10609 ,851,352
  db  0,15    ;30,0.10612 ,852,353
  db  0,15    ;30,0.10615 ,853,354
  db  0,15    ;30,0.10618 ,854,355
  db  0,15    ;30,0.10621 ,855,356
  db  0,15    ;30,0.10624 ,856,357
  db  0,15    ;30,0.10627 ,857,358
  db  0,15    ;30,0.10630 ,858,359
  db  0,15    ;30,0.10633 ,859,35A
  db  0,15    ;30,0.10636 ,860,35B
  db  0,15    ;30,0.10639 ,861,35C
  db  0,15    ;30,0.10642 ,862,35D
  db  0,15    ;30,0.10645 ,863,35E
  db  0,15    ;30,0.10648 ,864,35F
  db  0,15    ;30,0.10651 ,865,360
  db  0,15    ;30,0.10654 ,866,361
  db  0,15    ;30,0.10657 ,867,362
  db  0,15    ;30,0.10660 ,868,363
  db  0,14    ;28,0.10662 ,869,364
  db  0,14    ;28,0.10665 ,870,365
  db  0,14    ;28,0.10668 ,871,366
  db  0,14    ;28,0.10671 ,872,367
  db  0,14    ;28,0.10674 ,873,368
  db  0,14    ;28,0.10676 ,874,369
  db  0,14    ;28,0.10679 ,875,36A
  db  0,14    ;28,0.10682 ,876,36B
  db  0,14    ;28,0.10685 ,877,36C
  db  0,14    ;28,0.10688 ,878,36D
  db  0,14    ;28,0.10690 ,879,36E
  db  0,14    ;28,0.10693 ,880,36F
  db  0,14    ;28,0.10696 ,881,370
  db  0,14    ;28,0.10699 ,882,371
  db  0,14    ;28,0.10702 ,883,372
  db  0,14    ;28,0.10704 ,884,373
  db  0,14    ;28,0.10707 ,885,374
  db  0,14    ;28,0.10710 ,886,375
  db  0,14    ;28,0.10713 ,887,376
  db  0,14    ;28,0.10716 ,888,377
  db  0,14    ;28,0.10718 ,889,378
  db  0,14    ;28,0.10721 ,890,379
  db  0,14    ;28,0.10724 ,891,37A
  db  0,14    ;28,0.10727 ,892,37B
  db  0,14    ;28,0.10730 ,893,37C
  db  0,14    ;28,0.10732 ,894,37D
  db  0,14    ;28,0.10735 ,895,37E
  db  0,14    ;28,0.10738 ,896,37F
  db  0,14    ;28,0.10741 ,897,380
  db  0,14    ;28,0.10744 ,898,381
  db  0,14    ;28,0.10746 ,899,382
  db  0,14    ;28,0.10749 ,900,383
  db  0,14    ;28,0.10752 ,901,384
  db  0,14    ;28,0.10755 ,902,385
  db  0,14    ;28,0.10758 ,903,386
  db  0,14    ;28,0.10760 ,904,387
  db  0,14    ;28,0.10763 ,905,388
  db  0,14    ;28,0.10766 ,906,389
  db  0,14    ;28,0.10769 ,907,38A
  db  0,14    ;28,0.10772 ,908,38B
  db  0,13    ;26,0.10774 ,909,38C
  db  0,13    ;26,0.10777 ,910,38D
  db  0,13    ;26,0.10779 ,911,38E
  db  0,13    ;26,0.10782 ,912,38F
  db  0,13    ;26,0.10785 ,913,390
  db  0,13    ;26,0.10787 ,914,391
  db  0,13    ;26,0.10790 ,915,392
  db  0,13    ;26,0.10792 ,916,393
  db  0,13    ;26,0.10795 ,917,394
  db  0,13    ;26,0.10798 ,918,395
  db  0,13    ;26,0.10800 ,919,396
  db  0,13    ;26,0.10803 ,920,397
  db  0,13    ;26,0.10805 ,921,398
  db  0,13    ;26,0.10808 ,922,399
  db  0,13    ;26,0.10811 ,923,39A
  db  0,13    ;26,0.10813 ,924,39B
  db  0,13    ;26,0.10816 ,925,39C
  db  0,13    ;26,0.10818 ,926,39D
  db  0,13    ;26,0.10821 ,927,39E
  db  0,13    ;26,0.10824 ,928,39F
  db  0,13    ;26,0.10826 ,929,3A0
  db  0,13    ;26,0.10829 ,930,3A1
  db  0,13    ;26,0.10831 ,931,3A2
  db  0,13    ;26,0.10834 ,932,3A3
  db  0,13    ;26,0.10837 ,933,3A4
  db  0,13    ;26,0.10839 ,934,3A5
  db  0,13    ;26,0.10842 ,935,3A6
  db  0,13    ;26,0.10844 ,936,3A7
  db  0,13    ;26,0.10847 ,937,3A8
  db  0,13    ;26,0.10850 ,938,3A9
  db  0,13    ;26,0.10852 ,939,3AA
  db  0,13    ;26,0.10855 ,940,3AB
  db  0,13    ;26,0.10857 ,941,3AC
  db  0,13    ;26,0.10860 ,942,3AD
  db  0,13    ;26,0.10863 ,943,3AE
  db  0,13    ;26,0.10865 ,944,3AF
  db  0,13    ;26,0.10868 ,945,3B0
  db  0,13    ;26,0.10870 ,946,3B1
  db  0,13    ;26,0.10873 ,947,3B2
  db  0,13    ;26,0.10876 ,948,3B3
  db  0,13    ;26,0.10878 ,949,3B4
  db  0,13    ;26,0.10881 ,950,3B5
  db  0,13    ;26,0.10883 ,951,3B6
  db  0,13    ;26,0.10886 ,952,3B7
  db  0,12    ;24,0.10888 ,953,3B8
  db  0,12    ;24,0.10891 ,954,3B9
  db  0,12    ;24,0.10893 ,955,3BA
  db  0,12    ;24,0.10896 ,956,3BB
  db  0,12    ;24,0.10898 ,957,3BC
  db  0,12    ;24,0.10900 ,958,3BD
  db  0,12    ;24,0.10903 ,959,3BE
  db  0,12    ;24,0.10905 ,960,3BF
  db  0,12    ;24,0.10908 ,961,3C0
  db  0,12    ;24,0.10910 ,962,3C1
  db  0,12    ;24,0.10912 ,963,3C2
  db  0,12    ;24,0.10915 ,964,3C3
  db  0,12    ;24,0.10917 ,965,3C4
  db  0,12    ;24,0.10920 ,966,3C5
  db  0,12    ;24,0.10922 ,967,3C6
  db  0,12    ;24,0.10924 ,968,3C7
  db  0,12    ;24,0.10927 ,969,3C8
  db  0,12    ;24,0.10929 ,970,3C9
  db  0,12    ;24,0.10932 ,971,3CA
  db  0,12    ;24,0.10934 ,972,3CB
  db  0,12    ;24,0.10936 ,973,3CC
  db  0,12    ;24,0.10939 ,974,3CD
  db  0,12    ;24,0.10941 ,975,3CE
  db  0,12    ;24,0.10944 ,976,3CF
  db  0,12    ;24,0.10946 ,977,3D0
  db  0,12    ;24,0.10948 ,978,3D1
  db  0,12    ;24,0.10951 ,979,3D2
  db  0,12    ;24,0.10953 ,980,3D3
  db  0,12    ;24,0.10956 ,981,3D4
  db  0,12    ;24,0.10958 ,982,3D5
  db  0,12    ;24,0.10960 ,983,3D6
  db  0,12    ;24,0.10963 ,984,3D7
  db  0,12    ;24,0.10965 ,985,3D8
  db  0,12    ;24,0.10968 ,986,3D9
  db  0,12    ;24,0.10970 ,987,3DA
  db  0,12    ;24,0.10972 ,988,3DB
  db  0,12    ;24,0.10975 ,989,3DC
  db  0,12    ;24,0.10977 ,990,3DD
  db  0,12    ;24,0.10980 ,991,3DE
  db  0,12    ;24,0.10982 ,992,3DF
  db  0,12    ;24,0.10984 ,993,3E0
  db  0,12    ;24,0.10987 ,994,3E1
  db  0,11    ;24,0.10989 ,995,3E2
  db  0,10    ;24,0.10992 ,996,3E3
  db  0,09    ;24,0.10994 ,997,3E4
  db  0,08    ;24,0.10996 ,998,3E5
  db  0,04    ;22,0.10999 ,999,3E6			;2000 5/19 >>> 11>08>04
  db  0,00    ;22,0.11001 ,1000,3E7
  db  0,00    ;22,0.11003 ,1001,3E8
  db  0,00    ;22,0.11005 ,1002,3E9
  db  0,00    ;22,0.11007 ,1003,3EA
  db  0,00    ;22,0.11010 ,1004,3EB
  db  0,00    ;22,0.11012 ,1005,3EC
  db  0,00    ;22,0.11001 ,1000,3E7
  db  0,00    ;22,0.11001 ,1000,3E7
  db  0,00    ;22,0.11001 ,1000,3E7
  db  0,00    ;22,0.11001 ,1000,3E7
  db  0,00    ;22,0.11054 ,1024,3FF
;
	org	START_ADDRESS + 2800H
UP170D:
UP150D:
  db  255,0    ;8160,0.00816,1,0
  db  255,0    ;8160,0.00816,1,0
  db  80,0    ;2560,0.01072,2,1
  db  60,0    ;1920,0.01264,3,2
  db  50,0    ;1600,0.01424,4,3
  db  44,0    ;1408,0.015648,5,4
  db  33,0    ;1056,0.016704,6,5
  db  26,0    ;832,0.017536,7,6
  db  24,0    ;768,0.018304,8,7
  db  22,0    ;704,0.019008,9,8
  db  21,0    ;672,0.01968,10,9
  db  20,0    ;640,0.02032,11,A
  db  19,0    ;608,0.020928,12,B
  db  18,0    ;576,0.021504,13,C
  db  17,0    ;544,0.022048,14,D
  db  16,0    ;512,0.02256,15,E
  db  0,254    ;508,0.023068,16,F
  db  0,245    ;490,0.023558,17,10
  db  0,237    ;474,0.024032,18,11
  db  0,230    ;460,0.024492,19,12
  db  0,223    ;446,0.024938,20,13
  db  0,217    ;434,0.025372,21,14
  db  0,211    ;422,0.025794,22,15
  db  0,206    ;412,0.026206,23,16
  db  0,201    ;402,0.026608,24,17
  db  0,196    ;392,0.027,25,18
  db  0,191    ;382,0.027382,26,19
  db  0,187    ;374,0.027756,27,1A
  db  0,183    ;366,0.028122,28,1B
  db  0,179    ;358,0.02848,29,1C
  db  0,176    ;352,0.028832,30,1D
  db  0,172    ;344,0.029176,31,1E
  db  0,169    ;338,0.029514,32,1F
  db  0,166    ;332,0.029846,33,20
  db  0,163    ;326,0.030172,34,21
  db  0,160    ;320,0.030492,35,22
  db  0,158    ;316,0.030808,36,23
  db  0,155    ;310,0.031118,37,24
  db  0,153    ;306,0.031424,38,25
  db  0,150    ;300,0.031724,39,26
  db  0,148    ;296,0.03202,40,27
  db  0,146    ;292,0.032312,41,28
  db  0,144    ;288,0.0326,42,29
  db  0,142    ;284,0.032884,43,2A
  db  0,140    ;280,0.033164,44,2B
  db  0,138    ;276,0.03344,45,2C
  db  0,136    ;272,0.033712,46,2D
  db  0,134    ;268,0.03398,47,2E
  db  0,132    ;264,0.034244,48,2F
  db  0,131    ;262,0.034506,49,30
  db  0,129    ;258,0.034764,50,31
  db  0,127    ;254,0.035018,51,32
  db  0,126    ;252,0.03527,52,33
  db  0,124    ;248,0.035518,53,34
  db  0,123    ;246,0.035764,54,35
  db  0,121    ;242,0.036006,55,36
  db  0,120    ;240,0.036246,56,37
  db  0,119    ;238,0.036484,57,38
  db  0,117    ;234,0.036718,58,39
  db  0,116    ;232,0.03695,59,3A
  db  0,115    ;230,0.03718,60,3B
  db  0,114    ;228,0.037408,61,3C
  db  0,113    ;226,0.037634,62,3D
  db  0,111    ;222,0.037856,63,3E
  db  0,110    ;220,0.038076,64,3F
  db  0,109    ;218,0.038294,65,40
  db  0,108    ;216,0.03851,66,41
  db  0,107    ;214,0.038724,67,42
  db  0,106    ;212,0.038936,68,43
  db  0,105    ;210,0.039146,69,44
  db  0,104    ;208,0.039354,70,45
  db  0,103    ;206,0.03956,71,46
  db  0,102    ;204,0.039764,72,47
  db  0,101    ;202,0.039966,73,48
  db  0,100    ;200,0.040166,74,49
  db  0,100    ;200,0.040366,75,4A
  db  0,99    ;198,0.040564,76,4B
  db  0,98    ;196,0.04076,77,4C
  db  0,97    ;194,0.040954,78,4D
  db  0,96    ;192,0.041146,79,4E
  db  0,95    ;190,0.041336,80,4F
  db  0,95    ;190,0.041526,81,50
  db  0,94    ;188,0.041714,82,51
  db  0,93    ;186,0.0419,83,52
  db  0,92    ;184,0.042084,84,53
  db  0,92    ;184,0.042268,85,54
  db  0,91    ;182,0.04245,86,55
  db  0,90    ;180,0.04263,87,56
  db  0,90    ;180,0.04281,88,57
  db  0,89    ;178,0.042988,89,58
  db  0,88    ;176,0.043164,90,59
  db  0,88    ;176,0.04334,91,5A
  db  0,87    ;174,0.043514,92,5B
  db  0,86    ;172,0.043686,93,5C
  db  0,86    ;172,0.043858,94,5D
  db  0,85    ;170,0.044028,95,5E
  db  0,84    ;168,0.044196,96,5F
  db  0,84    ;168,0.044364,97,60
  db  0,83    ;166,0.04453,98,61
  db  0,83    ;166,0.044696,99,62
  db  0,82    ;164,0.04486,100,63
  db  0,82    ;164,0.045024,101,64
  db  0,81    ;162,0.045186,102,65
  db  0,80    ;160,0.045346,103,66
  db  0,80    ;160,0.045506,104,67
  db  0,79    ;158,0.045664,105,68
  db  0,79    ;158,0.045822,106,69
  db  0,78    ;156,0.045978,107,6A
  db  0,78    ;156,0.046134,108,6B
  db  0,77    ;154,0.046288,109,6C
  db  0,77    ;154,0.046442,110,6D
  db  0,76    ;152,0.046594,111,6E
  db  0,76    ;152,0.046746,112,6F
  db  0,75    ;150,0.046896,113,70
  db  0,75    ;150,0.047046,114,71
  db  0,74    ;148,0.047194,115,72
  db  0,74    ;148,0.047342,116,73
  db  0,74    ;148,0.04749,117,74
  db  0,73    ;146,0.047636,118,75
  db  0,73    ;146,0.047782,119,76
  db  0,72    ;144,0.047926,120,77
  db  0,72    ;144,0.04807,121,78
  db  0,71    ;142,0.048212,122,79
  db  0,71    ;142,0.048354,123,7A
  db  0,71    ;142,0.048496,124,7B
  db  0,70    ;140,0.048636,125,7C
  db  0,70    ;140,0.048776,126,7D
  db  0,69    ;138,0.048914,127,7E
  db  0,69    ;138,0.049052,128,7F
  db  0,69    ;138,0.04919,129,80
  db  0,68    ;136,0.049326,130,81
  db  0,68    ;136,0.049462,131,82
  db  0,67    ;134,0.049596,132,83
  db  0,67    ;134,0.04973,133,84
  db  0,67    ;134,0.049864,134,85
  db  0,66    ;132,0.049996,135,86
  db  0,66    ;132,0.050128,136,87
  db  0,66    ;132,0.05026,137,88
  db  0,65    ;130,0.05039,138,89
  db  0,65    ;130,0.05052,139,8A
  db  0,65    ;130,0.05065,140,8B
  db  0,64    ;128,0.050778,141,8C
  db  0,64    ;128,0.050906,142,8D
  db  0,64    ;128,0.051034,143,8E
  db  0,63    ;126,0.05116,144,8F
  db  0,63    ;126,0.051286,145,90
  db  0,63    ;126,0.051412,146,91
  db  0,62    ;124,0.051536,147,92
  db  0,62    ;124,0.05166,148,93
  db  0,62    ;124,0.051784,149,94
  db  0,61    ;122,0.051906,150,95
  db  0,61    ;122,0.052028,151,96
  db  0,61    ;122,0.05215,152,97
  db  0,61    ;122,0.052272,153,98
  db  0,60    ;120,0.052392,154,99
  db  0,60    ;120,0.052512,155,9A
  db  0,60    ;120,0.052632,156,9B
  db  0,59    ;118,0.05275,157,9C
  db  0,59    ;118,0.052868,158,9D
  db  0,59    ;118,0.052986,159,9E
  db  0,59    ;118,0.053104,160,9F
  db  0,58    ;116,0.05322,161,A0
  db  0,58    ;116,0.053336,162,A1
  db  0,58    ;116,0.053452,163,A2
  db  0,57    ;114,0.053566,164,A3
  db  0,57    ;114,0.05368,165,A4
  db  0,57    ;114,0.053794,166,A5
  db  0,57    ;114,0.053908,167,A6
  db  0,56    ;112,0.05402,168,A7
  db  0,56    ;112,0.054132,169,A8
  db  0,56    ;112,0.054244,170,A9
  db  0,56    ;112,0.054356,171,AA
  db  0,55    ;110,0.054466,172,AB
  db  0,55    ;110,0.054576,173,AC
  db  0,55    ;110,0.054686,174,AD
  db  0,55    ;110,0.054796,175,AE
  db  0,40   ;108,0.054904,176,AF		2000 5/19 >>> 54 > 40
  db  0,0    ;108,0.055012,177,B0
  db  0,0    ;108,0.055012,178,B1
  db  0,0    ;108,0.055012,179,B2
  db  0,0    ;108,0.055012,180,B3
  db  0,0    ;108,0.055012,181,B4
  db  0,0    ;108,0.055012,182,B5
  db  0,0    ;108,0.055012,183,B6
  db  0,0    ;108,0.055012,184,B7
  db  0,0    ;108,0.055012,185,B8
  db  0,0    ;108,0.055012,186,B9
  db  0,0    ;108,0.055012,187,BA
  db  0,0    ;108,0.055012,188,BB
  db  0,0    ;108,0.055012,189,BC
  db  0,0    ;108,0.055012,190,BD
  db  0,0    ;108,0.055012,191,BE
  db  0,0    ;108,0.055012,192,BF
;=================================================

;=============================================================================
;	INCLUDE STM_D.SRC
;=============================================================================
	org	RAMD + 040h
PIOAD_P		DS	1
PIOBD_P		DS	1
CTC1COU		DS	1
CTC1DLC1	DS	1
CTC1DLC2	DS	1
RX_D_P		DS	1
RX_F		DS	1
TX_F		DS	1
IX_DEC_P	DS	1
UP_DW_P		DS	1
ERR_P		DS	1
KIDOU_P		DS	1
MODE_P		DS	1	;BIT 7 ON=80H USE PG
				;BIT 6 DW=HI=40H  UP=0
				;BIT 5 STM=ON=HI=20H
				;BIT 4 KIDOU=1 ON
MAX_SP		DS	1
;					6/03
KIRI_STM_COU	DS	1
ACK		DS	1
PUSHMV_P	DS	1
PUSHMV_SW	DS	1
KIDOU_OFF	DS	1
;
	org	RAMD + 080H
;
SUUTI_TOP:
;PP
KAKOU_RYOU 	DS 	2 ;[A] 研削量　　　　回 0-60000(30mm)
KIRI_RYOU 	DS      2 ;[B] 切り込み量    回 0-1999(1mm)
KIRI_KAI 	DS	2 ;[N] テーブル回転  回数 0-999
SP_OUT_KAI      DS      2 ;[C] スパークアウト回数 0-999
;
EARCUT_D        DS      2 ;[D] エア－カット  回数 0-1999(1mm)
OBERRUN_D       DS      2 ;[E] オーバーラン  回数 0-1999(1mm)
;QQ
;STM_P_MM        DS      2 ;[S]定数　0.0005mm
;SOFT_UD_P 	DS	2 ;[E2]定数　177
;KAIHI_3M 	DS      2 ;[M3]定数　3mm/S=6000
;
QQ_NOP		DS	6
STOP1DATA	DS	2 ;-OBERRUN_D - EARCUT_D - KAIHI_3M + (SOFT_UD_P*2)
DW3MM_DATA	DS	2 ;-OBERRUN_D - EARCUT_D
KAKOU_END       DS	2 ;-OBERRUN_D + SOFT_UD_P + KAKOU_RYOU
;'WK センサー位置ONで　ｶｳﾝﾀ=0とする
;'   E=E1=E2    E1=E-E2 がWKに当たってからｾﾝｻｰが働くまでの値
;'   例　E=400 B=200 D=60 A=200
;'Dim STOP1DATA As Double     'WK ON STOPご　UPする位置-E2
;'     -400+177-60-6000+177 = -6106(E826)      (-E-D-M3+E2+E2)
;'DW3MM_DATA
;'          -400+177-60-177 =  -460(FE34)   (-E+E2-D-E2)=(-E-D)
;'Dim KAKOU_END As Double     '            カコウ終了位置
;'           -400+177+200   =   -23(FFE9)        (-E+E2+A)
;
	NOP
	NOP
	NOP
;
	org	RAMD + 0C0H
STMC1		DS	10H
	org	RAMD + 0E0H
TX_Data		DS	10H
;
	org	RAMD + 0100H
RX_Data		DS      0100H
;=================================================
;    TxMVcommand (1-7)               'SW
;
;    TxMVcommand (&H89)              'SLOW STOP
;    TxMVcommand (&H88)              'STOP
;    TxMVcommand (&H80 + Index) 'UP
;    TxMVcommand (&H90 + Index) 'DOWN
;    TxMVcommand (&HA0)              'ORIGINAL PRG
;    TxMVcommand (&HB0)              'USER PRG
;    TxMVcommand (&HC0)		    'ALL _OFF
;    TxMVcommand (&HC8)		    'STOP_UP
;    TxMVcommand (&HD0)		    'KIDOU
;    TxMVcommand (&HE0)             'EDIT
	END

```
## おわりに　
長いリスト当時そのままで公開しました。昔の自分の根気に脱帽しています。
写真は、当時開発していた関係多機種になっています。
分かりにくい資料で申し訳ございません。