> of course this might very well be purely academic, but the result is still
> incorrect regardless of how you turn it. ((0-0)+0+(c)) should never result
> in 1. as for whether you can work around it, that is a different question.
> but the fact is that the result is incorrect.
You're simply labouring under a misunderstanding of how carry flags work.
The only thing incorrect here is following SUBS with ADC. There is no
meaning to this instruction sequence.
Carry is only defined on ADD. SUB defines borrow, and borrow is mapped into
the C flag one of two possible ways. To say that ((0-0)+0+(c)) even has
*meaning* is to make an unwarranted assumption about how this mapping is
done. Carry and borrow are two distinct concepts, and to treat them as the
same in code is incorrect. It is your code that is wrong, *not* the CPU.
It's just like Damian said - it's an arbitrary choice like big-endian vs
little-endian. Except that there are some asm tricks that are possible in
little-endian that aren't possible in big-endian and vice versa. I *hoped*
I was going to learn something and find out that there's a trick you can do
in carry = borrow systems that you can't do in carry = !borrow systems, but
I fear I'm going to be disappointed. I wasn't meaning to debate this with
you, I just wanted to know if you had any use for that sequence or if it was
just a contrived example.
Jay wrote:
> I confirmed that this is does occur (at least in the VisualBoy emulator).
Oh right an EMULATOR gives a result that doesn't match the ARM docs and
that's confirmation of a problem with the ARM?! Gimme a break.
I agree that it's puzzling to find the carry flag set after Morten's first
sequence:
But I just tested it on an Acorn ARM machine and it doesn't. It gives C = 0
as you would expect. And C = 1 if you do LSL #3, again, as you would
expect.
Can anyone confirm Morten's result on an actual GBA?
... Can you justify why the carry flag should be set in this case? ... I confirmed that this is does occur (at least in the VisualBoy emulator). This is not...
... You're simply labouring under a misunderstanding of how carry flags work. The only thing incorrect here is following SUBS with ADC. There is no meaning to...
Eddie Edwards
eddie@...
Apr 3, 2003 2:16 am
Is there a quick and simple test for detecting the SP version ? over the older GBA? I have a help page screen that lists controls for GBA, and wish to display...
... unfortunately, no. there isn't even a long and complicated test for detecting the SP. it's totally transparent to the programmer. regards, matthew....
Hi Bollo, I asked this on the gbadev.org forums, and there was no method known as of yet. I tried dumping the BIOS as well, to see if anything had changed,...
but doesn't final fantasy tactics advance change its colors depending on whether its running on the GBA or the SP? if so, then there must be some way to detect...
Metroid Fusion asks you if you are using headphones or internal speaker and changes the sound depending on your selection. Although its nice to autodetect to...
Aaron Isaksen
aisaksen@...
Apr 4, 2003 2:35 am
Hi, You can choose the color settings from the menu. There are even settings for when you're playing through the Gameboy Player for the NGC. Bye, Collin ... ...
... that would also be a reliable way to make sure you are on a gba ;) cheers, x -- chris@... Postmodernism is german romanticism with better ...
CK
x@...
Apr 4, 2003 10:59 am
... OK, I can't reproduce it now with the same conditions as before, so I retract my complaint. If I investigate again, I will confirm on actual hardware. It...
Hi Jay, ... Both correct. CMP is *exactly* just SUBS without a destination register. ... <=> BCC. ... Well you should avoid BCC/BCS except (a) after ADD and...
Eddie Edwards
eddie@...
Apr 3, 2003 1:27 pm
... maybe an old speccy owner that still cant resist any 6502-ish behaviour no matter what? :o) gpz...
... yes, I was taking about the old 6502 (history of the Arm being the replacement for the 6502 in acorn computers) (still it was sbc without the sub etc etc)....
Mike Wynn
mike.wynn@...
Apr 2, 2003 2:43 am
of course this might very well be purely academic, but the result is still incorrect regardless of how you turn it. ((0-0)+0+(c)) should never result in 1. as...
Morten Pedersen
escapekey@...
Apr 2, 2003 11:36 pm
... Academically, does Peano arithmetic define 'c'? What's incorrect academically is to use the carry flag for anything other than carrying from less...
... This really perplexed me so I tried it out myself as a sanity check. I was unable to reproduce this behaviour either in VBA or on the hardware. ?!?...