implmenting more opcodes

This commit is contained in:
Thiago Auler 2017-11-14 16:06:51 -02:00 committed by GitHub
parent 57159c7484
commit bb31cc3386
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 36 additions and 1 deletions

View File

@ -100,7 +100,7 @@ void adc()
{ {
// add memory to accumalator with carry // add memory to accumalator with carry
fetch_operand(); fetch_operand();
ac = ac + operand + C_IS_SET; ac = adder(ac, operand + C_IS_SET);
} }
void and() void and()
@ -108,6 +108,7 @@ void and()
// and memory with accumulator // and memory with accumulator
fetch_operand(); fetch_operand();
ac = ac & operand; ac = ac & operand;
adjustNZ(ac);
} }
void asl() void asl()
@ -115,6 +116,7 @@ void asl()
// shift left one bit (memory or accumulator) // shift left one bit (memory or accumulator)
fetch_operand(); fetch_operand();
operand = operand << 1; operand = operand << 1;
adjustNZ(operand);
} }
void bcc() void bcc()
@ -257,16 +259,23 @@ void cpy()
void dec() void dec()
{ {
// decrement memory by one // decrement memory by one
operand = operand - 1;
write_mem(address, operand);
adjustNZ(operand);
} }
void dex() void dex()
{ {
// decrement index x by one // decrement index x by one
x = x - 1;
adjustNZ(x);
} }
void dey() void dey()
{ {
// decrement index y by one // decrement index y by one
y = y - 1;
adjustNZ(y);
} }
void eor() void eor()
@ -285,12 +294,14 @@ void inx()
{ {
// increment index x by one // increment index x by one
x = x + 1; x = x + 1;
adjustNZ(x);
} }
void iny() void iny()
{ {
// increment index y by one // increment index y by one
y = y + 1; y = y + 1;
adjustNZ(y);
} }
void jmp() void jmp()
@ -316,16 +327,19 @@ void jsr()
void lda() void lda()
{ {
// load accumulator with memory // load accumulator with memory
ac = operand;
} }
void ldx() void ldx()
{ {
// load index x with memory // load index x with memory
x = operand;
} }
void ldy() void ldy()
{ {
// load index y with memory // load index y with memory
y = operand;
} }
void lsr() void lsr()
@ -391,59 +405,80 @@ void sbc()
void sec() void sec()
{ {
// set carry flag // set carry flag
C_SET;
} }
void sed() void sed()
{ {
// set decimal flag // set decimal flag
D_SET;
} }
void sei() void sei()
{ {
// set interrupt disable status // set interrupt disable status
I_SET;
} }
void sta() void sta()
{ {
// store accumulator in memory // store accumulator in memory
write_mem(address, ac);
adjustNZ(y);
} }
void stx() void stx()
{ {
// store index x in memory // store index x in memory
write_mem(address, x);
adjustNZ(x);
} }
void sty() void sty()
{ {
// store index y in memory // store index y in memory
write_mem(address, y);
adjustNZ(y);
} }
void tax() void tax()
{ {
// transfer accumulator to index x // transfer accumulator to index x
x = ac;
adjustNZ(x);
} }
void tay() void tay()
{ {
// transfer accumulator to index y // transfer accumulator to index y
y = ac;
adjustNZ(y);
} }
void tsx() void tsx()
{ {
// transfer stack pointer to index x // transfer stack pointer to index x
x = sp;
adjustNZ(x);
} }
void txa() void txa()
{ {
// transfer index x to accumulator // transfer index x to accumulator
ac = x;
adjustNZ(x);
} }
void txs() void txs()
{ {
// transfer index x to stack pointer // transfer index x to stack pointer
sp = x;
adjustNZ(x);
} }
void tya() void tya()
{ {
// transfer index y to accumulator // transfer index y to accumulator
ac = y;
adjustNZ(y);
} }