6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 3:07 am

All times are UTC




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: WDC Tools - bugs!
PostPosted: Thu Sep 15, 2022 10:17 pm 
Offline
User avatar

Joined: Tue Mar 05, 2013 4:31 am
Posts: 1385
So, some time ago, I discovered some odd problems with WDC Tools Assembler. This was back when I was working on the SIM module for DOS/65. Using the following code to load some pointers into the bottom of the stack page:

First Bug:
Code:
;
                ldy     #6              ;set index to 6
simset_lp       lda     sim_inttbl-1,y  ;get SIM table data
                sta     $0100-1,y       ;store into page $01 PEM area
                dey                     ;decrement index
                bne     simset_lp       ;loop until done


The above works fine, but, WDC Tools has a bug using the X register (in the above code) when the operand is: $0100-1 (it should be $00FF, but it becomes $FF), so no workie!

Second Bug:
Again, writing the SIM module.
Code:
sim_dcbtbl      .DW     dcb_a
                .DW     dcb_b
                .DW     dcb_c
                .DW     dcb_d
                .DW     dcb_e
                .DW     dcb_f
                .DW     dcb_g
                .DW     dcb_h

Initial code didn't support all 8 drives. Initial code used: .DW dcba, etc. for creating the dcb, table. When I increased the drives to h, the label "dcbh" caused an assembly error. Adding the "_" to make it "dcb_h" (fixed it.


Now I found Bug number 3, while working to port some of the DOS/65 utilities over.
In the Assembler utility, they use two page zero locations for an indirect pointer to routines. At one section in the code, they show:
Code:
        JMP     (TBLPTR)        ;go to entry point

The assembler chokes on this with an invalid addressing mode, as TBLPTR is defined in Page Zero.

My workaround for this is:

.DB $6C
.DW TBLPTR

This generates the code as 3 bytes, which works.

Ah... tooling... they all have their little gotchas. I'll be sending a note off to Bill Mensch on this, see what he thinks... who knows, would be nice to get an updated assembler!

_________________
Regards, KM
https://github.com/floobydust


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC Tools - bugs!
PostPosted: Thu Sep 15, 2022 10:57 pm 
Offline

Joined: Thu Mar 12, 2020 10:04 pm
Posts: 704
Location: North Tejas
floobydust wrote:
Code:
                sta     $0100-1,y       ;store into page $01 PEM area


I do not think that is a bug.

If you write
Code:
                sta     $0100-1,x       ;store into page $01 PEM area

the assembler is well within its right to interpret that as
Code:
                sta     $FF,x       ;store into page $01 PEM area


Maybe you should have written that as
Code:
                sta     >$FF,x       ;store into page $01 PEM area


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC Tools - bugs!
PostPosted: Thu Sep 15, 2022 11:02 pm 
Offline

Joined: Thu Mar 12, 2020 10:04 pm
Posts: 704
Location: North Tejas
floobydust wrote:
Initial code didn't support all 8 drives. Initial code used: .DW dcba, etc. for creating the dcb, table. When I increased the drives to h, the label "dcbh" caused an assembly error. Adding the "_" to make it "dcb_h" (fixed it.

Does the assembler try to be "nice" and allow you to write hexadecimal constants "Intel" style?

If so, it should not trigger on "DCBh" because "Intel" style hexadecimal numbers must begin with a digit, that is, "0DCBh" with a leading zero.


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC Tools - bugs!
PostPosted: Thu Sep 15, 2022 11:11 pm 
Offline
User avatar

Joined: Tue Mar 05, 2013 4:31 am
Posts: 1385
BillG wrote:
floobydust wrote:
Code:
                sta     $0100-1,y       ;store into page $01 PEM area


I do not think that is a bug.

If you write
Code:
                sta     $0100-1,x       ;store into page $01 PEM area

the assembler is well within its right to interpret that as
Code:
                sta     $FF,x       ;store into page $01 PEM area


Maybe you should have written that as
Code:
                sta     >$FF,x       ;store into page $01 PEM area


Perhaps... but the assembler interprets it differently when using the Y index register. So at best, it's inconsistent, which I would lean towards it being a bug.

I would also note that the original code (I think it was written and assembled with TASM) was written that way using the X Index register, which apparently worked.

_________________
Regards, KM
https://github.com/floobydust


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC Tools - bugs!
PostPosted: Thu Sep 15, 2022 11:14 pm 
Offline

Joined: Thu Mar 12, 2020 10:04 pm
Posts: 704
Location: North Tejas
floobydust wrote:
Perhaps... but the assembler interprets it differently when using the Y index register. So at best, it's inconsistent, which I would lean towards it being a bug.

I would also note that the original code (I think it was written and assembled with TASM) was written that way using the X Index register, which apparently worked.

There is no zero page,Y addressing mode...


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC Tools - bugs!
PostPosted: Thu Sep 15, 2022 11:19 pm 
Offline
User avatar

Joined: Tue Mar 05, 2013 4:31 am
Posts: 1385
BillG wrote:
floobydust wrote:
Initial code didn't support all 8 drives. Initial code used: .DW dcba, etc. for creating the dcb, table. When I increased the drives to h, the label "dcbh" caused an assembly error. Adding the "_" to make it "dcb_h" (fixed it.

Does the assembler try to be "nice" and allow you to write hexadecimal constants "Intel" style?

If so, it should not trigger on "DCBh" because "Intel" style hexadecimal numbers must begin with a digit, that is, "0DCBh" with a leading zero.


Actually, this one is very strange... if you don't use the "_" in any of them, the last two work, but the first six error out as "undefined symbol". As you add the "_" the list changes in which ones are problematic.
I just added the "_" to all of them (for consistency) and the problem went away.

_________________
Regards, KM
https://github.com/floobydust


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC Tools - bugs!
PostPosted: Thu Sep 15, 2022 11:24 pm 
Offline

Joined: Thu Mar 12, 2020 10:04 pm
Posts: 704
Location: North Tejas
floobydust wrote:
Actually, this one is very strange... if you don't use the "_" in any of them, the last two work, but the first six error out as "undefined symbol".

Well, you did not originally say that.

This smells even more like failed attempted Intelism.

$DCBA, $DCBB, $DCBC, $DCBD, $DCBE and $DCBF are all valid hexadecimal numbers!


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC Tools - bugs!
PostPosted: Thu Sep 15, 2022 11:25 pm 
Offline
User avatar

Joined: Tue Mar 05, 2013 4:31 am
Posts: 1385
BillG wrote:
floobydust wrote:
Perhaps... but the assembler interprets it differently when using the Y index register. So at best, it's inconsistent, which I would lean towards it being a bug.

I would also note that the original code (I think it was written and assembled with TASM) was written that way using the X Index register, which apparently worked.

There is no zero page,Y addressing mode...


That's very true... but the source code is written with a 16-bit operand. When you subtract the 1 from it, the assembler changes it to an 8-bit operand. That's why I'm leaning towards it being a bug. Then again, could be works as designed.

_________________
Regards, KM
https://github.com/floobydust


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC Tools - bugs!
PostPosted: Thu Sep 15, 2022 11:35 pm 
Offline
User avatar

Joined: Tue Mar 05, 2013 4:31 am
Posts: 1385
BillG wrote:
floobydust wrote:
Actually, this one is very strange... if you don't use the "_" in any of them, the last two work, but the first six error out as "undefined symbol".

Well, you did not originally say that.

This smells even more like failed attempted Intelism.

$DCBA, $DCBB, $DCBC, $DCBD, $DCBE and $DCBF are all valid hexadecimal numbers!


Yea, it was a while ago.... I just grabbed the source and started changing it around, but forgot to change the actual labels, hence the strange results :shock:

I went back and removed the "_" from all of the labels and the error only occurs on the dcbh one. The actual error is: "Hex and Symbol are identical!" So yes, I think you're right that the assembler is interpreting the "h" at the end as a hex value. When used at the start of the line as a label, it doesn't cause a problem, until you try and use it somewhere else in the code.

Code:
;disk control blocks
; Updated to support 8 drives by default - KM
;drive a (CF 8MB)
dcb_a           .DW     4095            ;max block number
                .DW     1024            ;records per track
                .DW     0               ;number system tracks
                .DB     1               ;block size = 2048
                .DW     1023            ;max directory
                .DW     almpa           ;address of allocation map
                .DB     128             ;do not do checksums
                .DW     0               ;phony address
;drive b (CF 8MB)
dcb_b           .DW     4095            ;max block number
                .DW     1024            ;records per track
                .DW     0               ;number system tracks
                .DB     1               ;block size = 2048
                .DW     1023            ;max directory
                .DW     almpb           ;address of allocation map
                .DB     128             ;do not do checksums
                .DW     0               ;phony address
;drive c (CF 8MB)
dcb_c           .DW     4095            ;max block number
                .DW     1024            ;records per track
                .DW     0               ;number system tracks
                .DB     1               ;block size = 2048
                .DW     1023            ;max directory
                .DW     almpc           ;address of allocation map
                .DB     128             ;do not do checksums
                .DW     0               ;phony address
;drive d (CF 8MB)
dcb_d           .DW     4095            ;max block number
                .DW     1024            ;records per track
                .DW     0               ;number system tracks
                .DB     1               ;block size = 2048
                .DW     1023            ;max directory
                .DW     almpd           ;address of allocation map
                .DB     128             ;do not do checksums
                .DW     0               ;phony address
