Date : Tue, 19 Jul 1994 19:02:04 +0100
From : jfid@... (James Fidell)
Subject: Re: Progress Report and some questions...
Chris Rae wrote:
> Anyway, here come my questions and I'm pretty stumped with 'em. Please
> help if you can...
>
> 1. What is the V flag for? Is it user-definable and that's it?
It's the overflow flag and it's not user-definable.
It is set to indicate that the sign bit of and addition or subtraction
is incorrect -- for example, adding 0x53 and 0x47, both positive numbers,
gives 0x9a, which has the sign bit set and thus will be treated as a
negative number.
I think that the only other instruction that affects this flag is BIT,
which sets it to bit 6 of the operand of the BIT.
> 2. What does BIT do?
Logical ANDs the accumulator with the operand, setting the zero flag
according to the result, but NOT changing the accumulator. The N
flag is set to bit 7 of the operand, the V flag to bit 6. Because
there is no SEV instruction, but the OS uses V to give status information
on return from some subroutines, it often does a BIT of a fixed location
in the OS which it knows will set the V bit.
> 3. WHy have a direction flag, seeing as no operations I can see are
> direcitonal?
There isn't a direction flag. I can only assume that you are talking
about the D (decimal mode) flag. This is used to indicate that all
arithmetic should be done in binary-coded decimal. It affects
ADC and SBC. It may also affect CMP, since there is an implied
subtraction in a CMP instruction. I haven't checked this, or coded
for it in my 6502 implementation. Perhaps someone else knows ?
> 4. (PC question) does, for example, mov AX,[DS:SI] use up fewer clock
> cycles than mov AX,[DS:SI]+1? I've looked in my TASM manual but I'm
> buggered if I can follow it...
Someone else will have to answer this.
> 5. What do PHP/PLP do?
PHP pushes the processor status register onto the stack. PLP pulls it
off again.
> 6. What does RTI do?
RTI is used to return from an interrupt handling routine. When an
IRA or NMI occurs, the PC and then the status register (with the B
flag cleared) are pushed onto the stack (note that unlike the JSR
instruction, which pushes the address of the high-byte of the operand
onto the stack, IRQs push the true address of the next instruction to
be executed). The I flag is then set in the SR and the PC set to the
address in 0xfffe/0xffff.
RTI is similar to RTS, but it unstacks the SR as well as the PC.
FYI, BRK behaves the same as a hardware IRQ, but does not clear the
B flag in the SR image pushed onto the stack. BASIC uses the BRK
instruction to generate errors, and this is how the OS can tell real
hardware IRQs from the software IRQ generated by a BRK.
James.
--
"Yield to temptation -- |
it may not pass your way again" | jfid@...
|
- Lazarus Long | James Fidell