Board index » delphi » registers in TP

registers in TP

I've got a specification document that tells me how to call certain
functions on Interrupt 15h.  It states that if the function is
successful the carry flag will equal 0.  Otherwise it will equal 1.

When I try the following bit of code I get a Compile Error 44 (field
identifier expected).
if regs.cy = 0 then begin
  {report on the state of interesting registers}
end;
I suspect this carry flag goes by a different name than CY.  How do I
access that flag so that I can do error checking on the function I'm
calling?
--
Remove the Beer from my address to reply by e-mail

 

Re:registers in TP


Quote
Steven Krise wrote:

> I've got a specification document that tells me how to call certain
> functions on Interrupt 15h.  It states that if the function is
> successful the carry flag will equal 0.  Otherwise it will equal 1.

> When I try the following bit of code I get a Compile Error 44 (field
> identifier expected).
> if regs.cy = 0 then begin
>   {report on the state of interesting registers}
> end;

CY is a bit in the Regs.Flags word. Look in your F1 help file for more
info about using the flags and in a 8086 manual!

if (Regs.Flags and 1) = 0 then

Quote
> I suspect this carry flag goes by a different name than CY.  How do I
> access that flag so that I can do error checking on the function I'm
> calling?
> --
> Remove the Beer from my address to reply by e-mail

It is better to drink it!

Regards,
Franz Glaser
http://members.eunet.at/meg-glaser

Re:registers in TP


JRS:  In article <3553105E.5...@LAGERibm.net> of Fri, 8 May 1998
10:02:06 in comp.lang.pascal.borland, Steven Krise <skr...@LAGERibm.net>
wrote:

Quote
>I've got a specification document that tells me how to call certain
>functions on Interrupt 15h.  It states that if the function is
>successful the carry flag will equal 0.  Otherwise it will equal 1.

>When I try the following bit of code I get a Compile Error 44 (field
>identifier expected).
>if regs.cy = 0 then begin
>  {report on the state of interesting registers}
>end;
>I suspect this carry flag goes by a different name than CY.  How do I
>access that flag so that I can do error checking on the function I'm
>calling?

See the Online Help (^F1) for Registers and Flag.  You need to test the
relevant bit of regs.Flags : fCarry=$0001.  For efficient bit-testing,
see
        http://www.merlyn.demon.co.uk/pas-time.htm#Opt  Bit testing

AFAIR, the best is
        if not (fCarry in WordSet(regs.Flags)) then <interesting> ;

--
John Stockton, Surrey, UK.    j...@merlyn.demon.co.uk    Turnpike v1.12    MIME.
  Web <URL: http://www.merlyn.demon.co.uk/> - TP/BP/&c. FAQqish topics & links.
  Timo's TurboPascal <A HREF="ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip">FAQ</A>.
  <A HREF="http://www.merlyn.demon.co.uk/clpb-faq.txt">Mini-FAQ</A> of c.l.p.b.

Re:registers in TP


In article <35536B4D.6AFF...@eunet.at>,
Ing. Franz Glaser <meg-gla...@eunet.at> wrote:

Quote
>Steven Krise wrote:

>> I've got a specification document that tells me how to call certain
>> functions on Interrupt 15h.  It states that if the function is
>> successful the carry flag will equal 0.  Otherwise it will equal 1.

>> When I try the following bit of code I get a Compile Error 44 (field
>> identifier expected).
>> if regs.cy = 0 then begin
>>   {report on the state of interesting registers}
>> end;

>CY is a bit in the Regs.Flags word. Look in your F1 help file for more
>info about using the flags and in a 8086 manual!

>if (Regs.Flags and 1) = 0 then

Or one could use   if (regs.flags and fcarry)=0 then ...

Osmo

Re:registers in TP


JRS:  In article <35536B4D.6AFF...@eunet.at> of Fri, 8 May 1998 22:30:05
in comp.lang.pascal.borland, "Ing. Franz Glaser" <meg-gla...@eunet.at>
wrote:

Quote
>CY is a bit in the Regs.Flags word. Look in your F1 help file for more
>info about using the flags and in a 8086 manual!

>if (Regs.Flags and 1) = 0 then

That can be written to give 3 bytes less code, and IMHO more readably :

uses Dos ;
type Flags = (Carry, b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) ;
FlagSet = Set of Flags ;
var Regs : registers ; Z : byte ;
begin
  if (Regs.Flags and 1) = 0 then Z := 0 ;
  if not (Carry in FlagSet(Regs.Flags)) then Z := 0 ;
  end.

PROGRAM.6: if (Regs.Flags and 1) = 0 then Z := 0 ;
  cs:000F A16200         mov    ax,[0062]
  cs:0012 250100         and    ax,0001
  cs:0015 09C0           or     ax,ax
  cs:0017 7505           jne    PROGRAM.7 (001E)
  cs:0019 C606640000     mov    byte ptr [0064],00
PROGRAM.7: if not (Carry in FlagSet(Regs.Flags)) then Z := 0 ;
  cs:001E F606620001     test   byte ptr [0062],01
  cs:0023 7505           jne    PROGRAM.8 (002A)  
  cs:0025 C606640000     mov    byte ptr [0064],00
PROGRAM.8: end.
  cs:002A                                    

Set operations seem well-optimised in BP7.

--
John Stockton, Surrey, UK.    j...@merlyn.demon.co.uk    Turnpike v1.12    MIME.
  Web <URL: http://www.merlyn.demon.co.uk/> - TP/BP/&c. FAQqish topics & links.
  Timo's TurboPascal <A HREF="ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip">FAQ</A>.
  <A HREF="http://www.merlyn.demon.co.uk/clpb-faq.txt">Mini-FAQ</A> of c.l.p.b.

Re:registers in TP


Quote
> >if (Regs.Flags and 1) = 0 then

> Or one could use   if (regs.flags and fcarry)=0 then ...

To test the fCarry-flag, I use

  If Odd(reg.flags) Then Error;

Other Threads