Skip to content

Commit

Permalink
Add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
agkaminski committed Sep 9, 2023
1 parent 832ec22 commit 5d9ffc0
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 12 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CFLAGS := -Wall -Wextra -Werror -O2 -ansi -std=gnu99
DEBUG := -DNDEBUG
INSTALL_PATH := /usr/local

LIB = simak65.a
LIB = libsimak65.a
HEADER = simak65.h
OBJ = addrmode.o alu.o bus.o decoder.o exec.o simak65.o

Expand Down
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# simak65 - 6502 CPU simulator library

This simulator is based on the simualator of [AK6502 CPU](https://github.com/agkaminski/AK6502).
NMOS version of the CPU is simulated, cycle accurate. There's no undocumented intructions support,
invalid opcodes are decoded as `nop`.

## Build

There're no dependencies, only `make` and `gcc` are needed. Simply type `make` to build the library.
It can be installed to `/usr/local/lib` via `sudo make install`, along with the api header (to `/usr/local/include`).

## API

Library interface is available in `simak65.h` header.

### struct simak65_bus

This structure holds CPU bus read/write callback, that are need to provided by the library user.

### struct simak65_cpustate

This structure holds internal CPU state. It is stored by the library user and needs to be passed
to the library functions.

### void simak65_step(struct simak65_cpustate *cpu, unsigned int *cycles)

Execute the next instruction.
- cpu - cpu state,
- cycles - optional (can be NULL), number of cycles passed for the execution of the instruction
is added to this variable.

### void simak65_rst(struct simak65_cpustate *cpu, unsigned int *cycles)

Perform the CPU reset. This operation must be performed pefored before executing first instruction.
- cpu - cpu state,
- cycles - optional (can be NULL), number of cycles passed for the execution of the instruction
is added to this variable.

### void simak65_nmi(struct simak65_cpustate *cpu, unsigned int *cycles)

Execute the non-maskable interrupt.
- cpu - cpu state,
- cycles - optional (can be NULL), number of cycles passed for the execution of the instruction
is added to this variable.

### void simak65_irq(struct simak65_cpustate *cpu, unsigned int *cycles)

Execute the interrupt.
- cpu - cpu state,
- cycles - optional (can be NULL), number of cycles passed for the execution of the instruction
is added to this variable.

### void simak65_init(struct simak65_cpustate *cpu, const struct simak65_bus *ops)

Initialize the library and the cpu state.
- cpu - cpu state,
- ops - CPU memory bus callbacks.

## License

See LICENSE for details.
10 changes: 0 additions & 10 deletions addrmode.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,3 @@ enum argtype addrmode_getArgs(struct simak65_cpustate *cpu, u8 *args, enum addrm
return arg_type;
}











1 change: 1 addition & 0 deletions addrmode.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ u8 addrmode_nextpc(struct simak65_cpustate *cpu);
enum argtype addrmode_getArgs(struct simak65_cpustate *cpu, u8 *args, enum addrmode mode, unsigned int *cycles);

#endif /* SIMAK65_ADDRMODE_H_ */

0 comments on commit 5d9ffc0

Please sign in to comment.