dasm-assembler / dasm-assembler/dasm

Combee bitmap patch

Open
#12 12 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C
Stars
257
Forks
55
PR merge metrics
No merged PRs in 30d

Description

Consider adding Ben Coombe's bitmap changes, as listed in the PATCHES file...

From: Ben Combee [mailto:ben.combee@gmail.com] On Behalf Of Ben Combee
Sent: Thursday, February 28, 2008 8:56 AM
To: atari2600@taswegian.com
Subject: Bitmap format patch for DASM

Hi, Andrew... I just started up a 2600 project of my own, and I've done
a few local modifications to the DASM source -- most are to make it
compile without warnings in CodeWarrior for Windows, but I also added a
new integer representation inspired by some of the disassemblies I've
seen. I call it bitmap format, and instead of a leading %, you use a
leading | followed by dots and Xs. A trailing | is allowed, but not
required. Here's an example.

PfDataStart
   .byte |..XXX...|
   .byte |....X...|
   .byte |X..XX..X|
   .byte |.XX..XXX|
   .byte |.XX..XXX|
   .byte |X..XX..X|
   .byte |....X...|
   .byte |..XXX...|
PfDataEnd

I find it easier to visualize the bitmaps in the code using this format,
as 0's and 1's aren't that distinctive.

Here's the code change made to exp.c. I added this new function just
before pushbin():

char *pushbitmap(char *str)
{
    long val = 0;
    while (*str == '.' || *str == 'X') {
        val = (val << 1) | (*str == 'X');
        ++str;
    }
    if (*str == '|') {
        ++str;
    }
    stackarg(val, 0, NULL);
    return str;
}

Then I modified the case statement around line 314:

    case '|':   /*  13: |   11: ||              */

        if (str[1] == '.' || str[1] == 'X')
        {
            str = pushbitmap(str+1);
        }
        else if (str[1] == '|')
        {
            doop((opfunc_t)op_oror, 11);
            str += 2;
        }
        else
        {
            doop((opfunc_t)op_or, 13);
            ++str;
        }
        break;

I'd be glad to send the other changes, but they're mostly just adding
"static" in front of local functions and cleaning up some loops that
used a ";" to do nothing into using "{ }" instead (it tells the compiler
that you intended on the empty action rather than just using a semicolon
accidentally by habit.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review PATCHES and exp.c, especially the parser case around line 314 and the existing pushbin() handling. Confirm how bitmap literals should coexist with the existing | and || operators, then implement the requested syntax and verify that the bitmap examples in the issue assemble as intended.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
compilers
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.