Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force extended addressing mode? #41

Closed
tobiasvl opened this issue Apr 14, 2020 · 8 comments
Closed

Force extended addressing mode? #41

tobiasvl opened this issue Apr 14, 2020 · 8 comments

Comments

@tobiasvl
Copy link

tobiasvl commented Apr 14, 2020

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?

@andrew-davie
Copy link
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.

@tobiasvl
Copy link
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…

@tobiasvl
Copy link
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.

@thomas374b
Copy link
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)

@tobiasvl
Copy link
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.

@thomas374b
Copy link
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.

@thrust26
Copy link
Member

Can this be closed?

@tobiasvl
Copy link
Author

Yes. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants