Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
It is possible to read the state of the flags with basic
#1
Hi  Smile

In assembler there is a register that have the state of the flags zero, carry , etc

It is possible to read the state of the flags ONLY WITH BASIC (NOT ASSEMBLER) or the state of the carry flag, zero flag etc
Reply
#2
No, you need to use assembler (in fact it's difficult even in assembler to read the entire flag without changing them). You can get them for example:
Code:
DIM flags as Ubyte

#define save_flags \
    ASM \
    push af \
    pop hl \
    ld a, l \
    ld (._flags), a \
    END ASM

REM Now you can save flags at any moment with this macro
...
LET a = 5: save_flags: PRINT "Flags: "; flags

You can also create a function if you feel more comfortable, but will require also assembler, and I'm not sure if flags will be altered when jumping
into the function:

Code:
function fastcall get_flags as Ubyte
  ASM
  push af
  pop hl
  ld a, l
  END ASM
end function

PRINT "Flags: "; get_flags

Perhaps you might find this useful?? Rolleyes
Reply
#3
(09-08-2021, 09:31 AM)boriel Wrote: No, you need to use assembler (in fact it's difficult even in assembler to read the entire flag without changing them). You can get them for example:
Code:
DIM flags as Ubyte

#define save_flags \
    ASM \
    push af \
    pop hl \
    ld a, l \
    ld (._flags), a \
    END ASM

REM Now you can save flags at any moment with this macro
...
LET a = 5: save_flags: PRINT "Flags: "; flags

You can also create a function if you feel more comfortable, but will require also assembler, and I'm not sure if flags will be altered when jumping
into the function:

Code:
function fastcall get_flags as Ubyte
  ASM
  push af
  pop hl
  ld a, l
  END ASM
end function

PRINT "Flags: "; get_flags

Perhaps you might find this useful?? Rolleyes

thanks for the answer
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)