mirror of
https://github.com/pevans/erc-c.git
synced 2024-12-21 23:29:16 +00:00
Documentation
This commit is contained in:
parent
46fedccce1
commit
fca069d5de
@ -5,11 +5,26 @@
|
|||||||
#include "mos6502.h"
|
#include "mos6502.h"
|
||||||
#include "mos6502.enums.h"
|
#include "mos6502.enums.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The and instruction will assign the bitwise-and of the accumulator
|
||||||
|
* and a given operand.
|
||||||
|
*/
|
||||||
DEFINE_INST(and)
|
DEFINE_INST(and)
|
||||||
{
|
{
|
||||||
cpu->A &= oper;
|
cpu->A &= oper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is the "arithmetic" shift left instruction.
|
||||||
|
*
|
||||||
|
* Here we will shift the contents of the given operand left by one bit.
|
||||||
|
* If the operand was the accumulator, then we'll store it back there;
|
||||||
|
* if not, we will store it in the last effective address in memory.
|
||||||
|
*
|
||||||
|
* Note that we use the carry bit to help us figure out what the "last
|
||||||
|
* bit" is, and whether we should now set the carry bit as a result of
|
||||||
|
* our operation.
|
||||||
|
*/
|
||||||
DEFINE_INST(asl)
|
DEFINE_INST(asl)
|
||||||
{
|
{
|
||||||
cpu->P &= ~CARRY;
|
cpu->P &= ~CARRY;
|
||||||
@ -26,6 +41,11 @@ DEFINE_INST(asl)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The bit instruction will test a given operand for certain
|
||||||
|
* characteristics, and assign the negative, overflow, and/or carry bits
|
||||||
|
* in the status register as a result.
|
||||||
|
*/
|
||||||
DEFINE_INST(bit)
|
DEFINE_INST(bit)
|
||||||
{
|
{
|
||||||
cpu->P &= ~NEGATIVE;
|
cpu->P &= ~NEGATIVE;
|
||||||
@ -45,11 +65,22 @@ DEFINE_INST(bit)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Compute the bitwise-exclusive-or between the accumulator and operand,
|
||||||
|
* and store the result in A.
|
||||||
|
*/
|
||||||
DEFINE_INST(eor)
|
DEFINE_INST(eor)
|
||||||
{
|
{
|
||||||
cpu->A ^= oper;
|
cpu->A ^= oper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is pretty similar in spirit to the ASL instruction, except we
|
||||||
|
* shift right rather than left.
|
||||||
|
*
|
||||||
|
* Note that the letters in the instruction stand for "logical" shift
|
||||||
|
* right.
|
||||||
|
*/
|
||||||
DEFINE_INST(lsr)
|
DEFINE_INST(lsr)
|
||||||
{
|
{
|
||||||
cpu->P &= ~CARRY;
|
cpu->P &= ~CARRY;
|
||||||
@ -66,11 +97,20 @@ DEFINE_INST(lsr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Compute the bitwise-or of the accumulator and operand, and store the
|
||||||
|
* result in the A register.
|
||||||
|
*/
|
||||||
DEFINE_INST(ora)
|
DEFINE_INST(ora)
|
||||||
{
|
{
|
||||||
cpu->A |= oper;
|
cpu->A |= oper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This instruction is interesting; it's a _rotation_ left, which means
|
||||||
|
* that what was in the 8th bit will move to the 1st bit, and everything
|
||||||
|
* else moves down one place.
|
||||||
|
*/
|
||||||
DEFINE_INST(rol)
|
DEFINE_INST(rol)
|
||||||
{
|
{
|
||||||
CARRY_BIT();
|
CARRY_BIT();
|
||||||
@ -92,6 +132,10 @@ DEFINE_INST(rol)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Here it's a rotation to the right, just like the ROL instruction. All
|
||||||
|
* bits are maintained.
|
||||||
|
*/
|
||||||
DEFINE_INST(ror)
|
DEFINE_INST(ror)
|
||||||
{
|
{
|
||||||
CARRY_BIT();
|
CARRY_BIT();
|
||||||
|
Loading…
Reference in New Issue
Block a user