prtst68k.lib

来自「open source of basic interpreter of 68」· LIB 代码 · 共 42 行

LIB
42
字号
*
*  prtst68k.lib      print a constant string to the console (68xxx)
*
*  This routine prints an embedded string to the output device that
*  responds to the outch subroutine.  See the file outch68k.lib for
*  details on the low-level outch function.
*
*  This routine expects the address of the in-line string in the
*  top of the stack.  This is accomplished by code such as:
*
*      jsr   _prtstrc
*      dc.b   13
*      dc.b   'hello, world!'
*      even
*      <next instruction>
*
*  Note that the embedded string must contain the string length in the
*  first byte of the string.
*
*  This routine preserves all registers.
*

_prtstrc
	movem.l	a0/d0/d1,-(a7)	save regs
	movea.l	12(a7),a0	get addr of string (return addr on stack)
	clr.l	d1		force d1 to 0
	move.b	(a0)+,d1	move count to d1
	subq.b	#1,d1		adjust for loop
_prtstrc0
	move.b	(a0)+,d0	get a byte
	jsr	_outch		print a byte
	dbra	d1,_prtstrc0	loop until done
	move.l	a0,d0		get final address
	btst	#0,d0		test low bit
	beq	_prtstrc1	branch if even address
	addq.l	#1,d0		adjust for even address
_prtstrc1
	move.l	d0,12(a7)	overwrite return address
	movem.l	(a7)+,a0/d0/d1	restore regs
	rts

⌨️ 快捷键说明

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