;drive e (CF 8MB)
dcb_e           .DW     4095            ;max block number
                .DW     1024            ;records per track
                .DW     0               ;number system tracks
                .DB     1               ;block size = 2048
                .DW     1023            ;max directory
                .DW     almpe           ;address of allocation map
                .DB     128             ;do not do checksums
                .DW     0               ;phony address
;drive f (CF 8MB)
dcb_f           .DW     4095            ;max block number
                .DW     1024            ;records per track
                .DW     0               ;number system tracks
                .DB     1               ;block size = 2048
                .DW     1023            ;max directory
                .DW     almpf           ;address of allocation map
                .DB     128             ;do not do checksums
                .DW     0               ;phony address
;drive g (CF 8MB)
dcb_g           .DW     4095            ;max block number
                .DW     1024            ;records per track
                .DW     0               ;number system tracks
                .DB     1               ;block size = 2048
                .DW     1023            ;max directory
                .DW     almpg           ;address of allocation map
                .DB     128             ;do not do checksums
                .DW     0               ;phony address
;drive h (CF 8MB)
dcb_h           .DW     4095            ;max block number
                .DW     1024            ;records per track
                .DW     0               ;number system tracks
                .DB     1               ;block size = 2048
                .DW     1023            ;max directory
                .DW     almph           ;address of allocation map
                .DB     128             ;do not do checksums
                .DW     0               ;phony address

_________________
Regards, KM
https://github.com/floobydust


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC Tools - bugs!
PostPosted: Thu Sep 15, 2022 11:37 pm 
Offline

Joined: Thu Mar 12, 2020 10:04 pm
Posts: 704
Location: North Tejas
floobydust wrote:
That's very true... but the source code is written with a 16-bit operand. When you subtract the 1 from it, the assembler changes it to an 8-bit operand. That's why I'm leaning towards it being a bug. Then again, could be works as designed.

If you write
Code:
    lda     #$100-1

would you expect it to give you an error or
Code:
    lda     #$FF
?


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC Tools - bugs!
PostPosted: Fri Sep 16, 2022 12:05 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8507
Location: Midwestern USA
Some years ago, I worked with the WDC package for a while. While the C compiler was okay, the assembler was annoying when writing 65C816 code. I haven’t touched it since 2015. As Bill suggests, it is likely whomever wrote the assembler thought he/she would be doing someone a favor and mixed in some Intel cruft.

BTW, STA $100-1,X would evaluate to STA $FF,X in just about any assembler. The Kowalski assembler has a way to force an address to be assembled as 16 bits, even though the address evaluates to an eight-bit value. If I write STA \2$100-1,Y, the Kowalski assembler will assemble it as STA $00FF,Y, which is legit.

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


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC Tools - bugs!
PostPosted: Fri Sep 16, 2022 12:58 am 
Offline
User avatar

Joined: Tue Mar 05, 2013 4:31 am
Posts: 1385
BillG wrote:
floobydust wrote:
That's very true... but the source code is written with a 16-bit operand. When you subtract the 1 from it, the assembler changes it to an 8-bit operand. That's why I'm leaning towards it being a bug. Then again, could be works as designed.

If you write
Code:
    lda     #$100-1

would you expect it to give you an error or
Code:
    lda     #$FF
?


That's using immediate mode, which is always going to be an 8-bit value.

Then again if you try:
Code:
 LDA #256

you get code of A9 00 (LDA #0). So it wraps around.

_________________
Regards, KM
https://github.com/floobydust


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC Tools - bugs!
PostPosted: Fri Sep 16, 2022 1:19 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8544
Location: Southern California
BillG wrote:
There is no zero page,Y addressing mode...

There is for LDX (op code $B6) and STX (op code $96), but nothing else.

_________________
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  
 Post subject: Re: WDC Tools - bugs!
PostPosted: Fri Sep 16, 2022 7:46 am 
Offline

Joined: Thu Mar 12, 2020 10:04 pm
Posts: 704
Location: North Tejas
GARTHWILSON wrote:
BillG wrote:
There is no zero page,Y addressing mode...

There is for LDX (op code $B6) and STX (op code $96), but nothing else.

True, but he was talking about STA, not STX.


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC Tools - bugs!
PostPosted: Fri Sep 16, 2022 7:53 am 
Offline

Joined: Thu Mar 12, 2020 10:04 pm
Posts: 704
Location: North Tejas
floobydust wrote:
BillG wrote:
Then again if you try:
Code:
 LDA #256

you get code of A9 00 (LDA #0). So it wraps around.

An argument can be made that should be flagged as an error.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 26 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: