Magic squares, programmed in AVRco Pascal


In case you prefer a more sophisticated way of coding, you might go for the AVRco (download at https://www.e-lab.de/AVRco/), the free demo version of which compiles up to an object file size of 4096 bytes.

For the standard version they will charge you € 572.39

Actually, the syntax of AVRco is something near Modula, but at the end of the day, you will manage to handle the AVRco IDE and compile without any errors.

And it turns out that the magic squares algorithm fits nicely in the 4096 bytes. Don't expect any extras ...

Once you finished it will come up like this using a serial terminal with your PC:

Magische Quadrate mit AVRco Pascal Compiler

Versuch: 167242 Loesung Nr. 1:
 |  1 |  2 | 15 | 16
 | 12 | 14 |  3 |  5
 | 13 |  7 | 10 |  4
 |  8 | 11 |  6 |  9

Versuch: 183934 Loesung Nr. 2:
 |  1 |  2 | 15 | 16
 | 13 | 14 |  3 |  4
 | 12 |  7 | 10 |  5
 |  8 | 11 |  6 |  9

Versuch: 383717 Loesung Nr. 3:
 |  1 |  2 | 16 | 15
 | 13 | 14 |  4 |  3
 | 12 |  7 |  9 |  6
 |  8 | 11 |  5 | 10

Versuch: 522365 Loesung Nr. 4:
 |  1 |  3 | 14 | 16
 | 10 | 13 |  4 |  7
 | 15 |  6 | 11 |  2
 |  8 | 12 |  5 |  9
...

How to upload a hex file compiled by AVRco?
If you have installed an Arduino IDE just open a command window and enter the following command:

> path-to-AVRDUDE/avrdude.exe -Cpath-to-AVRDUDE.CONF/avrdude.conf -v -patmega328p -carduino -PCOMthe-port-number -b115200 -D -Uflash:w:path-to-the-hex-file\name-of-the-hex-file.hex:i

everything on ONE single line. Of course, you have to replace the path and filename according to your environment.
You might find those pathes easily by selecting "Show verbose output during upload" in the Arduino Preferences window. They will be printed red on black just below your Arduino code.

The good news: the Arduino bootloader will not become overwritten.

the source

the HEX file


contact: nji(at)gmx.de