Skip to content

Add debug#438

Merged
oxe-i merged 5 commits into
exercism:mainfrom
oxe-i:addDebug
May 10, 2026
Merged

Add debug#438
oxe-i merged 5 commits into
exercism:mainfrom
oxe-i:addDebug

Conversation

@oxe-i

@oxe-i oxe-i commented May 8, 2026

Copy link
Copy Markdown
Contributor

Add debug.mac

This PR adds a debug.mac macro file to the templates directory, with many macros for debugging support (printing to stdout). This file was based on a similar one in the test-runner folder, with the following changes:

  1. Added support to double floating-point values.
  2. Added support to packed floating-point/integer values in XMM registers. A XMM register may be interpreted as 16 byte integers, 8 word integers, 4 dword integers or 2 qword integers, as well as 4 dword or 2 qword floating-point values. Any of those integer values may be interpreted as signed, decimal unsigned or printed in hexadecimal format.
  3. Normalized the behavior for all integer formatting strings, so that they are all 64-bit values now ("%zd", "%zX", "zu").
  4. Changed the name of the file from debug.asm to debug.mac. That is the default file extension for macro files, which must be included as a whole in another asm file in order to be used. The extension .asm also makes NASM assemble the file separately and the compiler complains if there is no .note.GNU-stack section, making the stack executable.

Change bin/update-from-templates

This script was only copying the Makefile and the files in the vendor folder to practice exercises. Added support to concept exercises and to the debug.mac file, so that this file was propagate to every exercise.

This also revealed that the Makefile for practice exercises had a few extra flags not present in the Makefile for concept exercises.

Added a templates/concept_Makefile

Concept exercises don't have an example.asm, but a exemplar.asm. So I added a second template Makefile for concept exercises with the correct file name.

Added support to double in unity.h

By default, Unity doesn't support double, only float. This can be changed by adding a #define UNITY_INCLUDE_DOUBLE 1 in the unity.h file. This change doesn't impact tests using float.

A few concept exercises already had this flag set (for example, freelancer-rates), and another that sets a default precision for double comparison. In order to have an uniform treatment, I added both flags to templates/vendor/unity.h and propagated the change to all exercises.

This PR should be merged together with another in the test-runner that adds the complete debug.mac file. I haven't PRed there yet so I can still make changes here to keep things in sync.

@oxe-i

oxe-i commented May 8, 2026

Copy link
Copy Markdown
Contributor Author

Changes I didn't make, because I wanted to have your opinions first:

  1. Should I add debug.mac by default in the stubs? The problem is that maybe this affects the line count for submissions, as if those macros were written by the students. I thought we could add the %include commented out, so students can uncomment if necessary.
  2. Should I make debug.mac visible in the online editor by adding it under files -> editor in the config.json of the exercise, as described here?

@oxe-i oxe-i added the x:rep/large Large amount of reputation label May 9, 2026

@keiravillekode keiravillekode left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should mention this, and how to %include it, in https://exercism.org/docs/tracks/x86-64-assembly/tests

The ocaml and reasonml tracks use an editor file for the method signature. Otherwise, use of editor is rare.

@oxe-i oxe-i merged commit e32aecb into exercism:main May 10, 2026
5 checks passed
@oxe-i oxe-i deleted the addDebug branch May 10, 2026 18:49
@oxe-i

oxe-i commented May 10, 2026

Copy link
Copy Markdown
Contributor Author

We should mention this, and how to %include it, in https://exercism.org/docs/tracks/x86-64-assembly/tests

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

x:rep/large Large amount of reputation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants