Stupid Arithmetic Compare / Carry Flag question
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2004-12-26 9:24 PM
Posted on December 27, 2004 at 06:24
Stupid Arithmetic Compare / Carry Flag question
Labels:
- Labels:
-
Legacy Products
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2004-12-26 6:32 AM
Posted on December 26, 2004 at 15:32
Have a simple question that I cannot find in the ST7 programming manual or any support documentation. Does anyone know the relationship of the carry flag to the Arithmetic Compare command?
CP A,#$09 The reason I ask, is because the 6500 code I am converting uses what seems to be the same command which would be CMP #$09 The 6500 sets the carry flag if the memory (in this case the number 9) is less than or equal to the A register. From what I can tell with simple programs, it looks like ST arithmetic compare sets the Carry Flag if the memory is greater than the A register. Very confusing.Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2004-12-26 9:24 PM
Posted on December 27, 2004 at 06:24The carry-flag is meant to be a borrow-flag in the CP instruction of ST7 controllers. It is set when dst < src at CP dst,src (--> dst-src). You can see it analogous to the SUB, SBC commands. To subtract a double byte number you will use e.g. ... sub A,LSByte ld A,X sbc A,MSByte ld X,A ... With the relationship of SBC dst,src : dst <-- dst-src-C it won't work but with the described relation. Pay attention to the DEC and INC commands as the carry flag is unaffected there . Regards WoRo
