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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/11/00 05:40
Read: times


 
#1762 - ADD instruction
Hi!

I have some problems implementing ADD
instruction in my simulator.

This is my code:

void Simikon8052::add_DATA( Simikon8052 *c, uint data, uint, uint )
{
uint acc = c->iram[ ACC ] + data;

bool carry = ( acc > 0xFF ) ? 1 : 0;
bool auxcarry =
( ( c->iram[ ACC ] & 0x0F ) +
( data & 0x0F ) > 0x0F ) ? 1 : 0;

bool overflow =
( ( ( c->iram[ ACC ] & 0x80 ) +
( data & 0x80 ) > 0x80 )
^ ( carry == 1 ) ) ? 1 : 0;

c->PC += c->activeCode[ c->PC ].bytes;
c->updateIRAM( ACC, acc );

c->setBit( C, carry );
c->setBit( AC, auxcarry );
c->setBit( OV, overflow );
}

I think that C, and AC are calculated
OK, but for overflow I'm not sure.
I don't have any other simulator so
I can't test this. Can someone tell
me some examples and, results.

Thanks in advance!

List of 3 messages in thread
TopicAuthorDate
ADD instruction            01/01/70 00:00      
RE: ADD instruction            01/01/70 00:00      
RE: ADD instruction            01/01/70 00:00      

Back to Subject List