Fusion-6502 - The bridge between Old and New

For discussing the 65xx hardware itself or electronics projects.
User avatar
Oneironaut
Posts: 734
Joined: 25 May 2015
Location: Gillies, Ontario, Canada
Contact:

Re: Fusion-6502 - The bridge between Old and New

Post by Oneironaut »

Thanks.

I am using 6502 Macroassembler by Michal Kowalski.

It does not understand any version of >> or << though.
Actually, I can't even use division.

No doubt, I am just missing the obvious, as it surely can do this somehow.
if not, it will be a show-stopper for me, and I will have to switch to another IDE.

I must represent 24 bit decimal values.
If the user has to do math, then this is a no go for me.

Will keep looking for the answer.
Brad
User avatar
Oneironaut
Posts: 734
Joined: 25 May 2015
Location: Gillies, Ontario, Canada
Contact:

Re: Fusion-6502 - The bridge between Old and New

Post by Oneironaut »

Ok, I found a way to make it work.
It isn't the best case, but it gets me by...

Code: Select all

 LDA #<264376
 STA 606
 LDA #>264376
 STA 607
 LDA #264376/65536
 STA 608
Seems you have to use the forward slash for division.
I also don't like the fact that the first 2 values are bit selected while the last one is just divided.
Being a total neat freak, I like all things to be the same.

Oh well, on to more important parts of the project... the input system.
I am doing an experiment with reading FAT16 into the FPGA to see if it's worth it.

Later!
Brad
User avatar
barrym95838
Posts: 2056
Joined: 30 Jun 2013
Location: Sacramento, CA, USA

Re: Fusion-6502 - The bridge between Old and New

Post by barrym95838 »

sbasm uses #, /, = and \ to right-shift the immediate operand by zero, eight, 16 and 24 bits respectively. It's tidy, but decidedly non-standard. I forgot ... you are using the Kowalski assembler, right?

Mike B.

P.S. Duh ... I not only forgot your assembler, but I also neglected to look a couple of posts up. I apologize for my incompetence.
Last edited by barrym95838 on Sat Oct 29, 2016 5:19 pm, edited 1 time in total.
Klaus2m5
Posts: 442
Joined: 28 Jul 2012
Location: Wiesbaden, Germany

Re: Fusion-6502 - The bridge between Old and New

Post by Klaus2m5 »

Seems like Kowalski just doesn't like the parentheses.

LDA #264376>>16&$ff

works!

brackets work as well!

LDA #[264376>>16]&$ff

Code: Select all

; lda immediate byte of a constant
ldaib: .macro const, bytnum
       lda   #const>>8*bytnum&$ff
       .endm
	
       .org  $200
       ldaib 264376,0
       ldaib 264376,1
       ldaib 264376,2
or even better

Code: Select all

; store a multi-byte constant in RAM using A
;     parameter 1: constant
;          "    2: memory location
;          "    3: number of bytes
stcnst:  .macro const, memory, bytes
.current .= 0
         .repeat bytes         
         lda   #const>>8*.current&$ff
         sta   memory+.current
.current .= .current + 1
         .endr
         .endm
	
         .org  0
hell:    .ds   3     ;data lives in page zero
         .org  $200
         stcnst 264376,hell,3
I just love to use macros!
6502 sources on GitHub: https://github.com/Klaus2m5
User avatar
BigDumbDinosaur
Posts: 9428
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Fusion-6502 - The bridge between Old and New

Post by BigDumbDinosaur »

Oneironaut wrote:
I am using 6502 Macroassembler by Michal Kowalski.

It does not understand any version of >> or << though.
Actually, it does. See attachments.
logical_expression_examples.asm
Logical Expression Examples
(836 Bytes) Downloaded 95 times
asm_directives.asm
Kowalski Assembler Directives
(1.62 KiB) Downloaded 101 times
x86?  We ain't got no x86.  We don't NEED no stinking x86!
User avatar
Oneironaut
Posts: 734
Joined: 25 May 2015
Location: Gillies, Ontario, Canada
Contact:

