急救:::如何编写一个编译器?!~~
哪位牛人知道L1吗? 我需要编一个L1 -> x86 的编译器, 什么语言编的都行,希望大家能给点提示,给我讲讲编译器是怎么回事都行~!~ 我是一大菜鸟!~~~
下面是L1的一个代码,结果得89:
(((esi <- 89) ;; size of the array to create
(eax <- (allocate esi 3))
(edi <- eax) ;; save this register for the array base pointer
(ebx <- edi) ;; - loop index variable is now a pointer into
(ebx += 12) ;; the array; it starts at the 2nd word.
(esi *= 2) ;; - convert esi so it is the location of
(esi += 2) ;; the word just past the end of
(esi += edi) ;; the array
:loop
(cjump ebx < esi :keep_going :done)
:keep_going
(edx <- (mem ebx -8))
(ecx <- (mem ebx -4))
(edx += ecx)
(edx -= 1)
((mem ebx 0) <- edx)
(ebx += 4)
;; go back to the loop test
(goto :loop)
:done
(eax <- (print edi))))