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

📄 prtvl68k.lib

📁 open source of basic interpreter of 68
💻 LIB
字号:
*
*  prtval.lib      library routine to display a value on the output device (68xxx)
*
*  This routine translates a value, passed in the D0 reg, into ASCII
*  characters and uses the outch routine to display those characters
*  on the active output device.
*
*  The entry point _prtval prints the value as a signed number; it always
*  prepends a leading minus sign and negates the argument if the argument
*  is negative.
*
*  The entry point _prtvalu prints the value as an unsigned number.
*

_prtval
	link	a6,#-2			make a local variable (word)
	movem.l	d0/d1/a0,-(a7)		save regs
	move.l	d0,d1			move value to working reg
	tst.l	d1			check sign
	bpl	_prtv1			branch if plus
	move.b	#'-',d0			get minus sign
	jsr	_outch			send it
	neg.l	d1			force positive value
	bra	_prtv1			continue
*
*  Entry point for printing an unsigned value.
*
_prtvalu
	link	a6,#-2			make a local variable (word)
	movem.l	d0/d1/a0,-(a7)		save regs
	move.l	d0,d1			move value to working reg

_prtv1
	tst.l	d1			check for simple case
	beq	_prtv0			branch if just 0
	clr.w	-2(a6)			temp = 0 if no leading 0s	
	swap	d1			move msb to lsb
	tst.w	d1			look at lsb
	bne	_prtv1a			branch if not 0
	movea.l	#_tab10w,a0		only need to convert 16 bits
	bra	_prtv1b			continue
_prtv1a
	movea.l	#_tab10,a0		need to convert 32 bits
_prtv1b
	swap	d1			restore original number	
	move.l	d1,d0			get numerator to d0

_prtv2
	move.l	(a0)+,d1		move denom to d1
	tst.w	-2(a6)			test leading 0 flag
	bne	_prtv4			branch if must print
	cmp.l	d0,d1			need to divide?
	bhi	_prtv2a			branch if not
_prtv4
	jsr	_div32u			do the divide
	move.w	#1,-2(a6)		set leading 0 flag to non-zero
	add.w	#'0',d0			make result an ASCII char
	jsr	_outch			print it
_prtv3
	exg	d1,d0			move remainder to D0
_prtv2a	
	cmpa.l	#_tabend,a0		reached the end of table?
	bne	_prtv2			branch if not
_prtv0
	add.w	#'0',d0			make result an ASCII char
	jsr	_outch			print it
	move.b	#' ',d0			need trailing space
	jsr	_outch			send it
	movem.l	(a7)+,d0/d1/a0		restore regs
	unlk	a6			unlink
	rts


_tab10
	dc.l	1000000000
	dc.l	100000000
	dc.l	10000000
	dc.l	1000000			allow for predecrement
	dc.l	100000
_tab10w
	dc.l	10000
	dc.l	1000
	dc.l	100
	dc.l	10
_tabend	equ	*


⌨️ 快捷键说明

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