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

Re: Page Boundary Question



    Let me say.

    Carry should be present when 20FF goes into 2100.  It does not mean to
use Carry Flag.  Carry Flag is never used for operation.  I think that
secondary Carry Flag is in 9th bit before NV11DIZC.  9th bit is always
invisible that it is used for operation.
    For example, low byte FF adds 1 to become 00.  High byte receives 9th
Carry Bit before 9th Carry Bit is added into high byte 20 that is now 21.
It shows 2100.  It is how operation tells to add one extra cycle.
    Low byte subtracts 1 to become FF.  High byte receives 9th Carry Bit
before 9th Carry Bit is added into high byte 20 that is now 1F.  It shows
1FFFF.
    Look at 80x86 code example.

    mov eax,02000h
    mov ebx,00001h
    sub al,bl      ; sub turns on Carry Bit for sbb
    sbb ah,bh    ; sbb detects Carry Bit before 1 is subtracted.

    mov eax,02000h
    mov ebx,00001h
    add al,bl    ; add turns on Carry Bit for adc
    adc ah,bh    ; adc detects Carry Bit before 1 is added.

    It is how 80x86 use Carry Bit rather than Carry flag to determine two
bytes by forming one word.  It is how it is designed to work.  Like 6502
does that.  6502 is not designed to add/subtract word, but it is designed to
use only low byte and high byte.  9th Carry Bit is required to use
operation.  9th Carry Bit can be used to add one extra cycle if page
boundary is acrossed.
    Does it make sense?

Bryan Parkoff




"Michael J. Mahon" <mjmahon@aol.com> wrote in message
20030617201930.06564.00000894@mb-m17.aol.com">news:20030617201930.06564.00000894@mb-m17.aol.com...
> Bryan Parkoff asked:
>
> >    I understand that 6502 can only add one extra cycle if it is across
page
> >boundaries.
> >
> >    For example,
> >
> >2000: A9 00    LDA #00
> >2002: F0 EC    BEQ 1FF0
> >
> >    If BEQ is true, it will branch to $1FF0.  Extra cycle is supposed to
be
> >added, but it didn't.
> >
> >2080: A9 00    LDA #00
> >2082: F0 7F    BEQ 2103
> >
> >    If BEQ is true, it will branch to $2103.  Extra cycle will be added.
> >($20)$82 + $7F will always show carry flag that will let cycle to know
> >before it is added.  How can 6502 know that ($20)$04 + $EC will not
always
> >show carry flag?  Please explain.  It is what 6502 Reference Manual says
> >that branch can only add one extra cycle if carry flag is present.
>
> It's easy--it just does the signed addition and tests whether there
> was a carry out.  If there was, then the high-order address byte
> must be incremented/decremented by one, and that operation
> takes the extra cycle.
>
> None of this affects the programmer-visible carry flag.
>
> -michael
>
> Check out amazing quality 8-bit Apple sound on my
> Home page:  http://members.aol.com/MJMahon/