view src/varargs.inc @ 627:bf5fee575701

minor cleanup, reset rx circuity
author heinrichsweikamp
date Sun, 30 Jun 2019 23:22:32 +0200
parents c40025d8e750
children 4050675965ea
line wrap: on
line source

;=============================================================================
;
;    File varargs.inc                          combined next generation V3.0.1
;
;    Utilities to pass multiple arguments in compact code stream.
;
;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
;=============================================================================
; HISTORY
;  2011-05-27 : [jDG] Creation.
;

VARARGS_BEGIN macro
	movff	TOSL, TBLPTRL
	movff	TOSH, TBLPTRH
	movff	TOSU, TBLPTRU
	endm

VARARGS_GET8 macro register
	tblrd*+
	movff	TABLAT, register
	endm

VARARGS_GET16 macro register
	tblrd*+
	movff	TABLAT, register+0
	tblrd*+
	movff	TABLAT, register+1
	endm

VARARGS_GET24 macro register
	tblrd*+
	movff	TABLAT, register+0
	tblrd*+
	movff	TABLAT, register+1
	tblrd*+
	movff	TABLAT, register+2
	endm

VARARGS_ALIGN macro
	local	no_tblptr_align

	btfss	TBLPTRL,0
	bra		no_tblptr_align
	incf	TBLPTRL
	movlw	0
	addwfc	TBLPTRH
	addwfc	TBLPTRU
no_tblptr_align:
	endm

VARARGS_END macro
	; compute string length (modulo 256):
	movf	TOSL,W
	subwf	TBLPTRL,W

	; then 24 bit add to return address
	addwf	TOSL,F
	movlw	0			; clear WREG, but keep carry
	addwfc	TOSH,F
	addwfc	TOSU,F
	endm