6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Wed Nov 13, 2024 2:53 am

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Fri Feb 10, 2006 2:35 pm 
Offline

Joined: Sun Feb 05, 2006 1:20 am
Posts: 21
Location: The Netherlands
Hi, new member here.

As far as I know, the overflow bit doesn't affect any instruction in the 6502 and 6510 CPUs. Hence, there seems to be no point in clearing the V bit explicitly.
Is there a useful purpose for CLV anyhow? After all, there are no instructions for setting V, setting Z or clearing Z either.
Am I overlooking anything?

_________________
I trust my somewhat flawed English is comprehensible to all.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Feb 10, 2006 2:58 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1746
Location: Sacramento, CA
Actually, your English is excellent.

The 6502 has an input pin labeled SOB, pin 38. Here is an excerpt from the WDC 65C02 datasheet:
Quote:
A negative transition on the Set Overflow (SOB) pin sets the overflow bit (V) in the status code register. The signal is sampled on the rising edge of PHI2. SOB was originally intended for fast input recognition because it can be tested with a branch instruction; however, it is not recommended in new system design and was seldom used in the past.


Its safe to assume that the CLV instruction is used to reset this status register bit after the SOB input is detected.

Hope that clears this up!

Daryl


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Feb 10, 2006 7:41 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8540
Location: Southern California
The overflow flag tells if the sign bit of a signed arithmetic result is wrong. You'll see the earlier discussion on this if you down, under "General Discussions", down to "Carry and Overflow flags..." The URL is: http://www.6502.org/forum/viewtopic.php?t=62 . C and Z are touched on there too, but not with the same emphasis as V. When you're ready for more confusion, there's another one where we discussed the (in)validity of V in decimal arithmetic!

Welcome to the forum.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Feb 10, 2006 11:19 pm 
Offline

Joined: Sun Feb 05, 2006 1:20 am
Posts: 21
Location: The Netherlands
8BIT wrote:
The 6502 has an input pin labeled SOB, pin 38. <snip> ...

So that's what I forgot all about. Thanks for reminding me. The R6502 datasheet doesn't advise against using it, but I can see why 65C02 does.
Still CLV serves no purpose for the 6510.

@Garth:
Thanks for your welcome.
I'm familiar with the purpose of the overflow flag, but I was strictly referring to it not being an input parameter for any instruction.

_________________
I trust my somewhat flawed English is comprehensible to all.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Feb 11, 2006 6:37 am 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
Remember too that, after detecting an overflow, you can take actions to correct the overflow, and use CLV to "reset" the condition so that you can resume your calculation and detect another overflow event. This won't likely be used except in multi-precision, fixed-point, signed integer math though.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Feb 11, 2006 9:01 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8540
Location: Southern California
Would there be any reason to clear it though, since each test of the flag (by conditional branching) will reflect the result of the last ADC or SBC (or BIT, PLP or RTI, TSB, or TRB)? None of these instructions care what it was going in, or leave the initial V value intact.

> Is there a useful purpose for CLV anyhow?

Apart from using it conjunction with SO\ (which again, has hardly ever been done and is not recommended), the only thing I can think of so far is unconditional branching on the NMOS 6502 which lacked the CMOS 65c02's BRA instruction. Before I started using the CMOS one in 1986, I occasionally did CLV BVC to substitute.

> After all, there are no instructions for setting V, setting Z or clearing Z either.

Not directly, but you can, if you must, do something like
Code:
PHP
PLA
ORA #01000000B
PHA
PLP
for example


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Feb 11, 2006 4:41 pm 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
The 65C816 also includes the SEP and REP instructions. SEP can be used to set the V flag directly now, so as with C, it too can be used to indicate function return status (e.g., as the Commodore Kernal did to indicate errors).

Although, you could also set the V flag manually too this way (which is only 1 cycle longer than SEP):

Code:
LDA #$40
ADC #$40


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: