Skip to content

Force extended addressing mode? #41

Closed

Description

@tobiasvl

Perhaps a bad idea, but I'm using dasm to write a program for the MC6800. 6803 code is backwards compatible with 6800's documented instructions, so I thought it'd be a safe thing to do.

However, I just encountered a problem:

JSR $0040

On a 6800, this would use extended addressing, since there's no direct (zero-page) JSR there, so it would be assembled into $BD $0040. The 6803 does have a direct JSR instruction though, and dasm will obviously use it, creating code that's not compatible with 6800.

In this specific case, it's even worse. The opcode for direct JSR on 6803 is $9D, which on the 6800 was an undocumented opcode: The mythical "halt and catch fire"!

Anyway, my actual question is this: I realize dasm doesn't support 6800 and that maybe I should use something else, but is there a way to force it to use extended addressing in cases like this, without simply inputting the raw bytes?

Activity

  1. andrew-davie commented on Apr 15, 2020

    @andrew-davie
    Member

    How about creating a macro for that situation and using the macro in an opcode-like fashion?
    Something like...

        MAC JSRX ;{addr}
                .byte $BD
                .word {1}
        ENDM
    

    Then you'd just never use "JSR" but instead always "JSRX"

    Not quite answering your question about "forcing" but perhaps a better solution than inputting the raw bytes every single time.

  2. tobiasvl commented on Apr 15, 2020

    @tobiasvl
    Author

    Yeah, that's not the worst idea for my particular use case. Thanks.

    And I do realize I probably shouldn't dasm for 6800. but I've used dasm for F8 in the past and I quite like it. Maybe the solution is to add 6800 support to dasm…

  3. tobiasvl commented on Apr 19, 2020

    @tobiasvl
    Author

    The vasm assembler has the following feature:

    When an instruction supports direct and extended addressing mode the < character
    can be used to force direct mode and the > character forces extended mode. Otherwise
    the assembler selects the best mode automatically, which defaults to extended mode
    for external symbols.

    Could be something to consider.

  4. thomas374b commented on Jul 12, 2020

    @thomas374b
    Contributor

    Have you tried the postfix '.w'

      jsr.w       $40
    

    Should create 'bd 00 40' (I've tested this)

    With dasm one can force addressing mode to direct address with postfix (.b) or to extended address (.w)

  5. tobiasvl commented on Jul 12, 2020

    @tobiasvl
    Author

    Oh, interesting! No, I must have missed that in the documentation. Not sure if this kind of syntax is common and I just don't know about it. This looks perfect.

  6. thomas374b commented on Jul 13, 2020

    @thomas374b
    Contributor

    My admin-gurus at the university used to say: "You've got the sources, luke .." (especcially when docs where missing ;-)
    src/main.c around line 1030 you should find it.
    With dasm this extension works for any opcode where both addressing modes are available.

  7. added a commit that references this issue on Sep 16, 2020
  8. thrust26 commented on Apr 13, 2021

    @thrust26
    Member

    Can this be closed?

  9. tobiasvl commented on Apr 13, 2021

    @tobiasvl
    Author

    Yes. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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