Showing posts with label flag-register. Show all posts
Showing posts with label flag-register. Show all posts

Wednesday, May 19, 2010

IP and FLAG register's function

Question
What are the functions of IP and FLAG register?



Answers

Flag register - Flag register function is to record few parameter or characteristic from the last aritmetic/logic instruction. Flag register include zero flag,parity flag,carry flag,auxiliary carry flag, sign flag and overflow flag

IP register - IP is Instruction Pointer. Its function is the same as PC (program counter) in other microprocessor which is to point to the next instruction to be fetched by BIU unit to be feed into EU unit.

Thursday, May 13, 2010

Flag Value (CF,PF,AF,ZF & CF) Tutorial

Question
State the final flag's value (CF, PF, AF, ZF & SF) for the operation given below. Explain the reason.
MOV AH, 9CH
MOV AL, 64H
ADD AH, AL

Answer
9C16 =  1001 11002
6416 =  0110 01002

AH + AL--> AH
AH = 9C16+6416 = 1 0000 00002 (number 1 is not included because the register size is only 8 bit,therefore the AH final value is 0016)

CF = 1 (got carry from D7)
PF = 1 (the number of 1 is even)
AF = 1 (got carry from D3 to D4)
ZF = 1 (because the final value is zero
SF = 0 (because the value at D15 is zero)

Tuesday, May 11, 2010

Adding 64 bits of data tutorial

Question
Show how to add the following two 64 bits of data using 8088/8086 assembly programming . The final answer must be located at CX-DX combination. Then show the final value of CF,PF,ZF,SF and AF flags.

X=4322FFFFh
Y=43210001h

Answer:

     CX DX
+   AX BX
------------
     CX DX
------------

DX+BX can be done using the normal ADD DX,BX. However DX + BX might have a carry result that should be added to the following CX+AX. Therefore to ensure the carry bit (if there is a carry) is added to the following segment ADC (ADD with Carry) must be used.

So the code for this program will be

ADD DX,BX
ADC CX,AX

4322FFFF16=  0100 0011 0010 0010 1111 1111 1111 11112
4321000116 =  0100 0011 0010 0001 0000 0000 0000 00012


  0100 0011 0010 0010 1111 1111 1111 1111

+0100 0011 0010 0001 0000 0000 0000 0001
-------------------------------------------------
  1000 0110 0100 0100 0000 0000 0000 0000 = 8644000016
-------------------------------------------------

Therefore (check the second set/second command/ADC only)
SF=1 (the sign bit is number 1)
CF=0 (no carry) 
PF=0 (number of 1 is odd)
ZF=0 (result not zero)
AF = 0 (there is carry from bit 3 to bit 4)

Popular Posts

Latest Post from my Other Blog