Multi-target assembler supporting Z80, 8080/8085, and 8086 instruction sets. Produces relocatable object files (.obj) for linking with hclink. Syntax is inspired by NASM with platform-specific extensions.
| Binary | Target |
| hcasm-z80 | Zilog Z80 |
| hcasm-8086 | Intel 8086 (also used for 8086exe) |
| hcasm-8080 | Intel 8080 |
| hcasm-8085 | Intel 8085 |
Usage
hcasm-{target} [options] <input.s>
Options:
-o <file> Output object file (default: a.obj)
-dump <file> Generate assembly listing dump
-h Show help
Source Format
label: mnemonic arg1, arg2 ; comment
- Labels: end with :, must start at column 1 (no leading whitespace)
- Instructions: must be indented with a tab or spaces
- Comments: start with ; and run to end of line
- Case-insensitive: all mnemonics, registers, and directives
Labels
global _start ; export symbol for linker
extern printf ; import symbol from another module
_start: ; global label
.loop: ; sub-label (becomes _start.loop)
jp .loop ; references _start.loop
Sections
section text ; executable code
section data ; initialized data (db, dw, dd)
section bss ; uninitialized data (ds, rb, resb, rw, resw)
Output order: text → data → bss. BSS is zero-filled at load time.
Data Directives
| Directive | Description | Examples |
| db | Define byte(s) | db 0x12, "Hello", 0 |
| dw | Define word(s), 16-bit LE | dw 0x1234, label, "AB" |
| dd | Define dword(s), 32-bit LE | dd 0x12345678 |
| ds / rb / resb | Reserve bytes | ds 256 |
| rw / resw | Reserve words (size × 2 bytes) | rw 128 |
| equ | Define constant | SIZE equ 512 |
| times | Repeat directive/instruction | times 256 db 0 |
Expressions and Number Formats
| Format | Example | Notes |
| Decimal | 42 | Standard |
| Hexadecimal | 0xFF, 0FFh | 0x prefix or trailing h |
| Binary | 0b1010 | 0b prefix |
| Octal | 0o777 | 0o prefix |
Operators: + - * / % — $ = current position — </LOBYTE — >/HIBYTE
Z80 — Syntax and Examples
| Feature | Syntax |
| Memory access | Always square brackets [] - ld a, [hl], ld [ix+5], a |
| Indexed addressing | ld a, [ix+10] / ld a, [iy-4] (signed displacement) |
| 16-bit load | ld hl, 0x1234 |
| 16-bit arithmetic | add hl, de / sbc hl, bc (HL only destination) |
| Exchange | ex de, hl / ex (sp), hl / ex af, af' |
| Block operations | ldi, ldd, cpi, cpir |
| Bit operations | set 0, a / res 1, [hl] / bit 2, b |
; Z80 CP/M "Hello World"
section text
global _start
_start:
ld de, msg
ld c, 9 ; BDOS print string
call 5
ld c, 0 ; BDOS exit
call 5
section data
msg: db "Hello, World!$"
8080/8085 — Syntax and Examples
| Feature | Syntax |
| Memory via HL | mov a, m = mov a, [hl] = mov a, [m] (all equivalent) |
| Memory via BC/DE (store) | stax b = stax bc = stax [bc] = stax [b] |
| Memory via BC/DE (load) | ldax b = ldax bc = ldax [bc] = ldax [b] |
| 16-bit load | lxi h, 0x1234 |
| 16-bit add | dad d (HL only destination) |
| Direct address load | lhld 0x1234 (load HL from memory) |
| 8085 extras | rim, sim (interrupt mask) |
; 8080 CP/M "Hello World"
section text
global _start
_start:
lxi d, msg
mvi c, 9
call 5
mvi c, 0
call 5
section data
msg: db "Hello, World!$"
8086 — Syntax and Examples
| Feature | Syntax |
| Memory via register | mov ax, [bx] / mov [si], ax |
| Based addressing | mov ax, [bp-2] / mov ax, [bp+4] |
| Based+indexed | mov ax, [bx+si] / mov ax, [bp+di+4] |
| Direct address | mov ax, [0x1234] |
| Immediate to memory | mov word [bp-2], 42 / mov byte [bx], 0 |
| Size prefixes | byte, word, dword (when operand size ambiguous) |
| Distance prefixes | short, near, far (override jump/call distance) |
| Segment overrides | es mov ax, [bx] (use ES instead of DS) |
| Repeat prefixes | rep movsb / repe cmpsb / repne scasb |
; 8086 MS-DOS "Hello World"
section text
global _start
_start:
mov ah, 9
mov dx, msg
int 0x21
mov ah, 0x4C
int 0x21
section data
msg: db "Hello, World!$"
Target Comparison
| Feature | Z80 | 8080/8085 | 8086 |
| Memory brackets | [] | [] or m | [] |
| Indexed addressing | [ix+d], [iy+d] | None | [bp+N], [bx+si] |
| Imm to memory | ld [ix+N], imm | Not native | mov word [mem], imm |
| Segments | N/A | N/A | es, cs, ss, ds |
| Size prefixes | N/A | N/A | byte, word, dword |
| 16-bit immediate | ld hl, imm | lxi h, imm | mov ax, imm |
| Direct addr load | ld hl, (addr) | lhld addr | mov ax, [addr] |
| Return value reg | hl | hl | ax |
| 16-bit arithmetic | add hl, rr adc/sbc hl, rr | dad rr | add ax, rx |