Skip to content
Permalink
Browse files

fixed stuff

  • Loading branch information...
felixangell committed May 20, 2015
1 parent 4251204 commit 01c06995f30ebeb3b9104d028346316f775dc577
Showing with 43 additions and 88 deletions.
  1. +2 −0 Makefile
  2. +0 −3 mac-improved/Makefile
  3. +2 −2 mac-improved/README.md
  4. +0 −52 mac-improved/assembler.c
  5. +0 −29 mac-improved/instructionset.h
  6. +19 −2 mac-improved/mac.c
  7. +20 −0 mac.dSYM/Contents/Info.plist
@@ -1,4 +1,6 @@
CFLAGS = -Wall -Wextra -g -std=c11

all: mac

test: mac
./mac
@@ -2,6 +2,3 @@ CFLAGS = -Wall -Wextra -g -std=c11

all:
${CC} ${CFLAGS} mac.c -o mac

assembler:
${CC} assembler.c -o masm
@@ -2,8 +2,8 @@
MAC is a really simple virtual machine. It's written in C and is [as of writing this]
only one small C file.

This is the more advanced version, you can pass it files, for instance
this file is `test.mac`:
This is the more advanced version, it has more instructions and
you can pass it files, for instance this file is `test.mac`:

1 5 2 1
5 2 1 5

This file was deleted.

This file was deleted.

@@ -6,11 +6,28 @@
#include <stdbool.h>
#include <stdlib.h>

#include "instructionset.h"

#define STACK_SIZE 256
static int stack[STACK_SIZE];

/** Instructions */
typedef enum {
HLT, // 0 -- hlt :: halts program
PSH, // 1 -- psh val :: pushes <val> to stack
POP, // 2 -- pop :: pops value from stack
ADD, // 3 -- add :: adds top two vals on stack
MUL, // 4 -- mul :: multiplies top two vals on stack
DIV, // 5 -- div :: divides top two vals on stack
SUB, // 6 -- sub :: subtracts top two vals on stack
SLT, // 7 -- slt reg_a, reg_b :: pushes (reg_a < reg_b) to stack
MOV, // 8 -- mov reg_a, reg_b :: movs the value in reg_a to reg_b
SET, // 9 -- set reg, val :: sets the reg to value
LOG, // 10 -- log a :: prints out a
IF, // 11 -- if reg val ip :: if the register == val branch to the ip
IFN, // 12 -- ifn reg val ip :: if the register != val branch to the ip
GLD, // 13 -- gld reg :: loads a register to the stack
GPT, // 14 -- gpt reg :: pushes top of stack to the given register
NOP // 15 -- nop :: nothing
} Instructions;

/** Registers */
typedef enum {
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIdentifier</key>
<string>com.apple.xcode.dsym.mac</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>dSYM</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

0 comments on commit 01c0699

Please sign in to comment.
You can’t perform that action at this time.