exercism / exercism/arm64-assembly

Add macro for debug output to console

Open
#189 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
12
Forks
9
PR merge metrics
No merged PRs in 30d

Description

Hi,
I'm currently learning Arm64 assembly and I find it quiet cumbersome to get gdb ready for debugging.
I guess on native ARM hardware it shouldn't be that hard but unfortunatly I'm doing the exercises on my x86 machine.

```
.macro debug reg fmt_str=""
.pushsection .rodata
.ifeqs "\fmt_str", ""
l_fmt_str\@: .asciz "Register \reg: %d\n"
.else
l_fmt_str\@: .asciz "\fmt_str"
.endif
.popsection

sub sp, sp, #16
stp x29, x30, [sp]
mov x29, sp // FP points to frame record

mov x1, \reg
ldr x0, =l_fmt_str\@
bl printf

ldp x29, x30, [sp]
add sp, sp, #16
.endm
```

I know, it's not perfect and there is a lot of room for improvement.
For example the register x0 and x1 are modified when the macro is used (the user might not expect this).
But I posted it so you get the idea what I have in mind.

An additional file like `debug.s` could be provided with the exercises which can be included by the user with `.include "debug.s"`

The macro is then called like so:
`debug x1` which give an output like `Register x1: 42`.

It can also be called with a user defined format string:
`debug x1 "My custom debug message: Register x1 is now set to %d\n"` which will give something like `"My custom debug message: Register x1 is now set to 42"`.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the proposed debug.s macro and how the exercises currently use .include, then check the existing build and run entry points. Done means users can include debug.s, call debug x1 or supply a custom format string, and receive the documented output without unexpected register or stack corruption.

Written by the indexing model from the issue text.

Assessment

Domain
developer-experience
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.