Skip to content

general: move code examples to a separate directory - #93

Merged
0xAX merged 1 commit into
masterfrom
move-examples
Aug 25, 2026
Merged

general: move code examples to a separate directory#93
0xAX merged 1 commit into
masterfrom
move-examples

Conversation

@0xAX

@0xAX 0xAX commented Aug 23, 2026

Copy link
Copy Markdown
Owner

Description

This PR moves all code examples to a separate directory to make CI jobs easier. In the same time CI jobs to test code examples were added.

Related issues

#25

@0xAX
0xAX requested a review from klaudiagrz as a code owner August 23, 2026 12:53
Comment thread content/asm_6.md Outdated
Comment on lines +400 to +401
;; Preserve the pointer to the current floating-point value in the r12 register,
;; becase the strtod(3) may change it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
;; Preserve the pointer to the current floating-point value in the r12 register,
;; becase the strtod(3) may change it.
;; Preserve the pointer to the current floating-point value in the r12 register,
;; because the strtod(3) may change it.

Comment thread content/asm_7.md Outdated
Comment on lines +219 to +224
- `a` - tells the compiler to use the [`rax`](./asm_2.md) register.
- `b` - tells the compiler to use the [`rbx`](./asm_2.md) register.
- `c` - tells the compiler to use the [`rcx`](./asm_2.md) register.
- `d` - tells the compiler to use the [`rdx`](./asm_2.md) register.
- `S` - tells the compiler to use the [`rsi`](./asm_2.md) register.
- `D` - tells the compiler to use the [`rdi`](./asm_2.md) register.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe would be better to add only one link? Could be as a sentence below:

For more information about registers, read...

Comment thread examples/float/dot_product.asm Outdated
;; the strtod(3) will finish its work.
mov rsi, end_buffer_1
;; Preserve the pointer to the current floating-point value in the r12 register,
;; becase the strtod(3) may change it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
;; becase the strtod(3) may change it.
;; because the strtod(3) may change it.

Comment thread examples/float/dot_product.asm Outdated
;; the strtod(3) will finish its work.
mov rsi, end_buffer_2
;; Preserve the pointer to the current floating-point value in the r12 register,
;; becase the strtod(3) may change it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
;; becase the strtod(3) may change it.
;; because the strtod(3) may change it.

Comment thread CONTRIBUTING.md Outdated

Besides the tools from the [Requirements](./README.md#requirements) section, the script needs [GCC](https://gcc.gnu.org/) to build the examples that interact with C, and [Python](https://www.python.org/) to run the examples that expect a terminal.

A new example also needs a `test_<name>` function in the script and an entry in the `example` list of the [Examples](./.github/workflows/examples.yaml) workflow. The same script runs in the continuous integration for every pull request, so a broken example fails the build.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A new example also needs a `test_<name>` function in the script and an entry in the `example` list of the [Examples](./.github/workflows/examples.yaml) workflow. The same script runs in the continuous integration for every pull request, so a broken example fails the build.
When adding a new example, you also need to add a `test_<name>` function in the script and an entry in the `example` list of the [Examples](./.github/workflows/examples.yaml) workflow. The same script runs in continuous integration for every pull request, so a broken example fails the build.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to make it clear that a contributor must do it

Comment thread scripts/ci/test-examples.sh Outdated
expect_status "exits with success" 0 "${status}"

output="$("${EXAMPLES}/stack/stack" 5 | tr -d '\0')"
expect_output "complains about the number of arguments" \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

complains?

Comment thread scripts/ci/test-examples.sh Outdated

output="$("${EXAMPLES}/casm/casm3/casm" 2>&1)"
status=$?
expect_contains "complains about the number of arguments" \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

complains?

Comment thread examples/README.md Outdated
@@ -0,0 +1,20 @@
# Code examples

These are the example programs that accompany the book. Each directory is a standalone program with its own `Makefile` and `README.md`.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
These are the example programs that accompany the book. Each directory is a standalone program with its own `Makefile` and `README.md`.
These are the sample programs that accompany the book. Each directory is a standalone program with its own `Makefile` and `README.md`.

@0xAX
0xAX force-pushed the move-examples branch 2 times, most recently from 2957a72 to 8710e18 Compare August 24, 2026 13:33
Comment thread scripts/ci/test-examples.sh Outdated
expect_status "exits with success" 0 "${status}"

output="$("${EXAMPLES}/stack/stack" 5 | tr -d '\0')"
expect_output "output contains error about the number of arguments" \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expect_output "output contains error about the number of arguments" \
expect_output "output contains an error about the number of arguments" \

Comment thread scripts/ci/test-examples.sh Outdated

output="$("${EXAMPLES}/casm/casm3/casm" 2>&1)"
status=$?
expect_contains "output contains error about the number of arguments" \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expect_contains "output contains error about the number of arguments" \
expect_contains "output contains an error about the number of arguments" \

@0xAX
0xAX merged commit b0678d2 into master Aug 25, 2026
9 checks passed
@0xAX
0xAX deleted the move-examples branch August 25, 2026 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants