Skip to content

debug.asm #437

Description

@oxe-i

Since this seems to be test-runner week, I've been looking into the x86-64 test runner. Although I haven't come up with a way to reduce image size yet, I did find out there is a file debug.asm that is copied into the solution directory for every submission. This file is basically a buch of macros that are high-level wrappers for calling printf on various data types and sizes.

This means students can have debug support just adding %include "debug.asm" at the top of their solution file and passing a register to the relevant debugging macro. This would be, for example, something like debugd32 esi for a 32-bit signed integer on esi. I tested it on a few exercises and it did work.

I don't remember this being documented anywhere. As this debug.asm is actually just a macro file, as far as I know, it must be explicitly added to the solution file with the %include directive like I mentioned. So we could add the file to the template folder for it to be downloaded when students work locally, and then we could add this %include to the stub file for all exercises.

Two things about this debug.asm file:

  1. It doesn't have support to printing doubles, just floats. This is of course easily fixed, it is just a matter of copying the same macro but using a movsd instead of a ctvss2sd.
  2. It preserves only the low 8 bytes of XMM registers, basically treating them as floating-point registers instead of SIMD registers. This is also easily fixed, we could save all 16 bytes or extend it to YMM's 32 bytes or even ZMM's 64 bytes. In any case, we could add some macros to debug SIMD registers.

I'll work on that today.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions