> For the complete documentation index, see [llms.txt](https://bata-mladen.gitbook.io/bata-mladen/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bata-mladen.gitbook.io/bata-mladen/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>
