diff options
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 60 |
1 files changed, 30 insertions, 30 deletions
@@ -1,12 +1,12 @@ # hdass -hachem's dumb assembly super-set, pronounced "HD Ass", or "headass"...depends on how you feel that day. +hachem's dumb assembly super-set, pronounced "hd ass", or "headass"...depends on how you feel that day. -The entire point of this project is to provide a middle ground between C and assembly. If we think about why we still write assembly today, it's usually because we need direct control over what the CPU is doing. We want control over the exact instructions being executed, the memory, the stack and everything else that higher-level programming languages normally abstract away. The thing is, not every program written in assembly actually needs that control. Sometimes you want to write something close to the machine without having to manuall deal with every tiny detail yourself. You still want registers, explicit control over memory and a good understanding of what your program is doing, but you don't necessarily need to manually express everything as individual assembly instructions. +the entire point of this project is to provide a middle ground between c and assembly. if we think about why we still write assembly today, it's usually because we need direct control over what the cpu is doing. we want control over the exact instructions being executed, the memory, the stack and everything else that higher-level programming languages normally abstract away. the thing is, not every program written in assembly actually needs that control. sometimes you want to write something close to the machine without having to manuall deal with every tiny detail yourself. you still want registers, explicit control over memory and a good understanding of what your program is doing, but you don't necessarily need to manually express everything as individual assembly instructions. -This is where this piece of shit comes in. It's not quite high-level enough to be a C-like language, but it's also not low-level enough to be as annoying to write as raw assembly. The goal is to sit somewhere in between, keeping the parts of assembly that make it useful while making the parts that don't need to be painful a little nicer to work with. hdass transpiles into multiple flavours of assembly, currently NASM and FASM (MASM is planned), rather than directly producing machine code. The idea is to provide a single language for writing low-level programs while allowing the backend to translate code into the assembler syntax you want to target. You're still ultimately producing assembly, and you're never particularly far away from the code that gets assembled. The goal isn't to hide the machine from you or turn assembly into C. There are already plenty of high-level languages that do that. hdass just fills the gap between the two, where you might want some more convenience whilst writing assembly without taking away the reason you wanted to work close to the machine in the first place. +this is where this piece of shit comes in. it's not quite high-level enough to be a c-like language, but it's also not low-level enough to be as annoying to write as raw assembly. the goal is to sit somewhere in between, keeping the parts of assembly that make it useful while making the parts that don't need to be painful a little nicer to work with. hdass transpiles into multiple flavours of assembly, currently nasm and fasm (masm is planned), rather than directly producing machine code. the idea is to provide a single language for writing low-level programs while allowing the backend to translate code into the assembler syntax you want to target. you're still ultimately producing assembly, and you're never particularly far away from the code that gets assembled. the goal isn't to hide the machine from you or turn assembly into c. there are already plenty of high-level languages that do that. hdass just fills the gap between the two, where you might want some more convenience whilst writing assembly without taking away the reason you wanted to work close to the machine in the first place. -## Examples -Here's a simple "Hello, World!" world program written using hdass' syntax: +## examples +here's a simple "hello, world!" world program written using hdass' syntax: ```hdass [entry: main] @@ -31,46 +31,46 @@ proc main } ``` -The program still directly controls the registers used for the system calls. Nothing is hiding what the program is doing. More examples can be found in [examples/](examples/). +the program still directly controls the registers used for the system calls. nothing is hiding what the program is doing. more examples can be found in [examples/](examples/). -## Documentation -The docs live in [docs/](docs/): +## documentation +the docs live in [docs/](docs/): -- [Getting started](docs/getting-started.md) — build the compiler, write and run a first program on x86-64 and AArch64. -- [Language reference](docs/language.md) — directives, declarations, statements, control flow, memory, floats, raw instructions and extensions. -- [Targets](docs/targets.md) — architectures and assemblers, what each supports, and the per-architecture syscall ABIs. -- [Internals](docs/internals.md) — the compiler pipeline and how to add a backend or architecture. +- [getting started](docs/getting-started.md) — build the compiler, write and run a first program on x86-64 and aarch64. +- [language reference](docs/language.md) — directives, declarations, statements, control flow, memory, floats, raw instructions and extensions. +- [targets](docs/targets.md) — architectures and assemblers, what each supports, and the per-architecture syscall abis. +- [internals](docs/internals.md) — the compiler pipeline and how to add a backend or architecture. -## Building -The build is driven by [Meson](https://mesonbuild.com/). Configure a build directory and compile the compiler: +## building +the build is driven by [meson](https://mesonbuild.com/). configure a build directory and compile the compiler: ```bash meson setup build meson compile -C build ``` -This produces the `hdass` binary at `build/hdass`. The default build turns on the address and undefined-behaviour sanitizers; for an optimised build without them, configure a separate directory: +this produces the `hdass` binary at `build/hdass`. the default build turns on the address and undefined-behaviour sanitizers; for an optimised build without them, configure a separate directory: ```bash meson setup build-release --buildtype=release -Db_sanitize=none meson compile -C build-release ``` -To run the unit tests: +to run the unit tests: ```bash meson test -C build ``` -If [cppcheck](https://cppcheck.sourceforge.io/) is installed, `ninja -C build cppcheck` runs static analysis over the sources. +if [cppcheck](https://cppcheck.sourceforge.io/) is installed, `ninja -C build cppcheck` runs static analysis over the sources. -hdass emits x86-64 assembly, so to actually assemble and run its output you need an x86-64 Linux toolchain. The bundled Docker environment provides a consistent one on any host, including Apple Silicon, where the amd64 image runs under emulation. The image is a Debian base with `nasm`, `fasm`, `ld` (binutils), a C toolchain and Meson/Ninja preinstalled. +hdass emits x86-64 assembly, so to actually assemble and run its output you need an x86-64 linux toolchain. the bundled docker environment provides a consistent one on any host, including apple silicon, where the amd64 image runs under emulation. the image is a debian base with `nasm`, `fasm`, `ld` (binutils), a c toolchain and meson/ninja preinstalled. -Start the container (this builds the image the first time): +start the container (this builds the image the first time): ```bash docker compose up -d --build ``` -Open a shell inside it. The repository is bind-mounted at `/hdass`, so edits on the host are visible immediately: +open a shell inside it. the repository is bind-mounted at `/hdass`, so edits on the host are visible immediately: ```bash docker compose exec hdass bash ``` -From inside the container you can build the compiler and take a program all the way to a running executable: +from inside the container you can build the compiler and take a program all the way to a running executable: ```bash meson setup build-linux && meson compile -C build-linux ./build-linux/hdass examples/hello_world.hdass -o hello.asm @@ -79,35 +79,35 @@ ld -e main hello.o -o hello ./hello ``` -hdass targets NASM by default; pass `-t fasm` to emit FASM instead, which assembles in a single step: +hdass targets nasm by default; pass `-t fasm` to emit fasm instead, which assembles in a single step: ```bash ./build-linux/hdass -t fasm examples/hello_world.hdass -o hello.asm fasm hello.asm hello.o ld -e main hello.o -o hello ``` -To transpile, assemble, link and run every program in [examples/](examples/) and check its output, use the end-to-end test script (also from inside the container): +to transpile, assemble, link and run every program in [examples/](examples/) and check its output, use the end-to-end test script (also from inside the container): ```bash meson setup build-linux && meson compile -C build-linux && ./scripts/test_examples.sh ``` -Or, from the host, run the whole suite (unit tests plus the example tests) in one shot, bringing the container up if needed: +or, from the host, run the whole suite (unit tests plus the example tests) in one shot, bringing the container up if needed: ```bash ./scripts/docker_test.sh ``` -To build, assemble, link and run a single program in the container: +to build, assemble, link and run a single program in the container: ```bash ./scripts/run.sh examples/circle.hdass ``` -When you're finished, stop and remove the container: +when you're finished, stop and remove the container: ```bash docker compose down ``` -## Disclaimer -hdass is extremely experimental. The language, syntax and semantics are still being figured out, so things will probably change, sometimes because there is a better way to do something and sometimes because I decided the old syntax looked stupid. +## disclaimer +hdass is extremely experimental. the language, syntax and semantics are still being figured out, so things will probably change, sometimes because there is a better way to do something and sometimes because i decided the old syntax looked stupid. -## License -This project is licensed under the MIT License. See [LICENSE](LICENSE) for more information. +## license +this project is licensed under the mit license. see [license](LICENSE) for more information. |
