TIP: Click on subject to list as thread! ANSI
echo: power_bas
to: ALL
from: REINIER ZWITSERLOOT
date: 1998-05-18 11:44:00
subject: Re: `CF` & Interrupt List

From: Reinier Zwitserloot 
Subject: Re: 'CF' & Interrupt List
 
There is a third *EXTREMELY* helpful statement to work with the carry
flag, and it's SALC. It's undocumented but available and stable on every
single intel processor. What it does:
 
Set AL to 00 if carry is clear, or set AL to 0xFF (=0FFh=&hFF=255) if
the carry flag is set. I doubt the PB internal assembler supports it as
it's undocumented and not until recently declared 'stable' by intel. use
PBPLUS:
 
$PTNASM
SALC
$PTPBAS
 
or alternatively insert this for a SALC instruction:
!db &hD6
 
NB: SALC is sometimes called SETALC (ie: Set AL according to Carry flag)
and only NASM currently supports it. The main use is for HLLs (just like
what we are talking about here :-P).
 
In functions that return a byte, the function return is kept in AL. So,
if you want to make the carry flag known to the user, simply turn your
inline sub into a function (or if you are programming an .OBJ change the
declaration, that's all you need to do) and use SALC before returning.
Fast, compact, and easy.
 
 
paul pigott wrote:
>
> Marc van den Dikkenberg wrote:
> >
> > I'm using Ralf Brown's interrupt list to do some low-level thing with
> > PowerBasic... So far,e verything works the way it should.
> >
> > I'm wondering about one thing, though: in a lot of entries, a 'CF' is
> > mentioned, mostly for detecting whether or not the operation was 
succesful.
> > 'CF set on error' / 'CF clear if succesful'
> >
> > Are they talking about CX, part of CX, or something totally different?
> > As far as I'm aware, there is no 'CF' register... Or is there?
> > --
> > Marc van den Dikkenberg
> > -----------------------
> > The PowerBasic Archives
> > http://www.xs4all.nl/~excel/pb.html
>
> The CF stands for "CARRY FLAG".  It's actually one particular bit in the
> FLAGS register (which one I don't offhand recall).  Its basic use, as
> you might surmise, is in arithmetic, indicating whether a mathematical
> carry (as in "carry the one") or borrow has occurred.  However, in a
> number of interrupt operations, it's used to indicate the success, or
> lack thereof, of a particular operation.  There are a two assembler
> mnemonics to test the carry flag, JC and JNC to be precise:  "Jump If
> Carry" and "Jump If Not Carry".
>
> Hope this helps.
>
> Paul Pigott
> paul.pigott@worldnet.att.net
 
--
- Ray Zwitserloot.
 
R.Zwitserloot@antispam.BTInternet.com
 Change the E-mail address to reply!
 
----------------------------------------------------
 
*** QwkNews (tm) v2.1
 * [TN71] alt.lang.powerbasic  POWER_BAS Gateway
--- GEcho 1.20/Pro
---------------
* Origin: Toast House Remote (1:100/560.2)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.