1
0
mirror of https://github.com/KarolS/millfork.git synced 2025-01-15 09:29:49 +00:00
millfork/docs/api/getting-started.md

75 lines
1.9 KiB
Markdown
Raw Normal View History

2018-04-03 00:21:26 +02:00
[< back to index](../index.md)
2017-12-07 00:23:30 +01:00
# Getting started
## Hello world example
2017-12-07 00:37:57 +01:00
Save the following as `hello_world.mfk`:
2017-12-07 00:23:30 +01:00
```
import stdio
void main(){
2018-12-24 01:32:17 +01:00
putstrz("hello world"z)
2017-12-07 00:23:30 +01:00
while(true){}
}
```
2018-12-24 01:32:17 +01:00
Compile it using the following commandline:
2017-12-07 00:23:30 +01:00
```
2018-12-24 02:38:28 +01:00
java -jar millfork.jar hello_world.mfk -o hello_world -t c64
2017-12-07 00:23:30 +01:00
```
Run the output executable (here using the VICE emulator):
```
x64 hello_world.prg
```
2018-12-24 02:38:28 +01:00
## Basic command-line usage
2017-12-07 00:23:30 +01:00
2018-12-24 02:38:28 +01:00
The following options are obligatory when compiling your sources:
2017-12-07 00:23:30 +01:00
2019-06-14 11:39:11 +02:00
* `-o FILENAME` specifies the base name for your output file, an appropriate file extension will be appended:
`prg` for Commodore;
`crt` for Commodore cartridges;
`xex` for Atari computers;
`a2` for Apple;
`dsk` for PC-88;
`tap` for ZX Spectrum;
`rom` for MSX cartridges;
`com` for CP/M;
`nes` for Famicom;
`bin` for Atari 2600;
`inf` for BBC file metadata;
`asm` for assembly output;
`lbl`, `nl`, `fns`, or `sym` for label file
2019-06-05 18:34:32 +02:00
* `-t PLATFORM` specifies the target platform.
Each platform is defined in an `.ini` file in the include directory.
For the list of supported platforms, see [Supported platforms](target-platforms.md)
2017-12-07 00:23:30 +01:00
You may be also interested in the following:
2018-06-04 16:24:18 +02:00
* `-O`, `-O2`, `-O3`, `-O4` enable optimization (various levels)
2017-12-07 00:23:30 +01:00
2018-07-01 19:19:30 +02:00
* `-finline` automatically inline functions for better optimization
2017-12-07 00:23:30 +01:00
2018-07-01 19:19:30 +02:00
* `-fipo` enable interprocedural optimization
2017-12-07 00:23:30 +01:00
* `-s` additionally generate assembly output
2019-05-31 17:27:38 +02:00
(if targeting Intel 8080/8085, use `--syntax=intel` or `--syntax=zilog` to choose the preferred assembly syntax)
2017-12-07 00:23:30 +01:00
2018-12-17 00:35:32 +01:00
* `-fsource-in-asm` show original Millfork source in the assembly output
2019-06-14 11:39:11 +02:00
* `-g` additionally generate a label file
2017-12-07 00:23:30 +01:00
* `-r PROGRAM` automatically launch given program after successful compilation
* `-Wall` enable all warnings
2018-01-04 01:15:04 +01:00
* `--help` list all commandline options
2018-12-24 02:38:28 +01:00
For the comprehensive list of command-line options, see [Command-line options](./command-line.md).