mirror of
https://github.com/thiagoauler/apple1.git
synced 2024-06-02 20:41:37 +00:00
Merge branch 'master' of github.com:thiagoauler/apple1
This commit is contained in:
commit
6651b76f61
BIN
doc/Cassette Interface.pdf
Normal file
BIN
doc/Cassette Interface.pdf
Normal file
Binary file not shown.
BIN
doc/Operation Manual.pdf
Normal file
BIN
doc/Operation Manual.pdf
Normal file
Binary file not shown.
|
@ -68,11 +68,40 @@ void fetch_operand()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void adjustNZ(db a)
|
||||||
|
{
|
||||||
|
if (a == 0) { Z_SET; } else { Z_UNSET;}
|
||||||
|
a = a >> 7;
|
||||||
|
if (a == 0) { N_SET; } else { N_UNSET; }
|
||||||
|
}
|
||||||
|
|
||||||
|
db adder(db a, db b)
|
||||||
|
{
|
||||||
|
db r = a + b;
|
||||||
|
|
||||||
|
// todo: adjust carry flag
|
||||||
|
// todo: adjust overflow flag
|
||||||
|
adjustNZ(r);
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
db subtractor(db a, db b)
|
||||||
|
{
|
||||||
|
db r = a - b;
|
||||||
|
|
||||||
|
// todo: adjust carry flag
|
||||||
|
// todo: adjust overflow flag
|
||||||
|
adjustNZ(r);
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
void adc()
|
void adc()
|
||||||
{
|
{
|
||||||
// add memory to accumulator with carry
|
// add memory to accumulator with carry
|
||||||
fetch_operand();
|
fetch_operand();
|
||||||
ac = ac + operand + C_IS_SET;
|
ac = adder(ac, operand + C_IS_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
void and()
|
void and()
|
||||||
|
@ -80,6 +109,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()
|
||||||
|
@ -87,6 +117,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()
|
||||||
|
@ -229,16 +260,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()
|
||||||
|
@ -257,12 +295,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()
|
||||||
|
@ -288,16 +328,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()
|
||||||
|
@ -363,59 +406,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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user