~rabbits/public-inbox

1

[patch] uxnasm symbol file generation

Details
Message ID
<CAF-1gK_qTut9SrE6CiisXB8VnjH1_KBSHVy7+1OycJV_sajGsw@mail.gmail.com>
DKIM signature
pass
Download raw message
Without casting the pointer the +1 pointer offset yields the incorrect
high byte of the symbol address. There may be another way to fix it,
but this is what worked for me.

-Dave

--- a/src/uxnasm.c
+++ b/src/uxnasm.c
@@ -451,7 +451,7 @@ writesym(char *filename)
    fp = fopen(scat(scpy(filename, symdst, slen(filename) + 1), ".sym"), "w");
    if(fp != NULL) {
        for(i = 0; i < p.llen; i++) {
-            fwrite(&p.labels[i].addr + 1, 1, 1, fp);
+            fwrite((Uint8*)&p.labels[i].addr + 1, 1, 1, fp);
            fwrite(&p.labels[i].addr, 1, 1, fp);
            fwrite(p.labels[i].name, slen(p.labels[i].name) + 1, 1, fp);
        }
Details
Message ID
<CAKis=aGJKfyJsU_QRiQ46fm5EF5DSDY9BvdVkzj2i-_8bhPCHg@mail.gmail.com>
In-Reply-To
<CAF-1gK_qTut9SrE6CiisXB8VnjH1_KBSHVy7+1OycJV_sajGsw@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
Cheers Dave :)
Good catch, merged.

On 1/11/23, Dave VanEe <dave.vanee@gmail.com> wrote:
> Without casting the pointer the +1 pointer offset yields the incorrect
> high byte of the symbol address. There may be another way to fix it,
> but this is what worked for me.
>
> -Dave
>
> --- a/src/uxnasm.c
> +++ b/src/uxnasm.c
> @@ -451,7 +451,7 @@ writesym(char *filename)
>     fp = fopen(scat(scpy(filename, symdst, slen(filename) + 1), ".sym"),
> "w");
>     if(fp != NULL) {
>         for(i = 0; i < p.llen; i++) {
> -            fwrite(&p.labels[i].addr + 1, 1, 1, fp);
> +            fwrite((Uint8*)&p.labels[i].addr + 1, 1, 1, fp);
>             fwrite(&p.labels[i].addr, 1, 1, fp);
>             fwrite(p.labels[i].name, slen(p.labels[i].name) + 1, 1, fp);
>         }
>
Reply to thread Export thread (mbox)