> 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="https://2490252025-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUwIKQPujWqWSVFxQaX98%2Fuploads%2FQn0CUgFOzt0QyjzgI8tL%2Fimage.png?alt=media&amp;token=5b37a2a5-cc66-400f-9f05-63465cc98058" 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="https://2490252025-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUwIKQPujWqWSVFxQaX98%2Fuploads%2F5F86ffpx5M2fNJ2gr0EW%2Fimage.png?alt=media&amp;token=fca431c4-3bf7-42bd-824a-a2af2e79db73" 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="https://2490252025-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUwIKQPujWqWSVFxQaX98%2Fuploads%2FlDNX0iGc5JsFWZSTsDRq%2Fimage.png?alt=media&amp;token=5acb8e0c-5da3-4343-bced-875344b68075" 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="https://2490252025-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUwIKQPujWqWSVFxQaX98%2Fuploads%2FX9oVyWxGoMYkXUX9wVbs%2Fimage.png?alt=media&amp;token=f0bb37a2-0830-4b4c-ab12-c5c36454c01f" 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
