1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-12-27 04:29:34 +00:00
millfork/docs/api/getting-started.md

68 lines
1.7 KiB
Markdown
Raw Normal View History

2019-07-15 12:21:50 +00:00
[< back to index](../doc_index.md)
2018-04-02 22:21:26 +00:00
2017-12-06 23:23:30 +00:00
# Getting started
## Hello world example
2017-12-06 23:37:57 +00:00
Save the following as `hello_world.mfk`:
2017-12-06 23:23:30 +00:00
```
import stdio
void main(){
2018-12-24 00:32:17 +00:00
putstrz("hello world"z)
2017-12-06 23:23:30 +00:00
while(true){}
}
```
2018-12-24 00:32:17 +00:00
Compile it using the following commandline:
2017-12-06 23:23:30 +00:00
```
2018-12-24 01:38:28 +00:00
java -jar millfork.jar hello_world.mfk -o hello_world -t c64
2017-12-06 23:23:30 +00:00
```
2019-07-15 11:52:05 +00:00
or if you're using a Windows native build:
```
millfork hello_world.mfk -o hello_world -t c64
```
2017-12-06 23:23:30 +00:00
Run the output executable (here using the VICE emulator):
```
x64 hello_world.prg
```
2018-12-24 01:38:28 +00:00
## Basic command-line usage
2017-12-06 23:23:30 +00:00
2018-12-24 01:38:28 +00:00
The following options are obligatory when compiling your sources:
2017-12-06 23:23:30 +00:00
2019-09-14 00:40:03 +00:00
* `-o <FILENAME>` specifies the base name for your output file, an appropriate file extension will be appended.
2019-06-05 16:34:32 +00:00
2019-09-14 00:40:03 +00:00
* `-t <PLATFORM>` specifies the target platform.
2019-06-05 16:34:32 +00:00
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-06 23:23:30 +00:00
You may be also interested in the following:
2018-06-04 14:24:18 +00:00
* `-O`, `-O2`, `-O3`, `-O4` enable optimization (various levels)
2017-12-06 23:23:30 +00:00
2018-07-01 17:19:30 +00:00
* `-finline` automatically inline functions for better optimization
2017-12-06 23:23:30 +00:00
2018-07-01 17:19:30 +00:00
* `-fipo` enable interprocedural optimization
2017-12-06 23:23:30 +00:00
* `-s` additionally generate assembly output
2019-05-31 15:27:38 +00:00
(if targeting Intel 8080/8085, use `--syntax=intel` or `--syntax=zilog` to choose the preferred assembly syntax)
2017-12-06 23:23:30 +00:00
2018-12-16 23:35:32 +00:00
* `-fsource-in-asm` show original Millfork source in the assembly output
2019-06-14 09:39:11 +00:00
* `-g` additionally generate a label file
2017-12-06 23:23:30 +00:00
2019-09-14 00:40:03 +00:00
* `-r <PROGRAM>` automatically launch given program after successful compilation; you can supply extra params for it with `-R <PARAM>`
2017-12-06 23:23:30 +00:00
* `-Wall` enable all warnings
2018-01-04 00:15:04 +00:00
* `--help` list all commandline options
2018-12-24 01:38:28 +00:00
For the comprehensive list of command-line options, see [Command-line options](./command-line.md).