elikaski / BF-it

A C-like language to Brainfuck compiler, written in Python
MIT License
120 stars 11 forks source link

Using a variable with printchar could be optimized #25

Open NeeEoo opened 3 years ago

NeeEoo commented 3 years ago

Printing using a variable without math operations is a bit unoptimized. It first copies the variable and then prints the copy.

int x = 65;
printchar(x);

Results in (pseudo code)

Set x to 65
Move x to dest and temp
Move temp to x
Print dest
Clear dest

This could be optimized as

Set x to 65
Print x