A86: absolute address resolution


[Prev][Next][Index][Thread]

A86: absolute address resolution




Does anyone see any obvious defects in this routine?  I've tested it on
the emulator in several programs, but the last few versions tested out
ok too, until a week or so later when I discovered an error.  But I
think I've got it now.  Apparently, until tonight, my concept of what
paged memory meant wasn't quite what TI's concept was...

Cassady Roop


;decodeABS   decodes absolute address in ahl.
;by Cassady Roop
;input - AHL = absolute address, like that outputted by _findsym
;output - A = page
;	 HL = offset into page.
decodeABS:
	cp 0			;is a zero?
	ret z			;if so, hl is already a valid pointer
	dec a
	rlca			;*2
	rlca			;*4
	ld de, $4000		;length of one page
dABSloop:
	push hl			;save
	sbc hl, de		;hl=hl-de
	jr c, dABSdone		;if hl was less than $4000
	pop bc			;get rid of the value we saved
	inc a			;increment the page counter
	jr dABSloop		;reloop
dABSdone:
	inc a			;page correction
	pop hl			;the last pushed value is the offset
	ret			;we are done