Re: Fusion-6502 - The bridge between Old and New

Post by Oneironaut »

Thanks, I retyped the >> and it worked. Must have had a bad character in there or something.

This looks better to me now.
Still wish I could use the same sequence for all three bytes though.
Something like in Verilog would be nice... LDA #647381[15:7]

Code: Select all

; SET SAMPLE START
 LDA #<30720
 STA 603
 LDA #>30720
 STA 604
 LDA #30720>>16
 STA 605

; SET SAMPLE LENGTH
 LDA #<264376
 STA 606
 LDA #>264376
 STA 607
 LDA #264376>>16
 STA 608

; PLAY SAMPLE TO VOICE 1
 LDA #6
 STA 609
No doubt, a macro could do this, but I will never use a macro. Just not my thing.
Anyhow, thanks... I am happy with the ability to use >> in code.

Working on a simple Game Demo so I can post a video of where Fusion-6502 is currently at.

Cheers!
Brad
User avatar
BigDumbDinosaur
Posts: 9428
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Fusion-6502 - The bridge between Old and New

Post by BigDumbDinosaur »

Oneironaut wrote:
Still wish I could use the same sequence for all three bytes though.
Something like in Verilog would be nice... LDA #647381[15:7]
Unfortunately, the world of do-it-yourself assemblers is a chaotic one. For example, in Mr. Kowalski's assembler, @ is the radix for binary, not % as is defined in the MOS Technology and WDC assembler syntax standards. He uses % to refer to macro parameters, probably because MS-DOS, and by extension, Windows, uses % to refer to the MS-DOS equivalent of UNIX environment variables, which are prefixed with $ when referenced.

Further muddying the waters, the MOS/WDC syntax uses @ as the radix for octal notation, as does the Commodore 128 machine language monitor and Supermon 816. When I first started using the Kowalski assembler about a dozen years ago I kept tripping over trying to use % as a radix for binary and only through trial and error discovered what the correct radix symbol was.

Something else in the Kowalski assembler that might give you some grief is statement parsing. The parser expects that labels, symbol definitions and macro declarations always start in column one. If you place a mnemonic or a pseudo-op in column one the assembler will apparently try to treat it as a label or symbol and flag it as an error. Similarly, if you start a label or symbol in any column other than column one the assembler will apparently treat it as a mnemonic, macro invocation or pseudo-op and it will likewise be flagged as an error. Also, in a few cases lack of whitespace around operators may be an issue. If you get a diagnostic on a statement containing both an operator and a pseudo-op, such as I .set I+1, and see no apparent error, try surrounding each operator (+ in this example) with a space. Not that .set is a pseudo-op that can also be expressed as .=, with no space between . and =.

The assembler is actually quite powerful, but has its little quirks. The last version that Mike Kowalski released was 1.2.12, which may be downloaded here. A number of bugs related to macro processing were addressed in this final version.
x86?  We ain't got no x86.  We don't NEED no stinking x86!
User avatar
GARTHWILSON
Forum Moderator
Posts: 8775
Joined: 30 Aug 2002
Location: Southern California
Contact:

Re: Fusion-6502 - The bridge between Old and New

Post by GARTHWILSON »

Oneironaut wrote:
No doubt, a macro could do this, but I will never use a macro. Just not my thing.
The six-line examples above could each be replaced with a single-line macro invocation and result in the exact same machine code. It could look something like:

Code: Select all

        PUT_LONG   264376, IN, 606
You're obviously very productive. Macros can further increase your development speed, make the code more clear and maintainable, cause you fewer bugs to fix, etc..
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
User avatar
Oneironaut
Posts: 734
Joined: 25 May 2015
Location: Gillies, Ontario, Canada
Contact:

Re: Fusion-6502 - The bridge between Old and New

Post by Oneironaut »

Thanks for the input!

