Files
hugo-asm-shortcode/demo/content/posts/asm.md
√(noham)² 92e8af31c3 Initial commit
2026-02-01 15:07:11 +01:00

3.5 KiB

title, date, summary, aliases, tags, author, showToc, TocOpen, draft, hidemeta, comments, disableHLJS, disableShare, hideSummary, searchHidden, ShowReadingTime, ShowBreadCrumbs, ShowPostNavLinks, ShowWordCount, ShowRssButtonInSectionTermList, UseHugoToc
title date summary aliases tags author showToc TocOpen draft hidemeta comments disableHLJS disableShare hideSummary searchHidden ShowReadingTime ShowBreadCrumbs ShowPostNavLinks ShowWordCount ShowRssButtonInSectionTermList UseHugoToc
Adding ASM code blocks 2026-02-01 How to add assembly code blocks in Hugo using custom shortcodes
/posts/asm/
hugo
asm
assembly
code blocks
Noham true false true false true false false false true true true true true true true

x86 basic example

{{</* asm mode="raw" arch="x86" */>}}
mov rax, 1
xor rdi, rdi
syscall
{{</* /asm */>}}

{{< asm mode="raw" arch="x86" >}} mov rax, 1 xor rdi, rdi syscall {{< /asm >}}

ARM64 basic example

{{</* asm mode="raw" arch="arm" */>}}
mov w0, #1
mov w1, #1
add w2, w0, w1
ret
{{</* /asm */>}}

{{< asm mode="raw" arch="arm" >}} mov w0, #1 mov w1, #1 add w2, w0, w1 ret {{< /asm >}}

x86 + hex example

{{</* asm mode="hex" arch="x86" */>}}
48 c7 c0 01 00 00 00 | mov rax, 1
48 31 ff             | xor rdi, rdi
0f 05                | syscall
{{</* /asm */>}}

{{< asm mode="hex" arch="x86" >}} 48 c7 c0 01 00 00 00 | mov rax, 1 48 31 ff | xor rdi, rdi 0f 05 | syscall {{< /asm >}}

Hex with capitalization

{{</* asm mode="hex" capitalize="true" */>}}
48 c7 c0 01 00 00 00 | mov rax, 1
{{</* /asm */>}}

{{< asm mode="hex" capitalize="true" >}} 48 c7 c0 01 00 00 00 | mov rax, 1 {{< /asm >}}

Full example

{{</* asm mode="full" arch="arm" */>}}
00000000 | 20 00 80 52 | mov w0, #1
00000004 | 21 00 80 52 | mov w1, #1
00000008 | c0 03 5f d6 | ret
{{</* /asm */>}}

{{< asm mode="full" arch="arm" >}} 00000000 | 20 00 80 52 | mov w0, #1 00000004 | 21 00 80 52 | mov w1, #1 00000008 | c0 03 5f d6 | ret {{< /asm >}}

Full with capitalization

{{</* asm mode="full" arch="x86" capitalize="true" */>}}
00401000 | 48 c7 c0 01 00 00 00 | mov rax, 1
00401007 | 48 31 ff             | xor rdi, rdi
0040100a | 0f 05                | syscall
{{</* /asm */>}}

{{< asm mode="full" arch="x86" capitalize="true" >}} 00401000 | 48 c7 c0 01 00 00 00 | mov rax, 1 00401007 | 48 31 ff | xor rdi, rdi 0040100a | 0f 05 | syscall {{< /asm >}}

ARM64 with hex bytes

{{</* asm mode="hex" arch="arm" */>}}
20 00 80 52 | mov w0, #1
21 00 80 52 | mov w1, #1
42 00 01 0b | add w2, w2, w1
c0 03 5f d6 | ret
{{</* /asm */>}}

{{< asm mode="hex" arch="arm" >}} 20 00 80 52 | mov w0, #1 21 00 80 52 | mov w1, #1 42 00 01 0b | add w2, w2, w1 c0 03 5f d6 | ret {{< /asm >}}

Longer x86 function example

{{</* asm mode="full" arch="x86" */>}}
00401000 | 55                   | push rbp
00401001 | 48 89 e5             | mov rbp, rsp
00401004 | 48 83 ec 10          | sub rsp, 0x10
00401008 | 89 7d fc             | mov [rbp-0x4], edi
0040100b | 8b 45 fc             | mov eax, [rbp-0x4]
0040100e | 83 c0 01             | add eax, 0x1
00401011 | c9                   | leave
00401012 | c3                   | ret
{{</* /asm */>}}

{{< asm mode="full" arch="x86" >}} 00401000 | 55 | push rbp 00401001 | 48 89 e5 | mov rbp, rsp 00401004 | 48 83 ec 10 | sub rsp, 0x10 00401008 | 89 7d fc | mov [rbp-0x4], edi 0040100b | 8b 45 fc | mov eax, [rbp-0x4] 0040100e | 83 c0 01 | add eax, 0x1 00401011 | c9 | leave 00401012 | c3 | ret {{< /asm >}}