From b179cdf7ecb7ad871df137c41c97889cfcdb5f1d Mon Sep 17 00:00:00 2001 From: Sam Hadow Date: Fri, 5 Apr 2024 10:53:00 +0200 Subject: [PATCH] begin RAM, pushdown automaton --- src/stack.asm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/stack.asm diff --git a/src/stack.asm b/src/stack.asm new file mode 100644 index 0000000..7540a8d --- /dev/null +++ b/src/stack.asm @@ -0,0 +1,21 @@ +(5,2,5,5,0) +ADD(0, 0, r0) // r0 current state in pushdown automaton +ADD(2, 0, r1) // r1 cursor position in input word, (i2 first symbol of input word, i1 length of input word) +ADD(9, 0, r8) // r8, address of stack top +ADD(2, 0, r9) // r9 bottom symbol +ADD(i1, 2, r2) // r2, address first automaton instruction begin state 'q', instruction: (q, a, A, w, q′) +ADD(r2, 1, r3) // r3, address instruction read symbol 'a' +ADD(r3, 1, r4) // r4, address instruction read stack symbol 'A' +ADD(r4, 1, r5) // r5, address, instruction word pushed on stack length +ADD(r5, i@r5, r6) +ADD(1, r6, r6) // r6, address, next state q' + + +JE(r0, i@r2, ) // current state is the expected state in the instruction + +JE(i@r1, 2, ) // read symbol is epsilon +JE(i@r3, i@r1, ) // symbol in input == read symbol +JUMP() +JE(i@r4, 2, ) // read stack symbol is epsilon +JE(r@r6, i@r4, ) // stack top is the to expected symbol +