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

📄 prn_edit.asm

📁 calculator code ,use toshibaor nec LSI
💻 ASM
📖 第 1 页 / 共 5 页
字号:
		j	cs,print_shpd2		;with tenkey entry?  yes->
;in case of without tenkey.....................
		call	ten_to_w1		;tenkey -> W1(no DP adjustment)
		ld	(SYM),S_ST		;

;GT logic.................................................................
;V3.00		@BBC	(M_694,print_shgt0)
;V3.00		ld	(SYM),S_SHP		;# with square box
;V3.00print_shgt0:
;GT logic.................................................................

		ld	hl,W1
		call	edit_prn		;W1(display value) edit and transfer to PRN_BUF(edit without comma separator)
		j	wk_print91		;print without check P_NP flag

;in case of with tenkey..........
print_shpd2:
		call	spc_prnbuf		;PRN_BUF space clear
		ld	c,16			;#/D maximum print capacity
	test	(FLG_MODE).0
	j	f,print_shpd20x
		ld	c,18			;V4.07
print_shpd20x:					;V4.07
		ld	ix,DT_BUF_LSD
		ld	iy,PRN_BUF_LSD
	test	(FLG_MODE).0
	j	t,print_shpd20
		ld	iy,PRN_BUF_LSD_LTP+1	;V4.03
print_shpd20:
		ld	a,(ix)
		ld	cf,c.0			;even digit?
		j	cc,print_shpd22		; yes->
		swap	a
print_shpd22:
		and	a,0x0f
		cmp	a,C_DP			;DP code?
		j	eq,print_shpd24		; yes->
		cmp	a,C_SPC			;space code?
		j	eq,print_shpd23		; yes->
;V4.03		or	a,0x30			;change to ascii
		j	print_shpd25
print_shpd23:
		ld	a,ps_spc
		j	print_shpd25
print_shpd24:
		ld	a,ps_dot
print_shpd25:
		ld	(iy),a			;set to PRN_BUF
		dec	iy
		dec	c
		j	z,print_shpd26		;transfered maximum character?  yes->
		ld	cf,c.0			;even digit?
		j	cs,print_shpd20		; yes->
		dec	ix
		j	print_shpd20

;PRN_BUF left shift until data will be found...
print_shpd26:
		ld	hl,PRN_BUF_MSD_LTP
		ld	d,D_PRN_MAX_LTP	;V4.03
	test	(FLG_MODE).0
	j	f,print_shpd26_1
		ld	hl,PRN_BUF		;V3.03
		ld	d,D_PRN_MAX		;
print_shpd26_1:					;v4.03
		ld	e,d			;for make sure
print_shpd27:
		ld	a,(hl+1)
		cmp	a,ps_spc			;space?
		j	ne,print_shpd29		; no -> finish to shift
;1byte left shift (PRN_BUF+2~+20 -> PRN_BUF+1~+19)...22digit printer
		ld	c,2
print_shpd28:
		ld	a,(hl+c)
		dec	c
		ld	(hl+c),a
		inc	c
		inc	c
		cmp	c,d			;
		j	lt,print_shpd28
		dec	c
		ld	(hl+c),ps_spc		;padding space for PRN_BUF_LSD
		dec	e
		j	f,print_shpd27		;not ffh?  yes->
print_shpd29:
	
;GT logic......................................................
;V3.00		@BBC	(M_694,print_shgt9)
;V3.00		ld	(SYM),S_SHP		;# with square box
;V3.00		call	set_symbol		;set symbol from symbol code(SYM)
;V3.00		ld	ix,TENKEY
;V3.00		call	set_bold		;set P_RED flag by refer (ix) contents 
;V3.00		j	wk_print91		;print without check P_NP flag
;V3.00print_shgt9:
;GT logic......................................................

		ld	(hl),ps_der
		ld	ix,TENKEY
;V3.04		call	set_bold		;set P_RED flag by refer (ix) contents 
		j	wk_print91		;print without check P_NP flag


