mirror of
https://github.com/pnx/m16vm
synced 2026-06-17 03:50:03 +02:00
Compare commits
No commits in common. "main" and "v0.1" have entirely different histories.
36 changed files with 44 additions and 105 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,5 +1,4 @@
|
||||||
*.o
|
*.o
|
||||||
*.a
|
*.a
|
||||||
*.bin
|
|
||||||
m16vm
|
m16vm
|
||||||
m16as
|
m16as
|
||||||
|
|
|
||||||
44
README.md
44
README.md
|
|
@ -7,50 +7,6 @@ The design is taken from the real world and tries to mimic existing RISC-archite
|
||||||
|
|
||||||
The instruction set is by no means designed to be "fast" or "optimal" but focus more on being easy to understand and modify/play with.
|
The instruction set is by no means designed to be "fast" or "optimal" but focus more on being easy to understand and modify/play with.
|
||||||
|
|
||||||
Compile
|
|
||||||
-------
|
|
||||||
|
|
||||||
The code is compiled via Makefile.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
$ make
|
|
||||||
```
|
|
||||||
|
|
||||||
The code is compiled into 2 programs:
|
|
||||||
|
|
||||||
* `m16as` - Assembler - Compiles assembler code into binary form.
|
|
||||||
* `m16vm` - Virtual Machine, will run binary code from a file.
|
|
||||||
|
|
||||||
|
|
||||||
Example for first compile assembly code and then run it:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
$ ./m16as examples/asm/hello_world.as > prog.bin
|
|
||||||
$ ./m16vm ./prog.bin
|
|
||||||
HELLO WORLD
|
|
||||||
```
|
|
||||||
|
|
||||||
Usage
|
|
||||||
-----
|
|
||||||
|
|
||||||
#### m16as
|
|
||||||
|
|
||||||
```
|
|
||||||
Usage: ./m16as <inputfile> [ <outputfile> ]
|
|
||||||
```
|
|
||||||
|
|
||||||
`m16as` is pretty streigth forward. if no `outputfile` is given, the output is written to `stdout`
|
|
||||||
|
|
||||||
#### m16vm
|
|
||||||
|
|
||||||
```
|
|
||||||
usage: ./m16vm [ --dmem | --dreg ] <file>
|
|
||||||
```
|
|
||||||
|
|
||||||
* `--dmem` - debug memory, after the program has executed the last instruction, the contents of the memory is printed to `stdout`. NOTE: only the first 32 bytes are printed to
|
|
||||||
|
|
||||||
* `--dreg` - debug registers, after the program has executed the last instruction, the contents of the registers is printed to `stdout`.
|
|
||||||
|
|
||||||
Specification
|
Specification
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
|
|
||||||
5
as/as.c
5
as/as.c
|
|
@ -1,6 +1,6 @@
|
||||||
/* as.c
|
/* as.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2018-2019 Henrik Hautakoski <henrik@fiktivkod.org>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
int usage(char *program) {
|
int usage(char *program) {
|
||||||
|
|
||||||
fprintf(stderr, "Usage: %s <inputfile> [ <outputfile> ]\n", program);
|
fprintf(stderr, "Usage: %s <inputfile> [ <outputfile ]\n", program);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,7 +55,6 @@ int main(int argc, char **argv) {
|
||||||
parse(fd_in, fd_out);
|
parse(fd_in, fd_out);
|
||||||
|
|
||||||
fclose(fd_in);
|
fclose(fd_in);
|
||||||
if (fd_out != stdout)
|
|
||||||
fclose(fd_out);
|
fclose(fd_out);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* asm_error.h
|
/* asm_error.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2018-2019 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
||||||
2
as/ast.c
2
as/ast.c
|
|
@ -1,6 +1,6 @@
|
||||||
/* ast.c
|
/* ast.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2018-2019 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
||||||
2
as/ast.h
2
as/ast.h
|
|
@ -1,6 +1,6 @@
|
||||||
/* ast.h
|
/* ast.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2018-2019 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* codegen.c
|
/* codegen.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2018-2019 Henrik Hautakoski <henrik@fiktivkod.org>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* codegen.h
|
/* codegen.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2018-2019 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* lexer.c
|
/* lexer.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2018-2019 Henrik Hautakoski <henrik@fiktivkod.org>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* lexer.h
|
/* lexer.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2018-2019 Henrik Hautakoski <henrik@fiktivkod.org>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* Macros for the grammar.
|
* Macros for the grammar.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2018-2019 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* lexer/number.c
|
/* lexer/number.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2018-2019 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* lexer/number.h
|
/* lexer/number.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2018-2019 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* parser.c
|
/* parser.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2018-2019 Henrik Hautakoski <henrik@fiktivkod.org>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* parser.h
|
/* parser.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2018-2019 Henrik Hautakoski <henrik@fiktivkod.org>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* symtab.c
|
/* symtab.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2018-2019 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* symtab.h
|
/* symtab.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2018-2019 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
/Hϊ/Eϊ/Lϊϊ/Oϊο ϊ/Wϊ/Oϊ/Rϊ/Lϊ/Dϊ
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* error.c
|
/* error.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2018 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* error.h
|
/* error.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2018 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* instr.h
|
/* instr.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2012,2014 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* vector.h
|
/* vector.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2018 Henrik Hautakoski <henrik@fiktivkod.org>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* vector.c
|
/* vector.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2018 Henrik Hautakoski <henrik@fiktivkod.org>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
||||||
2
vm/cpu.c
2
vm/cpu.c
|
|
@ -1,6 +1,6 @@
|
||||||
/* cpu.c
|
/* cpu.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2012,2014-2015,2018-2019 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
||||||
2
vm/cpu.h
2
vm/cpu.h
|
|
@ -1,6 +1,6 @@
|
||||||
/* cpu.h
|
/* cpu.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2012,2014-2015,2018-2019 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
||||||
12
vm/debug.c
12
vm/debug.c
|
|
@ -1,6 +1,6 @@
|
||||||
/* debug.c
|
/* debug.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2019 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
@ -20,20 +20,14 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "mm.h"
|
|
||||||
|
|
||||||
void debug_print_memory(uint8_t *mm) {
|
void debug_print_memory(uint8_t *mm) {
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
printf("\n"
|
printf("\n");
|
||||||
" 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F\n"
|
|
||||||
" ------------------------------------------------");
|
|
||||||
|
|
||||||
for(i = 0; i < MEM_SIZE; i++) {
|
|
||||||
if ((i % 16) == 0)
|
|
||||||
printf("\n%.2X| ", i);
|
|
||||||
|
|
||||||
|
for(i = 0; i < 32; i++) {
|
||||||
printf("%.2X ", mm[i]);
|
printf("%.2X ", mm[i]);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* debug.h
|
/* debug.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2019 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* instr_decode.c
|
/* instr_decode.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2012,2014,2018-2019 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* instr_decode.h
|
/* instr_decode.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2012,2014,2018-2019 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
||||||
7
vm/mm.c
7
vm/mm.c
|
|
@ -1,6 +1,6 @@
|
||||||
/* mm.c
|
/* mm.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2012,2014,2018-2019 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
@ -21,6 +21,11 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "mm.h"
|
#include "mm.h"
|
||||||
|
|
||||||
|
#ifndef MEM_SIZE
|
||||||
|
/* Set a default memory size. (2^16) */
|
||||||
|
#define MEM_SIZE 65536
|
||||||
|
#endif
|
||||||
|
|
||||||
// Get a WORD aligned (16-bit) address.
|
// Get a WORD aligned (16-bit) address.
|
||||||
// Casts the 8-bit pointer (mm_base_addr) to 16-bit (WORD) and add offset.
|
// Casts the 8-bit pointer (mm_base_addr) to 16-bit (WORD) and add offset.
|
||||||
#define addr_align_word(offset) \
|
#define addr_align_word(offset) \
|
||||||
|
|
|
||||||
7
vm/mm.h
7
vm/mm.h
|
|
@ -1,6 +1,6 @@
|
||||||
/* mm.h
|
/* mm.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2012,2014,2018-2019 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
@ -22,11 +22,6 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifndef MEM_SIZE
|
|
||||||
/* Set a default memory size. (2^8) */
|
|
||||||
#define MEM_SIZE 256
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern uint8_t *mm_base_addr;
|
extern uint8_t *mm_base_addr;
|
||||||
|
|
||||||
void mm_init();
|
void mm_init();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* program.c
|
/* program.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2012,2014,2018-2019 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* program.h
|
/* program.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2012,2014,2018-2019 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* syscall.c
|
/* syscall.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2012,2014-2015,2018-2019 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* syscall.h
|
/* syscall.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012,2014-2015,2018-2019,2023 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2012,2014-2015,2018-2019 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
||||||
14
vm/vm.c
14
vm/vm.c
|
|
@ -50,19 +50,15 @@ void run(struct program *prog) {
|
||||||
mm_exit();
|
mm_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
int usage(const char* name) {
|
|
||||||
fprintf(stderr, "usage: %s [ --dmem | --dreg ] <file>\n", name);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
struct program prog = { 0 };
|
struct program prog = { 0 };
|
||||||
const char *filename = NULL;
|
const char *filename;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
return usage(argv[0]);
|
fprintf(stderr, "usage: %s [ --dmem | --dreg ] <file>\n", argv[0]);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse options.
|
// Parse options.
|
||||||
|
|
@ -82,10 +78,6 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filename == NULL) {
|
|
||||||
return usage(argv[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (program_loadfromfile(&prog, filename) < 0)
|
if (program_loadfromfile(&prog, filename) < 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue