A lightweight VM which allows for easy custom programs to be made on the device without having to worry about linking and PIC code and all of that. BSD licensed. See https://bitbucket.org/earlz/lightvm/ for the upstream general purpose repository
16bitops.c
00001 /** 00002 <Copyright Header> 00003 Copyright (c) 2013 Jordan "Earlz" Earls <http://Earlz.net> 00004 All rights reserved. 00005 00006 Redistribution and use in source and binary forms, with or without 00007 modification, are permitted provided that the following conditions 00008 are met: 00009 00010 1. Redistributions of source code must retain the above copyright 00011 notice, this list of conditions and the following disclaimer. 00012 2. Redistributions in binary form must reproduce the above copyright 00013 notice, this list of conditions and the following disclaimer in the 00014 documentation and/or other materials provided with the distribution. 00015 3. The name of the author may not be used to endorse or promote products 00016 derived from this software without specific prior written permission. 00017 00018 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 00019 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 00020 AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 00021 THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00022 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00023 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 00024 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00025 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 00026 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 00027 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00028 </Copyright Header> 00029 **/ 00030 00031 #include "lightvm.h" 00032 00033 void op16_single_arg(lightvm_state* s, uint16_t op, uint16_t* arg2) 00034 { 00035 unsigned int secondary=op & 0xF000 >> 12; 00036 switch(secondary) 00037 { 00038 case 0: 00039 //push 00040 lightvm_push(s, *arg2); 00041 break; 00042 case 1: 00043 //pop 00044 *arg2 = lightvm_pop(s); 00045 break; 00046 case 2: 00047 //not 00048 *arg2 = ~(*arg2); 00049 break; 00050 case 3: 00051 //unused 00052 case 4: 00053 //unused 00054 case 5: 00055 //unused 00056 case 6: 00057 //xcall? 00058 case 7: 00059 //and.eq 00060 *s->tr &= *s->cr == *arg2; 00061 break; 00062 case 8: 00063 //or.eq 00064 *s->tr |= *s->cr == *arg2; 00065 break; 00066 case 9: 00067 //and.neq 00068 *s->tr &= *s->cr != *arg2; 00069 break; 00070 case 10: 00071 //or.neq 00072 *s->tr |= *s->cr != *arg2; 00073 break; 00074 case 11: 00075 //set TR 00076 *s->tr = 1; 00077 break; 00078 case 12: 00079 //reset TR 00080 *s->tr = 0; 00081 break; 00082 case 13: 00083 //load CR 00084 *s->cr = *arg2; 00085 break; 00086 case 14: 00087 //8.bank PROBABLY NOT 00088 case 15: 00089 //unused 00090 default: 00091 return; 00092 } 00093 return; 00094 } 00095
Generated on Mon Jul 18 2022 19:33:40 by 1.7.2