??? 01/13/06 15:29 Read: times |
#107300 - Reply about ADD/ADDC in a VB project Responding to: ???'s previous message |
Sorry for the confusion
CY ,AC ,OV were user defined functions that has the format In VB [Name(State as Boolean)] equal in C to [void name(Bool state);] I wrote these functions to set the correct bits in PSW in the simulator. So if I want to set the OV flag In VB [OV(True)] equal in C to [OV(1);] Can you give me a mathematical algorithm to perform the ADD,ADDC,SUBB functions in C or Visual Basic including Altering of the state flags ? My current definition for ADD function is this (in VB) 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 CY i > &HFF OV (i > &HFF) Xor (((Op1 And &H7F) + (Op2 And &H7F) + Op3) > &H7F) End Function SFR is a structure that hold individual register values To perform ADD A,R0 SFR.ACC=ADD8(SFR.ACC,SFR.R0) To perform ADDC A,R0 GetCarry() is also a user defined function that returns the state of the carry flag as 1 or 0 SFR.ACC=ADD8(SFR.ACC,SFR.R0,GetCarry()); Also in vb the Hex notation is different &HFF is equal in c to FFh &H7F is equal in c to 7Fh I hope this information will give you a clear view. Thank you! |
Topic | Author | Date |
Help about ADD/ADDC in a VB project | 01/01/70 00:00 | |
all answers are in "the bible" | 01/01/70 00:00 | |
CY AC and OC | 01/01/70 00:00 | |
Reply about ADD/ADDC in a VB project | 01/01/70 00:00 | |
AGAIN: why reinvent the wheel? | 01/01/70 00:00 | |
did you consider | 01/01/70 00:00 | |
He's writing a simulator? | 01/01/70 00:00 |