summaryrefslogtreecommitdiff
path: root/asmmon.c
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2020-04-19 13:31:49 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2020-04-19 13:31:49 -0400
commite093aba79dd1ed88cb490b7cd69c81f0b14bea11 (patch)
tree7c37fe806b5e6fa7f82edcf2379cf4a424fa0c19 /asmmon.c
parent0a7a2a7a8f95730811117bd2aa904f1843f65071 (diff)
Removed most of the commented code, and optimized the
emulator some more. I optimized the emulator by replacing the main loop from a conditional while loop, to an unconditional for loop.
Diffstat (limited to 'asmmon.c')
-rw-r--r--asmmon.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/asmmon.c b/asmmon.c
index b1aead9..16865eb 100644
--- a/asmmon.c
+++ b/asmmon.c
@@ -181,7 +181,6 @@ void list(uint16_t start, uint16_t end, uint8_t all, uint8_t ln, uint8_t addr, u
}
if (flags & 0x20) {
printf("%s", symbols[tokline[i].sym]->name);
- /*get_symname(tokline[i].sym, 0));*/
if (tokline[i].islabel) {
printf(": ");
} else if (tokline[i].issym) {
@@ -363,13 +362,11 @@ uint64_t assemble(uint8_t dbg) {
opsize = 0;
skip = 0;
if ((flags & 0x53) == 0x42) {
- /*value = use_symbol("", symid, tmpaddr, 1, 0);*/
value = symbols[symid]->val;
} else {
value = tokline[i].op;
}
if ((flags & 0x51) == 0x41) {
- /*value = use_symbol("", symid, tmpaddr, 1, 0);*/
value = symbols[symid]->val;
}
if (flags & 0x220) {
@@ -583,23 +580,19 @@ int asmmon(const char *fn) {
uint8_t dbg = 0;
init_symbol();
while (!done) {
- /*char *buf = NULL;*/
char *cmd;
char *arg = malloc(sizeof(char *)*128);
char *tmp = malloc(sizeof(char *)*128);
- char *lex_line = NULL;
- size_t size;
- ssize_t line_len;
+ char lex_line[0x1000];
+ uint16_t size = 0;
uint8_t cmds = 0;
- /* Is shortend command. */
+ uint8_t dummy = 0;
+ /* Is single character command. */
uint8_t isshcmd = 0;
- if (!strcasecmp(fn, "stdin")) {
- line_len = getline(&lex_line, &size, stdin);
- } else {
- line_len = getline(&lex_line, &size, fp);
- }
- cmd = malloc(sizeof(char *)*(line_len+1));
- memcpy(cmd, lex_line, line_len+1);
+ fgets(lex_line, sizeof(lex_line), (!strcasecmp(fn, "stdin")) ? stdin : fp);
+ size = strlen(lex_line)+1;
+ cmd = malloc(size);
+ memcpy(cmd, lex_line, size);
cmd = strtok_r(cmd, " \t\n", &tmp);
if (cmd != NULL) {
isshcmd = (cmd[1] == '\0' || cmd[1] == ' ');