;==============================================================================
;	Name:     edit_prn
;	Function: copy work resister data to PRN_BUF with zero suppression and
;                  set commma, DP and symbol, Red color flag(P_RED)
;	Input:	  hl <- work resister address
;		  SYM <- symbol code
;	          *note) if symbol code is S_SHD(for #/D key) commma separator is omitted
;	Output:	  PRN_BUF +0~+9, P_RED
;	Work reg.: ix,iy,b,c,d,e,a,w
;		 *keep hl resister contents
;==============================================================================
;
;
;	work resister
;
;	+0   +1  - - - - - - - - +7   +8
;	SIGN MSD		 LSD  DP
;            <-------14 digits-----> 
;
;			 |
;	edit work resister data (set DP, comma 'minus sign' and zero suppression)
;			 |
;	PRN_BUF
;	+0  +1 - - - - - - - - - - - - - - +20 +21 +22 +23
;	SP '-' n  n  n  ,  n  n  n - - n  n  .  | M   + |
;       <-------------  21digits  ----------->     SYM
;		       (D_PRN_MAX)
;
edit_prn:
		ld	ix,hl			;save hl			
		call	spc_prnbuf		;PRN_BUF space clear
		call	set_symbol		;set symbol from symbol code(SYM)
		call	set_bold		;check minus tranzaction and negative value
		ld	d,0			;d...digit pointer of work register(0-13)
		ld	e,0			;e...digit pointer of PRN_BUF(0-19)
edit_prn0:
		ld	hl,ix			;load source top address
		call	get_from_src		;get nibble data from reg.hl(top address) and reg.d(pointer)  -> reg.a
		cmp	d,(ix+OFF_DP)		;check DP location
		j	eq,edit_prn4		;DP value of work resister = current pointer
		inc	d			;+1 source pointer
		call	store_to_dist		;nibble(reg.a) data of source -> change ASCII -> to distination (PRN_BUF + reg.e)
		inc	e			;+1 distination pointer
	test	(FLG_MODE).0
	j	f,edit_prn0_x
		cmp	e,D_PRN_MAX		;21; transfer end?(distination pointer is over than maximum digit?)
		jp	edit_prn0_y	;V4.06
edit_prn0_x:				;V4.05
		cmp	e,D_PRN_MAX_LTP	;V4.05	;16
edit_prn0_y:
		j	lt,edit_prn0		; no->loop
		j	store_zs0		; -> end(for make sure)
;Found DP...............
edit_prn4:
		inc	d			;+1 source pointer
		push	a			;for save current data
		ld	a,ps_dot			; '.' code
        test	(FLG_MODE).2
	j	t,edit_prn4_1
		ld	a,ps_com	;V4.09		; ',' code
edit_prn4_1:				;V4.09
		call	store_to_distx		;store DP(PRN_BUF + reg.e)
		inc	e			;+1 distination pointer
		pop	a
		ld	w,2			;for set comma separator
		j	edit_prn6
edit_prn5:		
		ld	hl,ix			;load source top address
		call	get_from_src		;get nibble data from reg.hl(top address) and reg.d(pointer)  ->reg.a
		inc	d			;+1 source pointer
edit_prn6:
		call	store_to_dist		;store nibble(reg.a) data to distination(PRN_BUF + reg.e)
		inc	e			;+1 distination pointer
	test	(FLG_MODE).0
	j	f,edit_prn6_x
		cmp	e,D_PRN_MAX		;  transfer end?(distination pointer is over than maximum digit?)
		jp	edit_prn6_y		;V4.05
edit_prn6_x:					;V4.05
		cmp	e,D_PRN_MAX_LTP		;V4.05
edit_prn6_y:
		j	ge,store_zs0		;  yes-> finish
		dec	w			;for set comma separator
		j	f,edit_prn8		;if no borrow? yes->
		ld	w,2			;for set comma separator
;V3.07		cmp	(SYM),S_SHD		;#/D print?
;V3.07		j	eq,edit_prn72		; yes -> omit comma sepalator
		
;FLG_RTC(bit0)=TIME_DISP flag......................
;V4.13		ld	cf,(FLG_RTC).0		;Time display?
;................................................
;V4.13		j	cs,edit_prn72		; yes -> omit comma sepalator
		
		ld	a,ps_spc			; 
;MDFLG_2(bit1)=SW_PUNC flag......................
		ld	cf,(FLG_MODE).1		;Punctuation is space?
;................................................
		j	cs,edit_prn65		; yes ->
		ld	a,ps_com			; 
        test	(FLG_MODE).2
	j	t,edit_prn65
		ld	a,ps_dot		;V4.09
edit_prn65:
		call	store_to_distx		;store Commma(PRN_BUF + reg.e)
		inc	e			;+1 distination pointer
edit_prn72:
		ld	w,2			;for set comma separator
edit_prn8:
		cmp	d,LENG_WK*2-1		;source pointer is over than maximum digit?
		j	gt,store_zs0		; yes ->finish
	test	(FLG_MODE).0
	j	f,edit_prn8_1
		cmp	e,D_PRN_MAX		;transfer end?(distination pointer is over than maximum digit?)
		jp	edit_prn8_2		;V4.05
edit_prn8_1:					;v4.03
		cmp	e,D_PRN_MAX_LTP		;V4.03
edit_prn8_2:					;V4.05
		j	lt,edit_prn5		; no ->loop

;zero suppression...............
store_zs0:
		dec	e			;-1 distination pointer
		call	get_from_dist		;get nibble data from distination(PRN_BUF + reg.e) ->reg.a
		cmp	a,ps_0			; '0'?
		j	eq,store_zs4		; yes-> suppression
        test	(FLG_MODE).2
	j	f,store_zs1
		cmp	a,ps_com			;commma?
		jp	store_zs2	;V4.09
store_zs1:				;V4.09
		cmp	a,ps_dot	;V4.09
store_zs2:				;V4.09
		j	eq,store_zs7		; yes-> suppression
		cmp	a,ps_spc			;space?
		j	eq,store_zs7		; yes-> suppression
		j	store_zs8		; no -> finish zero suppression
;found 0 .............
store_zs4:
		dec	e			;-1 distination pointer
		call	get_from_dist		;check one more previouse digit data
		inc	e			;+1 distination pointer
        test	(FLG_MODE).2
	j	f,store_zs5
		cmp	a,ps_dot			;dp?
		jp	store_zs6	;V4.09
store_zs5:				;V4.09
		cmp	a,ps_com	;V4.09
store_zs6:				;V4.09
		j	eq,store_zs8		;V3.00es -> finished  (means 0.00--- format)
;set space............
store_zs7:
		ld	a,ps_spc
		call	store_to_distx		;store space(PRN_BUF + reg.e)
		cmp	e,0			;for make sure
		j	ne,store_zs0
		j	store_zs92
store_zs8:
		ld	a,(ix+OFF_S)		;work reg.value is minus?
		j	z,store_zs92		;no(means positive value) ->
;negative value...
		inc	e			;+1 distination pointer
	test	(FLG_MODE).0
	j	t,store_zs8_x
		cmp	e,16
		jp	store_zs8_y		;V4.05
store_zs8_x:					;V4.05
		cmp	e,21			;V4.05
store_zs8_y:					;V4.05

		j	lt,store_zsx
		ld	a,(PRN_BUF_SYM+1)
	test	(FLG_MODE).0
	j	t,store_zs8_1
		ld	a,(PRN_BUF_SYM_LTP+1)	;V4.03
store_zs8_1:					;V4.03
		cmp	a,ps_spc
		j	eq,store_zsy
		cmp	a,ps_m
		j	eq,store_zsw
		cmp	a,ps_dlt
		j	eq,store_zsz
		jp	store_zs92
store_zsz:
	test	(FLG_MODE).0
	j	f,store_zsz_1
		ld	(PRN_BUF_SYM+1),ps_mder
		jp	store_zsz_2
store_zsz_1:
		ld	(PRN_BUF_SYM_LTP+1),ps_mder
store_zsz_2:
		jp	store_zs92
store_zsw:
	test	(FLG_MODE).0
	j	f,store_zsw_1
		ld	(PRN_BUF_SYM+1),ps_mm
		jp	store_zsw_2
store_zsw_1:
		ld	(PRN_BUF_SYM_LTP+1),ps_mm
store_zsw_2:
		jp	store_zs92
store_zsy:
	test	(FLG_MODE).0
	j	f,store_zsy_1
		ld	(PRN_BUF_SYM+1),ps_min
		jp	store_zsy_2
store_zsy_1:
		ld	(PRN_BUF_SYM_LTP+1),ps_min
store_zsy_2:
		jp	store_zs92
store_zsx:
		ld	a,ps_min
		call	store_to_distx		;store minus sign(PRN_BUF + reg.e)
store_zs92:
;V3.00		call	replay_cnt_add		;add auto call counter to MSD
		ld	hl,ix			;recover hl register for 2line print
		ret


;check minus tranzaction and negative value -> set P_RED for bold printing
set_bold:
		ld	a,(ix+OFF_S)		;work reg.value is minus?
		j	z,set_bold2		;no(means positive value) ->
;negative value...
	ld	wa,F_MIN_TRA
	test	(F_MIN_TRA>>4).a		;bit -reverse-> jump status
	j	f,set_bold5		;if jump status is 0 -> branch
		j	set_bold6
;positive value...
set_bold2:
	ld	wa,F_MIN_TRA
	test	(F_MIN_TRA>>4).a		;bit -reverse-> jump status
	j	f,set_bold6		;if jump status is 0 -> branch
set_bold5:
	ld	wa,P_RED
	clr	(P_RED>>4).a
		j	set_bold9
set_bold6:
	ld	wa,P_RED
	set	(P_RED>>4).a
set_bold9:
		ret



;get nibble data from reg.hl(top address) and reg.d(digit pointer)
get_from_src:
		ld	c,(LENG_WK+1)*2-1	;(length of work resister + sign part length)*2 - 1
		sub	c,d			;reg.d ... digit pointer of source address(0 - 13)
get_fs0:
		shrc	c
		ld	a,(hl+c)		;get data from work register
		j	cs,get_fs2		;c is odd number? yes->
		swap	a			;swap by nibble
get_fs2:
		and	a,0x0f			;get low nibble data
		ret


;get ascii data from reg.hl(top address) and reg.e(digit pointer)
get_from_dist:
		ld	hl,PRN_BUF		;hl <- distination top address
	test	(FLG_MODE).0
	j	t,get_from_dist_1
		ld	hl,PRN_BUF_MSD_LTP
get_from_dist_1:				;V4.03
		ld	c,D_PRN_MAX-1		;PRN_BUF maximum digits(numeric part only) - 1	
;V4.06		ld	c,D_PRN_MAX		;V4.06
	test	(FLG_MODE).0
	j	t,get_from_dist_2
		ld	c,D_PRN_MAX_LTP-1	;V4.03
get_from_dist_2:				;V4.03
		sub	c,e			;reg.e ...digit pointer of distination address(0 - 19)
		ld	a,(hl+c)		;get data from PRN_BUF
		ret

;nibble data(low nibble of reg.a) change to ACCII and transfer to address -> reg.hl(top address) and reg.e(digit pointer)
store_to_dist:
		and	a,0x0f
;V4.02		or	a,0x30			;change to ascii
store_to_distx:
		ld	hl,PRN_BUF		;hl <- distination top address
	test	(FLG_MODE).0
	j	t,store_to_disty
		ld	hl,PRN_BUF_MSD_LTP		;V3.03
store_to_disty:					;V4.03
		ld	c,D_PRN_MAX-1		;PRN_BUF maximum digits(numeric part only) - 1
;V4.06		ld	c,D_PRN_MAX		;V4.06
	test	(FLG_MODE).0
	j	t,store_to_disty_1
		ld	c,D_PRN_MAX_LTP-1	;V4.03
store_to_disty_1:				;V4.03
		sub	c,e			;reg.e ...digit pointer of distination address(0 - 19)
		ld	(hl+c),a		;store ascii data to distination
		ret		

⌨️ 快捷键说明

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