Plov022 : some tuning and fixes

It's been some while since I worked on Plov. Lately I have been trying to install a cross compiler for AVR on Linux. And that's not easy. It's also ridiculous. You need to install 30 megabytes of libraries and executables to program a micro controller with 30 kilobytes of code space. It doesn't make sense and it is very much dependent on the Linux distribution in use. So I stopped the senseless quest for a C compiler that does all for all processors. And shifted attention back to my own compiler that targets ALL processors without getting bulky or clunky.

Changes in Plov022:

All in all, the PALO code generated by Plov seems robust enough to justify the start of work on the Palo code generator backend.

CLAIM and RELEASE have been added. They enable dynamic variables. CLAIM reserves space on the heap and sets the pointer variable. RELEASE discards the reserved space on the heap.
Both CLAIM and RELEASE are runtime tasks. In the running program, CLAIM is called to
 IF  space on the heap > required space  THEN
   Z := Z + required space
 ELSE
   Call ErrorRoutine
 END
   
We don't want the heap to fall through its bottom (thereby ruining the stack or some other area of memory), so we need to check for that bottom. In most cases, the bottom will never be reached. But if it does, an ErrorRoutine is called. In this procedure, either the problem is solved by some means, or the attention of the human operator is drawn with flashing lights and sirens. Or the controller is simply reset.


Some tests

Each run of the compiler generates three extra files:

of which only the latter is of importance to the Palo backend. The other two files are only significant for the human developer of the Palo backend, to check if the backe end generator works as expected.


testIRQ

PROGRAM testIRQ

PROCESSOR ATmega8515

VARIABLES  a x y z END




PROCEDURE OpenGate


BEGIN
   a := x + y
END OpenGate







PROCEDURE CloseGate

BEGIN
   x := y - a
END CloseGate








IRQ 0 = RESET
IRQ 1 = OpenGate
IRQ 2 = CloseGate

BEGIN
   OpenGate
END testIRQ
      
# PROGRAM testIRQ

PROCESSOR ATmega8515
CODESTART 34
# VARIABLE	a  at  96
# VARIABLE	x  at  98
# VARIABLE	y  at  100
# VARIABLE	z  at  102

# PROCEDURE DECLARATION OF OpenGate
LABEL OpenGate

MEMORY 96
FETCH 98
FETCH 100
ADD
SAVE

RETURN
# END OF PROCEDURE OpenGate


# PROCEDURE DECLARATION OF CloseGate
LABEL CloseGate

MEMORY 98
FETCH 100
FETCH 96
SUBTRACT
SAVE

RETURN
# END OF PROCEDURE CloseGate


VECTOR 0  MAINLOOP
VECTOR 1  OpenGate
VECTOR 2  CloseGate

LABEL MAINLOOP

CLAIM 0
CALL OpenGate
RELEASE 0

LABEL EXITMAINLOOP
STOP
# Done #
      


Page created on 10 May 2010 and