Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
Indika Herath
01/11/06 08:52
Read: 666 times
Kandy
Sri Lanka


 
#107050 - Help about ADD/ADDC in a VB project
I am programming a simulator for 8051,i have some problem about the flag Altering in ADD and ADDC

'Is this Correct ?
CY, AC, OV, are function names that set the flags

For Calculating ADD we can call "ADD8(OP1,OP2)"
For Calculating ADDC we can call "ADD8(OP1,OP2,Carry)"

Public Function ADD8(ByVal Op1 As Byte, ByVal Op2 As Byte, Optional ByVal Op3 As Byte = 0) As Byte
Dim i As Integer
i = CInt(Op1) + CInt(Op2) + CInt(Op3)

ADD8 = LOW8(i)

AC (LOW4(Op1) + LOW4(Op2) + Op3) > 15

If i > 255 Then
CY True
If i < 0 Then
OV True
Else
OV False
End If
Else
OV False
CY False
End If

End Function


List of 7 messages in thread
TopicAuthorDate
Help about ADD/ADDC in a VB project      Indika Herath      01/11/06 08:52      
   all answers are in "the bible"      Erik Malund      01/11/06 09:04      
   CY AC and OC      Joseph Hebert      01/11/06 09:12      
      Reply about ADD/ADDC in a VB project      Indika Herath      01/13/06 08:29      
         AGAIN: why reinvent the wheel?      Erik Malund      01/13/06 09:12      
   did you consider      Erik Malund      01/11/06 09:27      
      He's writing a simulator?      Joseph Hebert      01/11/06 09:53      

Back to Subject List