6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Nov 24, 2024 1:36 am

All times are UTC




Post new topic Reply to topic  [ 57 posts ]  Go to page Previous  1, 2, 3, 4
Author Message
PostPosted: Sat Oct 29, 2016 2:20 pm 
Offline
User avatar

Joined: Mon May 25, 2015 2:25 pm
Posts: 693
Location: Gillies, Ontario, Canada
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


Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 29, 2016 2:39 pm 
Offline
User avatar

Joined: Mon May 25, 2015 2:25 pm
Posts: 693
Location: Gillies, Ontario, Canada
Ok, I found a way to make it work.
It isn't the best case, but it gets me by...

Code:
 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


Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 29, 2016 3:25 pm 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1949
Location: Sacramento, CA, USA
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.

Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 29, 2016 4:15 pm 
Offline

Joined: Sat Jul 28, 2012 11:41 am
Posts: 442
Location: Wiesbaden, Germany
Seems like Kowalski just doesn't like the parentheses.

LDA #264376>>16&$ff

works!

brackets work as well!

LDA #[264376>>16]&$ff

Code:
; 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:
; 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


Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 29, 2016 7:02 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8514
Location: Midwestern USA
Oneironaut wrote:
I am using 6502 Macroassembler by Michal Kowalski.

It does not understand any version of >> or << though.

Actually, it does. See attachments.

Attachment:
File comment: Logical Expression Examples
logical_expression_examples.asm [836 Bytes]
Downloaded 85 times
Attachment:
File comment: Kowalski Assembler Directives
asm_directives.asm [1.62 KiB]
Downloaded 93 times

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 29, 2016 9:41 pm 
Offline
User avatar

Joined: Mon May 25, 2015 2:25 pm
Posts: 693
Location: Gillies, Ontario, Canada
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:
; 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


Top
 Profile  
Reply with quote  
PostPosted: Sun Oct 30, 2016 4:46 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8514
Location: Midwestern USA
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!


Top
 Profile  
Reply with quote  
PostPosted: Sun Oct 30, 2016 5:08 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
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:
        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?


Top
 Profile  
Reply with quote  
PostPosted: Sun Oct 30, 2016 2:03 pm 
Offline
User avatar

Joined: Mon May 25, 2015 2:25 pm
Posts: 693
Location: Gillies, Ontario, Canada
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


Top
 Profile  
Reply with quote  
PostPosted: Sun Oct 30, 2016 2:27 pm 
Offline

Joined: Sun Apr 10, 2011 8:29 am
Posts: 597
Location: Norway/Japan
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


Top
 Profile  
Reply with quote  
PostPosted: Sun Oct 30, 2016 2:52 pm 
Offline
User avatar

Joined: Mon May 25, 2015 2:25 pm
Posts: 693
Location: Gillies, Ontario, Canada
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


Top
 Profile  
Reply with quote  
PostPosted: Sun Oct 30, 2016 4:10 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
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.
)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 57 posts ]  Go to page Previous  1, 2, 3, 4

All times are UTC


Who is online

Users browsing this forum: No registered users and 44 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: