Mercurial > repo
diff interps/egobf/src/c2m/i386/i386-1.h @ 996:859f9b4339e6
<Gregor> tar xf egobot.tar.xz
author | HackBot |
---|---|
date | Sun, 09 Dec 2012 19:30:08 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/interps/egobf/src/c2m/i386/i386-1.h Sun Dec 09 19:30:08 2012 +0000 @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2005 Gregor Richards + * + * This file is part of egobfi. + * + * egobfi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * egobfi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with egobfi; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#define C2MHEAD() { \ +memcpy((char *) (prog + pptr), \ + "\x55" \ + "\x89\xe5" \ + "\xa1____", 8); \ +memcpy((char *) (prog + pptr + 4), \ + &mptri, 4); \ +pptr += 8; \ +} + +#define C2MTAIL() { \ +memcpy((char *) (prog + pptr), \ + "\x5d\xc3", 2); \ +pptr += 2; \ +} + +#define C2MADD(a) { \ +*((char *) (prog + pptr)) = '\x80'; \ +if ((a) >= 0) { \ + *((char *) (prog + pptr + 1)) = '\x00'; \ + *((char *) (prog + pptr + 2)) = (char) (a); \ +} else { \ + *((char *) (prog + pptr + 1)) = '\x28'; \ + *((char *) (prog + pptr + 2)) = (char) ((a) * -1); \ +} \ +pptr += 3; \ +} + +#define C2MRHT(a) { \ +if ((a) >= 0) { \ + memcpy((char *) (prog + pptr), \ + "\x83\xc0_" \ + "\xa3____", 8); \ + *((char *) (prog + pptr + 2)) = (char) (a); \ + memcpy((char *) (prog + pptr + 4), &mptri, 4); \ +} else { \ + memcpy((char *) (prog + pptr), \ + "\x83\xe8_" \ + "\xa3____", 8); \ + *((char *) (prog + pptr + 2)) = (char) ((a) * -1); \ + memcpy((char *) (prog + pptr + 4), &mptri, 4); \ +} \ +pptr += 8; \ +} + +#define C2MLOS 9 + +#define C2MLO(rpptr) { \ +int jlen; \ +jlen = (int) (prog + pptr) - (int) (prog + rpptr) - 4; \ +memcpy((char *) (prog + (rpptr)), \ + "\x80\x38\x00" \ + "\x0f\x84____", 9); \ +memcpy((char *) (prog + (rpptr) + 5), &jlen, 4); \ +} + +#define C2MLC(sp) { \ +int jlen; \ +jlen = (int) (prog + sp) - (int) (prog + pptr) - 5; \ +memcpy((char *) (prog + pptr), \ + "\xe9____", 5); \ +memcpy((char *) (prog + pptr + 1), &jlen, 4); \ +pptr += 5; \ +} + +#define C2MCALL(a) { \ +int cptr; \ +cptr = (int) (a) - (int) (prog + pptr) - 5; \ +memcpy((char *) (prog + pptr), \ + "\xe8____" \ + "\xa1____", 10); \ +memcpy((char *) (prog + pptr + 1), &cptr, 4); \ +memcpy((char *) (prog + pptr + 6), &mptri, 4); \ +pptr += 10; \ +}