Date : Mon, 18 Jul 1994 16:28:00 +0100 (BST)
From : amh15@... (Alan Hart)
Subject: Re: Steve's emulators.
> I have a bit of a problem which I think I could really speed up - how can
> I do relative branches? What I'm doing at the moment (basically) is:
>
> load branch distance byte
> if <branch distance> is less than 128
> move P back <branch distance>
> goto end
> move P forward <branch distance>
> .end
>
> Is there a better way of doing this? In the 256^3 speed test this is *by
> far* where I lose my speed.
Surely the byte is a signed 8-bit number. All you have to do is add this to
the current PC+1 (or whatever it is that branch uses on the 6502). You might
want to sign-extend the byte when you load it into a 16-bit register and then
add it to the current PC+1. In fact I think the system you have proposed
above will not work for forward jumps, will it [I assume it does work for
backwards and that it can't work for both].
Alan
Alan Hart - amh15@... - University of Cambridge, UK