From 7fdc20eb453ce242c11b65f6b5d4b78a23cb2d52 Mon Sep 17 00:00:00 2001 From: Crystal Date: Wed, 10 Apr 2024 21:05:54 +0100 Subject: Me when the when me me --- src/org/blog/assembly/1.org | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/org/blog/assembly/1.org b/src/org/blog/assembly/1.org index 7a712e3..102a3c0 100644 --- a/src/org/blog/assembly/1.org +++ b/src/org/blog/assembly/1.org @@ -256,8 +256,8 @@ For example: *WORD PTR [BX]* ; word access. assembler supports shorter prefixes as well: -b. - for BYTE PTR -w. - for WORD PTR +- b. - for BYTE PTR +- w. - for WORD PTR in certain cases the assembler can calculate the data type automatically. @@ -286,3 +286,14 @@ Defining constants is pretty straight forward : #+END_SRC Of course constants cant be changed, and aren't stored in memory. So they are like little macros that live in your code. + +** ⚐ : +Now comes the notion of *Flags*, which are bits in the *Status register*, which are used for logical and arithmetical instructions and can take a value of 1 or 0 . Here are the 8 flags that exist for the 8086 CPU : +- *Carry Flag(CF):* Set to 1 when there is an *unsigned overflow*, for example when you add 255 + 1( not in range [0,255] ). by default its set to 0. +- *Overflow Flag(CF):* Set to 1 when there is a *signed overflow*, for example when you add 100 + 50( not in range [-128, 128[ ). by default its set to 0. +- *Zero Flag(ZF):* Set to 1 when the result is 0. by default its set to 0. +- *Auxiliary Flag(AF):* Set to 1 when there is an *unsigned overflow* for low nibble (4bits), or in human words : when there is a carry inside the number. for example when you add 29H + 4CH , 9 + C => 15. So we carry the 1 to 2 + 4 and AF is set to 1. +- *Parity Flag(PF):* Set to 1 when the result has an even number of one bits. and 0 if it has an odd number of one bits. Even if a result is a word, only the Low 8bits are analyzed. +- *Sign Flag(SF):* Self explanatory, set to 1 if the result is negative and 0 if its positive. +- *Interrupt Enable Flag(IF):* When its set to 1, the CPU reacts to interrupts from external devices. +- *Direction Flag(DF):* When this flag is set to 0, the processing is done forward, if its set to 1, its done backward. -- cgit 1.4.1-2-gfad0 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43