Translation Algorithm
Here is introduced the algorithm used by the interpreter MAL: 1)Divides instructions in blocks, each block is defined by a label.
2)Searchs in each instruction eventual conditional branches and divides it in IFs and ELSEs blocks.
3)If conditional branches were found, engages n position in controlStore from 0 to n (for the first instructions in ELSEs blocks) and n positions from 256 to 256+n(for the first instruction in IFs blocks).
4)Assigns to all instructions the right address, obviously beginning ,from n+1 address); if instuction is the first of a block reserves its address in an appropriate data structure called PRIME.
5)After we assigned all the addresses, assigns to each instruction the next instruction address.
5a)If instruction contains a branch searchs for an address to which jump in the data structure PRIME.
5b)If instruction NOT contains a branch assigns to this its address+1.
6)Traduces all the instructions.