In the end, i have plans to roll my own assembler and add it to the ever growing PC program I have made that converts bitmaps and waves to data. it also manages 6502 code and creates the final structure that will end up on whatever media I end up using as a cartridge. I might as well toss in an assembler as well, and that will make it "one stop shopping"!

Thanks Garth, I don't have much time, but I try to make it count!

For some reason, I cannot enjoy programming with high level languages, don't like over commented code, prefer a single tab at most, and do not like macros.
I tried jumping into the "C" thing a while back and it almost made me quit... that's how much I disliked it.
For some reason macros make me feel like I am one step closer to C.
When I code, I keep a running cycle count, and see the ones and zeros racing through the machine!
Anything that moves me one step further from the bare metal feels like poison.
Even the IDE I use must be pure and simple. For me, the ultimate toolchain would be notepad with a compile button!
I also refuse to ever use a debugger for any platform. If I can't figure out errors by looking at code, then I need to improve.
And HEX... also against my rules. I will use decimal until one of two things occurs; I grow 16 fingers, or I get a CPU brain transplant!

Strange, I know!
But I do get the job done, and have a great time doing it!

I was hoping to put a video together today, but it's warm enough out to split wood.
Once it snows here, I will have a lot more time.

Thanks for the comments, information, and ideas!

Brad
Tor
Posts: 597
Joined: 10 Apr 2011
Location: Norway/Japan

Re: Fusion-6502 - The bridge between Old and New

Post by Tor »

Good reasons all.. and I understand it, except the one about hex. With hexadecimal you see the bytes and bits directly, with decimal you're removed from that.. so I would have thought decimal was the extra layer to avoid.

-Tor
User avatar
Oneironaut
Posts: 734
Joined: 25 May 2015
Location: Gillies, Ontario, Canada
Contact:

Re: Fusion-6502 - The bridge between Old and New

Post by Oneironaut »

I guess it all depends on what we get used to.
When I am placing some Sprite graphics into my 1024K address space, it just makes more sense to me to say...

The explosion sequence resides at location 451,236. I now have about half of my 1,048,576 bytes used.
To say the explosion sequence resides at location 6E2A4 means zip to me.

I do sometimes work in binary, especially when dealing with IO ports, but HEX has had no use for me.

But l did admit to being over-the-top eccentric!
Hell, I have not owned a phone or TV since the early 90's, and am proud to say I have never or never will do a "text"!
Perhaps that's why I like this little corner of the web so much... it defies change and promotes the dark art of assembly.

As I do more coding on Fusion-6502, I realize that an ARM bloated with cut-n-paste C code would not do much better than the 6502.
My GPU is plenty fast, but it is still the final stop, so optimized 6502 assembly pumps it just as fast as bad C code on a 32 bit platform.
Actually, if 6502 was single cycle internally, I would prefer it over AVR, which is my current favorite assembly platform.

Ok, back to my wood cutting now... I must go work to defy the grid and city living for the rest of the day out on my homestead!

Cheers!
Brad
Tor wrote:
Good reasons all.. and I understand it, except the one about hex. With hexadecimal you see the bytes and bits directly, with decimal you're removed from that.. so I would have thought decimal was the extra layer to avoid.

-Tor
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Fusion-6502 - The bridge between Old and New

Post by BigEd »

Oneironaut wrote:
Tor wrote:
With hexadecimal you see the bytes and bits directly, with decimal you're removed from that.. so I would have thought decimal was the extra layer to avoid.
When I am placing some Sprite graphics into my 1024K address space, it just makes more sense to me to say the explosion sequence resides at location 451,236. I now have about half of my 1,048,576 bytes used.
To say the explosion sequence resides at location 6E2A4 means zip to me.
You know you've converted your brain to handle hex when you sometimes think of 8 as half of 10.

(
I grew up with mixed-base arithmetic:
pounds, shillings and pence.
10/- is half of £1, and 6d is half of 1/-.

But I bet many others did too:
6" is half of 1", and 8oz is half of 1lb.
)
Post Reply