Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* 1 */ Instruction("sys" , 0x0000); // @deprecated Jump to machine code at nnn | 0x0nnn
- /* 2 */ Instruction("cls" , 0x00E0); // Clear the display
- /* 3 */ Instruction("ret" , 0x00EE); // Return from subroutine, Set program counter(PC) to top of stack and subtract 1 from stackpointer
- /* 4 */ Instruction("jp" , 0x1000); // Jump to location at nnn | 0x 1nnn
- /* 5 */ Instruction("call" , 0x2000); // Call subroutine at nnn, Increment stackpointer, put PC on top of the stack, Set PC to nnn | 0x 2nnn
- /* 6 */ Instruction("se" , 0x3000); // Skip instruction, if Vx = kk then increment program counter by 2 | 0x 3xkk
- /* 7 */ Instruction("sne" , 0x4000); // Skip instruction, if Vx != kk then increment program counter by 2 | 0x 4xkk
- /* 8 */ Instruction("se" , 0x5000); // Skip instruction, if Vx = Vy then increment program counter by 2 | 0x 5xy0
- /* 9 */ Instruction("ld" , 0x6000); // Put value kk into register Vx | 0x 6xkk
- /* 10 */ Instruction("add" , 0x7000); // Set Vx = Vx + kk | 0x 7xkk
- /* 11 */ Instruction("ld" , 0x8000); // Put the value of register Vy in Vx | 0x 8xy0
- /* 12 */ Instruction("or" , 0x8001); // Performs a bitwise Or on the values of Vx and Vy, Result in Vx | 0x 8xy1
- /* 13 */ Instruction("and" , 0x8002); // Performs a bitwise And on the vlaues of Vx and Vy, Result in Vx | 0x 8xy2
- /* 14 */ Instruction("xor" , 0x8003); // Performs a bitwise Xor on the values of Vx and Vy, Result in Vx | 0x 8xy3
- /* 15 */ Instruction("add" , 0x8004); // Set Vx = Vx + Vy,Set VF = carry | 0x 8xy4
- /* 16 */ Instruction("sub" , 0x8005); // If Vx > Vy then VF set to 1 else 0, Vx = Vy - Vx | 0x 8xy5
- /* 17 */ Instruction("shr" , 0x8006); // if least-significant bit (lsb) of Vx is 1 then vf = 1 else vf = 0. Vx = Vx / 2 | 0x 8xy6
- /* 18 */ Instruction("subn" , 0x8007); // if Vy > Vx then VF set to 1 else 0, Vx = Vy - Vx | 0x 8xy7
- /* 19 */ Instruction("shl" , 0x800e); // If most-significant bit (msb) of Vx is 1 then vf = 1 else vf = 0, Vx = Vx * 2 | 0x 8xyE
- /* 20 */ Instruction("sne" , 0x9000); // The values of Vx and Vy are compared, if they are not increment program counter by 2 | 0x 9xy0
- /* 21 */ Instruction("ld" , 0xa000); // Register I is set to nnn | 0x Annn
- /* 22 */ Instruction("jp" , 0xb000); // Jump to location nnn + V0 | 0x Bnnn
- /* 23 */ Instruction("rnd" , 0xc000); // Vx = random byte (0 - ff) AND kk | 0x Cxkk
- /* 24 */ Instruction("drw" , 0xd000); // Display n-byte sprite starting at memory location I at (Vx, Vy), set VF = collision | 0x Dxyn
- /* @Implementation-notes drw draws using Vx Vy as coordinates. Sprites are XORED onto the existing screen. If anything is erased vf set to 1
- If the sprite would draw outside the display then it wraps around to the opposite side of the screen.
- */
- /* 25 */ Instruction("skp" , 0xe09e); // Skip next instruction if key with value Vx is pressed | 0x Ex9E
- /* 26 */ Instruction("skpnp" , 0xe0a1); // Skip next instruction if key with value Vx is not pressed | 0x Exa1
- /* 27 */ Instruction("ld" , 0xF007); // Set Vx = delay timer value | 0x Fx07
- /* 28 */ Instruction("ld" , 0xF015); // Set Dt = value of Vx | 0x Fx15
- /* 29 */ Instruction("ld" , 0xF018); // Set St = value of Vx | 0x Fx18
- /* 30 */ Instruction("add" , 0xF01e); // Set I = I + Vx | 0x Fx1E
- /* 31 */ Instruction("ld" , 0xF029); // Set I = location of sprite for digit Vx | 0x Fx29
- /* 32 */ Instruction("ld" , 0xF033); // Store binary coded decimal(bcd) representation of Vx in mem loc I, I+1, and I+2 | 0x Fx33
- /* @Implementation-notes I stores the hundreds digit, I + 1 stores the tens digit, I+2 stores the ones digit
- */
- /* 33 */ Instruction("ld" , 0xF055); // Store registers V0 through Vx in memory starting at location I | 0x Fx55
- /* 34 */ Instruction("ld" , 0xF065); // Read into Registers V0 through Vx from memory starting at location I | 0x Fx65
- // @Optional Super Chip-48 Instructions (May not support all of these)
- /* 35 */ Instruction("scd" , 0x00C0); // Scroll display N lines down | 0x 00Cn
- /* 36 */ Instruction("scr" , 0x00FB); // Scroll display 4 pixels right
- /* 37 */ Instruction("scl" , 0x00FC); // Scroll display 4 pixels left
- /* 38 */ Instruction("exit" , 0x00FD); // Leave the chip8 interpreter / Stop running
- /* 39 */ Instruction("low" , 0x00FE); // Disable Extended Screen Mode
- /* 40 */ Instruction("high" , 0x00FF); // Enable Extended Screen Mode
- /* 41 */ Instruction("ld" , 0xF030); // Set I = Location of 10 byte sprite for digit VX (0..9) | 0x Fx30
- static uint8_t Memory[0xFFF];
- // 16 16-bit values used to store the address that the interpreter should return to when finished with a subroutine
- // There is a hard limit of 16 levels of nesting on subroutines.
- static uint16_t Stack[16];
- struct Registers
- {
- // 16 general purpose 8 bit Registers, VF should not be used by any program (Used as a flag)
- uint8_t v[16];
- // Used to store memory addresses, generally only the lowest 12 bits are used
- uint16_t I = 0;
- // Delay Timer is actve when non-zero. Subtracts 1 at the rate of 60Hz
- // Sound Timer is the same as DT. However, it activates the buzzer while it is greater than 0.
- // Output from Sound timer should be a constant single tone.
- uint8_t DT = 0, ST = 0;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement