objvm - code - asm1.h

#ifndef ASM1_H
#define ASM1_h

#define VM_FILE_HEADER 0xAC 0xCA

#define VM_FILE_TYPE_RAW 0x00 0x00
#define VM_FILE_TYPE_SEG 0x00 0x01
#define VM_FILE_HEADER_UNUSED_PADDING                                          \
  0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00

// ops
#define HLT 0x00
#define ADD 0x12
#define INC 0x13
#define DEC 0x14
#define DEBUGOP 0xFD

#define JMP 0x20
#define CMP 0x22
#define JZE 0x23
#define JNZ 0x24

#define PUSH 0x40
#define POP 0x50

// data type flags
#define CONSTANT 0x00
#define REGISTER 0x01
#define SPECIAL 0x02

// special fields
#define IP 0x00
#define Z 0x01
#define SP 0x02

// higher-level macros
#define STOREIP8 PUSH SPECIAL IP PUSH CONSTANT 0x0a ADD POP

#endif