mirror of
https://github.com/rkujawa/rk65c02.git
synced 2025-03-03 14:29:23 +00:00
Add CLI skeleton.
This commit is contained in:
parent
f42f88c148
commit
b498da3ac8
26
src/Makefile
26
src/Makefile
@ -1,28 +1,36 @@
|
|||||||
OBJS=rk65c02.o bus.o instruction.o emulation.o
|
CLI=rk65c02cli
|
||||||
|
CLI_OBJS=rk65c02cli.o
|
||||||
|
|
||||||
|
LIB_OBJS=rk65c02.o bus.o instruction.o emulation.o
|
||||||
LIB_SO=librk65c02.so
|
LIB_SO=librk65c02.so
|
||||||
LIB_STATIC=librk65c02.a
|
LIB_STATIC=librk65c02.a
|
||||||
LDFLAGS=-shared
|
|
||||||
|
LDFLAGS_SO=-shared
|
||||||
|
LDFLAGS_CLI=-lreadline
|
||||||
CFLAGS=-Wall -fpic
|
CFLAGS=-Wall -fpic
|
||||||
|
|
||||||
65C02ISA=65c02isa
|
65C02ISA=65c02isa
|
||||||
|
|
||||||
all : $(LIB_SO) $(LIB_STATIC)
|
all : $(LIB_SO) $(LIB_STATIC) $(CLI)
|
||||||
|
|
||||||
$(LIB_SO) : $(OBJS)
|
$(CLI) : $(CLI_OBJS)
|
||||||
$(CC) -o $(LIB_SO) $(LDFLAGS) $(OBJS)
|
$(CC) -o $(CLI) $(LDFLAGS_CLI) $(CLI_OBJS) $(LIB_STATIC)
|
||||||
|
|
||||||
|
$(LIB_SO) : $(LIB_OBJS)
|
||||||
|
$(CC) -o $(LIB_SO) $(LDFLAGS_SO) $(LIB_OBJS)
|
||||||
|
|
||||||
$(LIB_STATIC) : $(OBJS)
|
$(LIB_STATIC) : $(OBJS)
|
||||||
$(AR) rcs $(LIB_STATIC) $(OBJS)
|
$(AR) rcs $(LIB_STATIC) $(LIB_OBJS)
|
||||||
|
|
||||||
$(65C02ISA).h : $(65C02ISA).csv $(65C02ISA).awk
|
$(65C02ISA).h : $(65C02ISA).csv $(65C02ISA).awk
|
||||||
awk -f $(65C02ISA).awk $(65C02ISA).csv > $(65C02ISA).h
|
awk -f $(65C02ISA).awk $(65C02ISA).csv > $(65C02ISA).h
|
||||||
|
|
||||||
# XXX: dependency on 65c02isa.h is only for instruction.c
|
# XXX: dependency on 65c02isa.h is only for instruction.c ?
|
||||||
%.o : %.c %.h $(65C02ISA).h
|
%.o : %.c %.h $(65C02ISA).h
|
||||||
$(CC) $(CFLAGS) -c $<
|
$(CC) $(CFLAGS) -c $<
|
||||||
|
|
||||||
clean :
|
clean :
|
||||||
rm -f $(65C02ISA).h
|
rm -f $(65C02ISA).h
|
||||||
rm -f $(OBJS)
|
rm -f $(LIB_OBJS) $(CLI_OBJS)
|
||||||
rm -f $(LIB_SO) $(LIB_STATIC)
|
rm -f $(LIB_SO) $(LIB_STATIC) $(CLI)
|
||||||
|
|
||||||
|
63
src/rk65c02cli.c
Normal file
63
src/rk65c02cli.c
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include <readline/readline.h>
|
||||||
|
#include <readline/history.h>
|
||||||
|
|
||||||
|
#include "bus.h"
|
||||||
|
#include "instruction.h"
|
||||||
|
#include "rk65c02.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
bus_t b;
|
||||||
|
|
||||||
|
b = bus_init();
|
||||||
|
|
||||||
|
bus_write_1(&b, 0, OP_INX);
|
||||||
|
bus_write_1(&b, 1, OP_NOP);
|
||||||
|
bus_write_1(&b, 2, OP_LDY_IMM);
|
||||||
|
bus_write_1(&b, 3, 0x1);
|
||||||
|
bus_write_1(&b, 4, OP_TSB_ZP);
|
||||||
|
bus_write_1(&b, 5, 0x3);
|
||||||
|
bus_write_1(&b, 6, OP_JSR);
|
||||||
|
bus_write_1(&b, 7, 0x09);
|
||||||
|
bus_write_1(&b, 8, 0x0);
|
||||||
|
bus_write_1(&b, 9, OP_STP);
|
||||||
|
|
||||||
|
rk6502_start(&b, 0);
|
||||||
|
|
||||||
|
bus_finish(&b);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
char* input, shell_prompt[100];
|
||||||
|
|
||||||
|
rl_bind_key('\t', rl_complete);
|
||||||
|
|
||||||
|
while(true) {
|
||||||
|
snprintf(shell_prompt, sizeof(shell_prompt), "> ");
|
||||||
|
|
||||||
|
input = readline(shell_prompt);
|
||||||
|
|
||||||
|
if (!input)
|
||||||
|
break;
|
||||||
|
|
||||||
|
add_history(input);
|
||||||
|
|
||||||
|
free(input);
|
||||||
|
}
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user