Board index » delphi » FLAGS-register in asm?

FLAGS-register in asm?

Hi,

Can anyone tell me how to get the FLAGS-register

type
    (Registers record used by Intr and MsDos)
  Registers = record
    case Integer of
    0: (AX, BX, CX, DX, BP, SI, DI, DS, ES, Flags: Word);   <=
    1: (AL, AH, BL, BH, CL, CH, DL, DH: Byte);
  end;

out of asm?

I'm using the BIOS-keyboard interrupt to write a keypressed-function, but I
have to get the flags-register, and I DONT want to use any units in the
unit... (I dont want to use the DOS unit to call intr)

please help.
{ e-mail me : Jori...@glo.Be }

 

Re:FLAGS-register in asm?


"Joris de Gruyter" <cd01...@glo.be> wrote:

Quote
>Can anyone tell me how to get the FLAGS-register
>out of asm?
>I'm using the BIOS-keyboard interrupt to write a keypressed-function, but I
>have to get the flags-register, and I DONT want to use any units in the
>unit... (I dont want to use the DOS unit to call intr)

Just use this code:

        PUSHF
        POP     AX      ; Gotta flags in AX - Does unit DOS too!

Wottie
"World Wide Wottie"

Re:FLAGS-register in asm?


"Joris de Gruyter" <cd01...@glo.be> wrote:

Quote
>Hi,

>Can anyone tell me how to get the FLAGS-register

>type
>    (Registers record used by Intr and MsDos)
>  Registers = record
>    case Integer of
>    0: (AX, BX, CX, DX, BP, SI, DI, DS, ES, Flags: Word);   <=
>    1: (AL, AH, BL, BH, CL, CH, DL, DH: Byte);
>  end;

>out of asm?

>I'm using the BIOS-keyboard interrupt to write a keypressed-function, but I
>have to get the flags-register, and I DONT want to use any units in the
>unit... (I dont want to use the DOS unit to call intr)

Do you really need to get the flags register or do you simply want
to use the information in the flags register?  Thing about this
for a moment and realize that there are many instructions that
respond to the state of the various flag bits.

For example, if you where thinking in terms of Pascal you might
code the following:

        mov  AH,1
        int  16h
        pushf           { push flags register }
        pop   AX        { pop flags into AX   }
        rol   AL,2      { move zero flag to 0-bit }
        and   AL,1      { make boolean on zero flag }

or, if you were familiar with LAHF instruction

        mov  AH,1
        int  16h
        lahf            { move lags into AH }
        rol   AX,2      { move zero flag to 0-bit }
        and   AL,1      { make boolean on zero flag }

OTOH, thinking in terms of assembler you might use:

        mov  AH,1
        int  16h
        jz   @noKey
        ...

and if you needed a Pascal boolean result, you might use:

        mov  AH,1
        int  16h
        mov  AL,0       { make FALSE w/o affecting flags }
        jz   @@1
        inc  AL         { make TRUE if zero flag NOT set }

    ...red

Re:FLAGS-register in asm?


Quote
Joris de Gruyter wrote:
> Hi,

> Can anyone tell me how to get the FLAGS-register

> type
>     (Registers record used by Intr and MsDos)
>   Registers = record
>     case Integer of
>     0: (AX, BX, CX, DX, BP, SI, DI, DS, ES, Flags:
> Word);   <=
>     1: (AL, AH, BL, BH, CL, CH, DL, DH: Byte);
>   end;

> out of asm?

> I'm using the BIOS-keyboard interrupt to write a
> keypressed-function, but I
> have to get the flags-register, and I DONT want to use any
> units in the
> unit... (I dont want to use the DOS unit to call intr)

> please help.
> { e-mail me : Jori...@glo.Be }

Well, U just need 2 push the flag register 2 the stack, &
then pop it 2 the ax or any other register.

        Have fun
           Tal

Other Threads