asm6 issue

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
charliee1151
Posts: 22
Joined: Mon Dec 26, 2016 8:58 am

asm6 issue

Post by charliee1151 »

I believe I may have found an issue with asm6. I am using version 1.6,which is the one given on RomHacking.


Is this program still being maintained? How may I contact the programmer/author?

Thank you
Charlie
User avatar
loopy
Posts: 405
Joined: Sun Sep 19, 2004 10:52 pm
Location: UT

Re: asm6 issue

Post by loopy »

Email address should be in the readme. It's not actively maintained, though there are unofficial branches that might be.
If you have issues with it, right here is the best place to talk about it.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: asm6 issue

Post by tokumaru »

If you've really found a bug, sharing it here might be helpful to other members too, as more people will be able to avoid/circumvent the issue until it's fixed.
charliee1151
Posts: 22
Joined: Mon Dec 26, 2016 8:58 am

Re: asm6 issue

Post by charliee1151 »

Thank you. I will make up a code snippet to demonstrate my question.

Regarding the lengthy discussion in reference to homebrew (I admit I did not read it all), I've attached (I hope) a bmp file. It is my "homebrew" game, and is a blatent rip-off of a C64 game "Oils Well" (IIRC). It is not intended for profit, and I am willing to submit it, with source code, to {someplace}, if it is appropriate to do so. Does this type of programming qualify as a "port" of the original? It is not an exact duplicate of the play function, just close enough to make it playable.

Thanks
Charlie
Attachments
Screen shot of "NESOil", my port of the Commodore game "Oils Well"
Screen shot of "NESOil", my port of the Commodore game "Oils Well"
NESOil.bmp (238.93 KiB) Viewed 4997 times
charliee1151
Posts: 22
Joined: Mon Dec 26, 2016 8:58 am

Re: asm6 issue

Post by charliee1151 »

Ok, here is an example of my question:
First the code snippet, file name is "test.asm":
----------------------------------------
someIndex = $2E

.org $c000

Data1:
.db #$00, #$00, #$00, #$00, #$00
Data1Size:
.db (Data1Size - Data1) / 5

Test:
lda someIndex
;cmp #Data2Size ;Uncomment to see issue
cmp #Data1Size

Data2:
.db #$FF, #$FF, #$FF, #$FF, #$FF
Data2Size:
.db (Data2Size - Data2) / 5
-----------------------------------------------

Compiling as is, is ok:

E:\temp>asm6 -L test.asm test.nes test.lst
pass 1..
test.nes written (17 bytes).
test.lst written.

Compiling with the comment removed:

E:\temp>asm6 -L test.asm test.nes test.lst
pass 1..
pass 2..
last try..
test.nes written (20 bytes).
test.lst written.

Note the output "last try...", which would:
(1) seem to indicate an error, even though the list file "test.lst" shows correct data
(2) does not give any indication of the "error". This may be correct, as there doesn't appear to actually be any error.

Note that the difference is that the calculated Size data is, in the first instance, BEFORE the code that uses it, and in the second instance, is AFTER the code that uses it.


Thanks
Charlie
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: asm6 issue

Post by tokumaru »

You should not be using the "#" in those CMP instructions though. This symbol is for immediate values, so what this will do is compare the accumulator to the ADDRESS that label points to, not the value at that address. The address is a 16-bit value though, so this should be an invalid instruction on 6502 assembly, so the assembler should throw an error, instead of silently using only the lower byte of the address or whatever else it's doing.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: asm6 issue

Post by tokumaru »

Maybe what you want to do is this:

Code: Select all

Data1:			
	.db #$00, #$00, #$00, #$00, #$00	
Data1Size = ($ - Data1) / 5 ;this will calculate the value you want, but will not output it to the ROM

	;(...)

	CMP #Data1Size
Or, if you really want the size to be stored in the ROM with a .db statement, do exactly like you did but remove the # from the CMP instructions. Either way should work fine, regardless of whether there size is calculated before or after it's used.
charliee1151
Posts: 22
Joined: Mon Dec 26, 2016 8:58 am

Re: asm6 issue

Post by charliee1151 »

Thanks, all, for the info.

I have tried both with and without the "#", using Asm6 and running on the Nintendoulator (my real code, of course, not the sample snippet). In both cases, the Debug Disassembly shows the same code:

D11A A5 2E LDA $2E = 05
D11C CD 60 C4 CMP $C460 = 08
D11F D0 07 BNE $D128

However, removing the "#" DOES eliminate the Asm6 issue, and so I have edited my real code to match.

(Edit: So, maybe the Asm6 message actually WAS an error indicator, since my source actually was incorrect, and an update is needed to add the text of the error message?)

Charlie
User avatar
loopy
Posts: 405
Joined: Sun Sep 19, 2004 10:52 pm
Location: UT

Re: asm6 issue

Post by loopy »

charliee1151 wrote:E:\temp>asm6 -L test.asm test.nes test.lst
pass 1..
pass 2..
last try..
test.nes written (20 bytes).
test.lst written.

Note the output "last try...", which would:
(1) seem to indicate an error, even though the list file "test.lst" shows correct data
(2) does not give any indication of the "error". This may be correct, as there doesn't appear to actually be any error.
"last try.." isn't an error condition. It just means it's the final assembly pass.
User avatar
Zutano
Posts: 38
Joined: Tue Apr 04, 2017 1:22 pm
Location: Ohio, USA
Contact:

Re: asm6 issue

Post by Zutano »

charliee1151 wrote:I have tried both with and without the "#", using Asm6 and running on the Nintendoulator (my real code, of course, not the sample snippet). In both cases, the Debug Disassembly shows the same code:

D11A A5 2E LDA $2E = 05
D11C CD 60 C4 CMP $C460 = 08
D11F D0 07 BNE $D128

However, removing the "#" DOES eliminate the Asm6 issue, and so I have edited my real code to match.
ASM6 tends to assume what you may have meant to do when it sees an invalid operation.
In this case it saw you were trying to use a 16-bit label as an immediate value (using "#"), and it assumed (correctly) that you meant to

Code: Select all

CMP Absolute
instead of

Code: Select all

CMP #Immediate
This is why the disassembly is the same with and without the "#"

As for the "last try" message, that just means the assembler did an extra pass, it is not an error. The extra pass came from your ambiguous "CMP", the assembler first assumed that "Data2Size" would be an 8-bit value that would be defined later in the source. But instead it found it as a 16-bit label, and had to do an extra pass to adjust the original "CMP" opcode to reflect that.
http://zutanogames.com/ <-- my dev blog
charliee1151
Posts: 22
Joined: Mon Dec 26, 2016 8:58 am

Re: asm6 issue

Post by charliee1151 »

Excellent explanation, thanks!

Charlie
Post Reply