> For the complete documentation index, see [llms.txt](https://digitalgarden.batamladen.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://digitalgarden.batamladen.com/notes/programming/assembly/assembly-8086/examples-projects/flags-practice.md).

# Flags Practice

## CF (Carry Flag)

When we have two 8-bit numbers in a calculation, and the result is more than 8 bits (9 for example) than the carry flag is 1\
If we have two 16-bit numbers in a calculation, and the result is more than 16 bits (17) than the carry flag is 1

<figure><img src="/files/JowtNZk6OB1qQqE0YSHS" alt=""><figcaption></figcaption></figure>

***

## ZF (Zero Flag)&#x20;

When the result is 0, zero flag is 1

***

## SF (Sign Flag)

If the result in a calculation has the MSB (most significant bit) 1, than the sign flag is 1. \
If we have a carry flag up, a bigger result than 8-bit, the carry flag does not determine the sign flag, the sign flag is 1 only if the msb of the 8-bit is 1.

<figure><img src="/files/kOxYHObXUdn1WQZArKI6" alt=""><figcaption></figcaption></figure>

***

## Overflow Flag

This flag is up if in a calculation, the MSB of the first number is different than the result MSB.

<figure><img src="/files/FzNqKMmVZZ0NYN6zY6Oo" alt=""><figcaption></figcaption></figure>

***

## Parity Flag

If the number of 1s in the result is paired (2, 4, 6, 8) the flag is up \
If we have 16-bit situation, the Least significant byte is looked (last 8 bits)

<figure><img src="/files/jREqsQP6Ajhzq65AvHTW" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://digitalgarden.batamladen.com/notes/programming/assembly/assembly-8086/examples-projects/flags-practice.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
