| 1. |
Flag Control Instructions |
|
Answer» Flag Control Instructions : Mnemonic Meaning Operation Flags affected LAHF Load AH from flags (AH)←Flags None SAHF Store AH into flags (flags) ← (AH) SF,ZF,AF,PF,CF CLC Clear carry flag (CF) ← 0 CF STC Set carry flag (CF) ← 1 CF CMC Complement carry flag (CF) ← (CF) CF CLI Clear interrupt flag (IF) ← 0 IF STI Set interrupt flag (IF) ← 1 IF Fig. : Flag control Instructions 31 The first two instructions LAHF and SAHF can be used either to read the flags or to change them respectively notice that the data transfer that takes place is always between the AH register and flag register. For instance, we may want to start an operation with certain flags set or reset. Assume that we want to preset all flags to logic 1. To do this we can first load AH with FF and then execute the SAHF instruction. Example :Write an instruction sequence to save the contents of the 8086’s flags in memory location MEM1 and then reload the flags with the contents of memory location MEM Assume that MEM1 and MEM2 are in the same data segment defined by the current contents of DS. LAHF : Load current flags in AH register MOV (MEM1), AH : Save in (MEM1) MOV AH, (MEM2) : Copy the contents of (MEM2) SAHF : Store AH contents into the flags. |
|