dasm-assembler / dasm-assembler/dasm

Request to put tested and ready made upgrades into DASM

Open
#157 11 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

For my current project, I had to add a few features to DASM which may be useful for other DASM users:

  • source files now can have line numbers starting at first character. These are ignored / skipped.
    As DASM required labels to begin at the first position in a line, here is the remedy for that:

  • Labels terminated with a colon ':' are now recognized anywhere in first part of the line, before
    any mnemonic or directive, but after the (optional) line numbers and '|' characters:

  • a sequence of '|' characters (ASCII $7C) after the (optional) line number or at the beginning
    of a line are ignored. The sequence can be of any length, but can't contain any other characters
    nor any white space. This feature is meant to make nesting levels of .IF / .ENDIF blocks human
    readable.

Yet another added feature:

  • DCX directive added to automatically invert the MSB of the last byte of a string. This was a common
    trick used, for instance, in the Microsoft BASIC interpreter.

This feature involves adding only one (!) line of code each in the files globals.c and ops.c

You might ask why I needed these extra features. Well, a few weeks ago, Microsoft has published their
original source code for Microsoft 6502 BASIC, see here:

https://github.com/microsoft/BASIC-M6502

... but this source won't assemble with any 6502 assembler I tried. I had to edit the original source to make it fit to assemble with DASM which involved adding lines and I wanted to keep track of which lines came from the original source and which were added by me. Hence, the line number feature. It also turned out that the deep nesting levels of their conditional assembly blocks are unfathomable for humans, so I made a machine do the tedious job to add the '|' indicating nesting levels. The added DCX is needed for their peculiar way to terminate strings. Which saves one byte per string. Some strings terminate with a zero, though, which is easy to implement, so no added DC variant for this.

The tgz file with my mods is attached. An example ('test.asm') showing all the new features is included.

I would appreciate if you could put these features into DASM as soon as possible, because I can release my edited Microsoft 6502 BASIC source code only when DASM has been upgraded to be able to handle it.

I think these added features are also useful for other developers, not only for those who want to explore Microsoft's 6502 BASIC.

  • Uncle Bernie

Attachment: rename the file to UB_DASM_mods.tgz --- github refused this so I changed it to .zip

UB_DASM_mods.zip

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

Start by reviewing the attached UB_DASM_mods archive and the referenced globals.c, ops.c, and test.asm files. Check how line numbers, '|' prefixes, colon-terminated labels, and the DCX directive are represented in the example, then verify that test.asm assembles with all four features and that existing assembler behavior remains intact.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.