Skip to content

Instantly share code, notes, and snippets.

@balazsgrill
balazsgrill / Add uint8
Created July 6, 2012 11:54
PIC16e uint8 arithmetics
add_u8(var uint8 d, uint8 v){
if (isliteral(v)){
MOVLW(v);
}else{
SELECTB(&v);
MOVF(&v,W);
}
SELECTB(&d);
ADDWF(&d,F);
}
@balazsgrill
balazsgrill / Branch on bool
Created July 6, 2012 12:12
PIC16e control operations
branch_bool(var bool condition, const codeaddr true, const codeaddr false){
SELECTB(&condition);
BTFSC(&condition, 0);
GOTO(true);
GOTO(false);
}
@balazsgrill
balazsgrill / (Not)Equals uint16
Created July 6, 2012 12:16
PIC16e uint16 arithmetics
checkEqual_u16(uint16 d1, uint16 d2, const bool not){
uint16 d;
d = d1-d2; //Simply subtract
//Put first byte into W
SELECTB(&d);
MOVF(&d,W);
//no need to select bank before using status
//we can select bank for result in advance
SELECTB(&result);
if (not){
@balazsgrill
balazsgrill / ObservablePatternMatchList.java
Created August 3, 2012 11:27
Observable list for EMF-IncQuery query matcher results
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.eclipse.core.databinding.observable.list.AbstractObservableList;
import org.eclipse.core.databinding.observable.list.ListDiff;
import org.eclipse.core.databinding.observable.list.ListDiffEntry;
import org.eclipse.viatra2.emf.incquery.runtime.api.IPatternMatch;
import org.eclipse.viatra2.emf.incquery.runtime.api.IncQueryMatcher;
import org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.misc.DeltaMonitor;
@balazsgrill
balazsgrill / MCP2200.lsusb
Created August 25, 2012 18:35
MCP2200 lsusb enumeration
Bus 002 Device 020: ID 04d8:00df Microchip Technology, Inc.
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2 ?
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 8
@balazsgrill
balazsgrill / mcp2200-tutorial.c
Created September 20, 2012 07:07
MCP2200 user-mode driver getting started
#include <stdio.h>
#include <sys/types.h>
#include <mcp2200.h>
int main(int argc, char** argv){
//Init MCP2200 library
int r = mcp2200_init();
if (r < 0)
return r;
@balazsgrill
balazsgrill / textualmodeler20131203.patch
Last active December 30, 2015 03:39
textualmodeler diff
diff --git a/hu.textualmodeler.editor/META-INF/MANIFEST.MF b/hu.textualmodeler.editor/META-INF/MANIFEST.MF
index ffbafd3..e1d1518 100644
--- a/hu.textualmodeler.editor/META-INF/MANIFEST.MF
+++ b/hu.textualmodeler.editor/META-INF/MANIFEST.MF
@@ -19,7 +19,9 @@
org.eclipse.emf.databinding;bundle-version="1.3.0",
org.eclipse.core.databinding.property;bundle-version="1.4.200",
org.eclipse.emf.transaction;bundle-version="1.4.0",
- org.eclipse.emf.databinding.edit;bundle-version="1.3.0"
+ org.eclipse.emf.databinding.edit;bundle-version="1.3.0",
@balazsgrill
balazsgrill / PeopleResource.java
Created December 9, 2013 14:01
Textualmodeler example
/**
*
*/
package hu.textualmodeler.parser.test;
import hu.textualmodeler.grammar.GrammarModel;
import hu.textualmodeler.grammar.Terminal;
import hu.textualmodeler.parser.AbstractTextualResource;
import hu.textualmodeler.parser.BasicFeatureResolver;
import hu.textualmodeler.parser.IFeatureResolver;
@balazsgrill
balazsgrill / infix.eiq
Created January 14, 2014 19:52
Parsing with IncQuery
package hu.textualmodeler.query.infix
import "http://textualmodeler.hu/grammar"
import "http://textualmodeler.hu/tokens"
pattern terminal(t : Token, s){
Token.terminal(t, terminal);
Terminal.name(terminal, s);
}
/*
* Optional rule
*/
pattern NonTerm(first: Token, next: Token){
first == next;
}or{
//Rule body
}