* Add make chlog target to genereate shlogs

* Fully implement the asm.bf assembler and disassembler
  - Syntax fixed. disassembled code can be reassembled
  - Added support for misd instructions (multiple instruction single data)
    rasm2 -a bf 'add [ptr], 8;trap,64;nop;poke;'
This commit is contained in:
pancake 2011-10-09 05:24:15 +02:00
parent 13d24051b7
commit 8de9123520
3 changed files with 59 additions and 6 deletions

View file

@ -27,6 +27,21 @@ libr:
binr:
cd binr && ${MAKE} all
R=$(shell hg tags|head -n2 | tail -n1|awk '{print $$2}' |cut -d : -f 1)
T=$(shell hg tip|grep changeset:|cut -d : -f 2)
.PHONY: chlog
chlog:
@hg log -v -r tip:$R > chlog
@echo "-=== release ${VERSION} ===-"
@echo "hg tag -r $T ${VERSION}"
@printf "last commit: "
@hg log -r tip | grep date: |cut -d : -f 2- |sed -e 's,^\ *,,g'
@printf "oldest commit: "
@hg log -r $R | grep date: |cut -d : -f 2- |sed -e 's,^\ *,,g'
@printf "Commits: "
@grep changeset: chlog |wc -l
@grep -v : chlog | grep -v '^$$'
w32:
make clean
# TODO: add support for debian

View file

@ -11,6 +11,9 @@ To debug a brainfuck program:
$ r2 -D bf bfdbg:///tmp/bf
> dc # continue
> x@scr # show screen buffer contents
The debugger creates virtual sections for code, data, screen and input.
TODO

View file

@ -44,10 +44,10 @@ static int disassemble(struct r_asm_t *a, struct r_asm_op_t *op, const ut8 *buf,
else strcpy (op->buf_asm, "- dec [ptr]");
break;
case ',':
strcpy (op->buf_asm, ", [ptr] = getch ()");
strcpy (op->buf_asm, ", peek [ptr]");
break;
case '.':
strcpy (op->buf_asm, ". print ([ptr])");
strcpy (op->buf_asm, ". poke [ptr]");
break;
case '\x00':
strcpy (op->buf_asm, " trap");
@ -65,12 +65,29 @@ static int disassemble(struct r_asm_t *a, struct r_asm_op_t *op, const ut8 *buf,
}
static int assemble(RAsm *a, RAsmOp *op, const char *buf) {
const char *arg = strchr (buf, ',');
const char *ref = strchr (buf, '[');
const char *ref, *arg;
int n = 0;
if (buf[0] && buf[1]==' ')
buf += 2;
arg = strchr (buf, ',');
ref = strchr (buf, '[');
if (!strncmp (buf, "trap", 4)) {
if (arg) {
n = atoi (arg+1);
memset (op->buf, 0xcc, n);
} else {
op->buf[0] = 0x90;
n = 1;
}
} else
if (!strncmp (buf, "nop", 3)) {
op->buf[0] = 0x90;
n++;
if (arg) {
n = atoi (arg+1);
memset (op->buf, 0x90, n);
} else {
op->buf[0] = 0x90;
n = 1;
}
} else
if (!strncmp (buf, "inc", 3)) {
char ch = ref? '+': '>';
@ -109,6 +126,24 @@ static int assemble(RAsm *a, RAsmOp *op, const char *buf) {
if (!strncmp (buf, "loop", 4)) {
op->buf[0] = ']';
n = 1;
} else
if (!strncmp (buf, "peek", 4)) {
if (arg) {
n = atoi (arg+1);
memset (op->buf, ',', n);
} else {
op->buf[0] = ',';
n = 1;
}
} else
if (!strncmp (buf, "poke", 4)) {
if (arg) {
n = atoi (arg+1);
memset (op->buf, '.', n);
} else {
op->buf[0] = '.';
n = 1;
}
}
return n;
}