Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View aarroyoc's full-sized avatar

Adrián Arroyo Calle aarroyoc

View GitHub Profile
#[deriving(FromPrimitive)]
enum Instruction {
INTEGER = 0x00,
STRING = 0x01,
ADD = 0x02,
SHOWINTEGER = 0x0A,
SHOWVERSION = 0x0E,
EXITVM = 0x0F
}
@aarroyoc
aarroyoc / execute.rs
Created August 27, 2014 10:01
Crea tu lenguaje de programación en Rust
fn execute(&mut self, execbyte: u8) -> () {
if self.push {
self.push(execbyte);
self.push=false;
}else{
let op: Option<Instruction> = FromPrimitive::from_u8(execbyte);
match op{
None => {
println!("Unknown instruction, skipping...");
},
@aarroyoc
aarroyoc / instruction.rs
Created August 27, 2014 10:43
instruction.rs
#[deriving(FromPrimitive)]
enum Instruction {
INTEGER = 0x00,
STRING = 0x01,
ADD = 0x02,
SHOWINTEGER = 0x0A,
SHOWVERSION = 0x0E,
EXITVM = 0x0F
}
@aarroyoc
aarroyoc / execute.rs
Created August 27, 2014 10:45
execute.rs
fn execute(&mut self, execbyte: u8) -> () {
if self.push {
self.push(execbyte);
self.push=false;
}else{
let op: Option<Instruction> = FromPrimitive::from_u8(execbyte);
match op{
None => {
println!("Unknown instruction, skipping...");
},
@aarroyoc
aarroyoc / pushAndPop.rs
Created August 27, 2014 10:46
pushAndPop.rs
fn push(&mut self, value: u8) -> (){
self.stack.push(value);
}
fn pop(&mut self) -> u8{
let a: Option<u8>=self.stack.pop();
match a{
None => {
println!("Failed to pop");
0
},
@aarroyoc
aarroyoc / main.rs
Created August 27, 2014 10:47
main.rs
mod vm;
fn main(){
let bytecode = "\x0E\x00\x02\x00\x03\x02\x0A";
let mut perin = vm::PerinVM::new();
perin.interpreter(bytecode);
}
@aarroyoc
aarroyoc / cpld.bash
Created August 30, 2014 14:29
Copy Shared Library dependencies UNIX
#!/bin/bash
# Author : Hemanth.HM
# Email : hemanth[dot]hm[at]gmail[dot]com
# License : GNU GPLv3
#
function useage()
{
cat << EOU
Useage: bash $0 <path to the binary> <path to copy the dependencies>
@aarroyoc
aarroyoc / ND_Keyboard_Handler.cpp
Created September 16, 2014 14:15
ND_Keyboard_Handler.cpp
extern "C"
void ND_Keyboard_Handler(struct regs* r)
{
unsigned char scancode = ND::Keyboard::GetChar();
if(scancode!=255)
@aarroyoc
aarroyoc / ND_Keyboard.cpp
Created September 16, 2014 14:19
ND_Keyboard - String manipulation
nsigned char ND::Keyboard::GetChar()
{
unsigned char scancode;
scancode=(unsigned char)ND::Ports::InputB(0x60);
@aarroyoc
aarroyoc / Keymap.hpp
Created September 16, 2014 14:25
Keymap
unsigned char en_US[128]=
{
0,27,'1','2','3','4','5','6','7','8','9','0','-','=', '\b',
'\t','q','w','e','r','t','y','u','i','o','p','[',']','\n',
0, /* Ctrl */
'a','s','d','f','g','h','j','k','l',';',
'\'','`',0, /* Left Shift */
'\\','z','x','c','v','b','n','m',',','.','/', 0,/* Right shift */
'*', 0, /* Alt */
' ',