6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 5:39 pm

All times are UTC




Post new topic Reply to topic  [ 14 posts ] 
Author Message
PostPosted: Sat May 23, 2020 7:07 pm 
Offline
User avatar

Joined: Thu May 21, 2020 9:43 pm
Posts: 5
Location: Slovakia
Hello,

I recently build my own 6502 computer thanks to Ben eater videos and also examples and tutorials from this forum. I also wanted to get EhBasic running so I set up everything like in reference manual compile it with simulator and it worked fine with my computer. So I decided to also add my own code to build simple interface from which I can run EhBasic or my other programs. So since I was using vasm because is pretty simple work with it I wanted to compile EhBasic with vasm. There I got few errors and warnings I don't understand. since I am still begginer and don't understand macros. there are also some garbage characters with I coudlnt get rid of after rewriting line. I know it is noob question but hopefully someone will be able help me. Thank you very much.

I compile with "vasm6502 -dotdir -Fbin min_mon.asm"
source files will be in attachment
Here are errors and warning I got:

error 10 in line 1551 of "basic.asm": number or identifier expected
included from line 8 of "min_mon.asm"
> .IF [* & $FF] == $FD

warning 1007 in line 1551 of "basic.asm": garbage at end of line
included from line 8 of "min_mon.asm"
> .IF [* & $FF] == $FD

error 10 in line 1630 of "basic.asm": number or identifier expected
included from line 8 of "min_mon.asm"
> CMP #[TK_TAB-$80]*2 ; compare normalised token * 2 with TAB

warning 2002 in line 1630 of "basic.asm": trailing garbage in operand
included from line 8 of "min_mon.asm"
> CMP #[TK_TAB-$80]*2 ; compare normalised token * 2 with TAB

error 10 in line 3105 of "basic.asm": number or identifier expected
included from line 8 of "min_mon.asm"
> .IF [* & $FF] == $FD

warning 1007 in line 3105 of "basic.asm": garbage at end of line
included from line 8 of "min_mon.asm"
> .IF [* & $FF] == $FD

error 10 in line 3342 of "basic.asm": number or identifier expected
included from line 8 of "min_mon.asm"
> CPX #<[LAB_224Da+2] ; from concatenate low return address?

warning 2002 in line 3342 of "basic.asm": trailing garbage in operand
included from line 8 of "min_mon.asm"
> CPX #<[LAB_224Da+2] ; from concatenate low return address?

error 10 in line 3344 of "basic.asm": number or identifier expected
included from line 8 of "min_mon.asm"
> CMP #>[LAB_224Da+2] ; from concatenate high return address?

warning 2002 in line 3344 of "basic.asm": trailing garbage in operand
included from line 8 of "min_mon.asm"
> CMP #>[LAB_224Da+2] ; from concatenate high return address?

warning 1007 in line 168 of "min_mon.asm": garbage at end of line
> .end RES_vec


Attachments:
basic.asm [344.69 KiB]
Downloaded 89 times
min_mon.asm [4.49 KiB]
Downloaded 82 times
Top
 Profile  
Reply with quote  
PostPosted: Sat May 23, 2020 7:11 pm 
Online
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Welcome! The nature of 6502 assembly language is that most assemblers have their own small differences from all the others. If you have a need to choose a different assembler than the one the code is written for, you may have to make substantial changes - in particular, you may need to understand both dialects.

I don't recommend doing this!

My advice would be as follows: when writing your own code, choose your assembler. When assembling someone else's code, stick with the choice they made.


Top
 Profile  
Reply with quote  
PostPosted: Sat May 23, 2020 7:37 pm 
Offline
User avatar

Joined: Thu May 21, 2020 9:43 pm
Posts: 5
Location: Slovakia
Thank you for reply. :)

Okay I understand now. So if I want to add some mine code which will be separate from EhBasic I still need to use assembler from simulator? Or there is way to combine them?
because like I said I would like to add some mine programs and let EhBasic stay in memory so I can run it anytime. Since I have 32k of ROM and EhBasic use upper half of ROM.


Top
 Profile  
Reply with quote  
PostPosted: Sat May 23, 2020 7:41 pm 
Online
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
There's usually more than one way to proceed... perhaps consider how to make a binary from sources, for the two or three parts of your system, and combine the binaries before loading them.

You will need to figure out how to call from one part to the other, by putting the absolute addresses of the routines into the other part's calls.

(I'm assuming you've got some way to get Basic into ROM, and you want your extra code also to be in ROM)


Top
 Profile  
Reply with quote  
PostPosted: Sat May 23, 2020 8:56 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8509
Location: Midwestern USA
BigEd wrote:
The nature of 6502 assembly language is that most assemblers have their own small differences from all the others.

Yep! This definitely appears as a case of operand syntax differences. I agree: for now, assemble with the assembler used to develop the original source code.

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


Top
 Profile  
Reply with quote  
PostPosted: Sat May 23, 2020 9:23 pm 
Offline
User avatar

Joined: Thu May 21, 2020 9:43 pm
Posts: 5
Location: Slovakia
BigEd wrote:
(I'm assuming you've got some way to get Basic into ROM, and you want your extra code also to be in ROM)


Yes just like you said. If I would understand these macros better I could make it work I guess. I have a lot to learn. Anyway Thank you very much for help and advice.


Top
 Profile  
Reply with quote  
PostPosted: Sat May 23, 2020 9:42 pm 
Offline
User avatar

Joined: Thu May 21, 2020 9:43 pm
Posts: 5
Location: Slovakia
I also tried something with code an now I only got 2 errors after compiling.

expression must be constant
.IF (* & $FF) == $FD

What does * means in this IF statement?


Top
 Profile  
Reply with quote  
PostPosted: Sat May 23, 2020 9:45 pm 
Online
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Usually * means the address of the present instruction being assembled - or the next instruction, if the line isn't an opcode line.


Top
 Profile  
Reply with quote  
PostPosted: Sat May 23, 2020 11:17 pm 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1949
Location: Sacramento, CA, USA
Jopo12321 wrote:
I also tried something with code an now I only got 2 errors after compiling.

expression must be constant
.IF (* & $FF) == $FD

What does * means in this IF statement?

The intent of this .IF is to ensure that the return address of the following JSR doesn't end in $FF, or something to that effect. There's a 255 out of 256 chance that you can proceed without it, should it become too difficult to translate.

P.S. I'm proceeding to reverse-engineer WozBASIC, with the goal of getting it to assemble and run in the Kowalski simulator. When I have it fully functional, I'll fix the few bugs, remove the Apple ][ specific graphics and I/O verbs, then add WOZ floats. My ultimate goal is to provide a quicker and smaller alternative to EhBASIC, but I can see a lot of bumps and branches on the path ahead ...

_________________
Got a kilobyte lying fallow in your 65xx's memory map? Sprinkle some VTL02C on it and see how it grows on you!

Mike B. (about me) (learning how to github)


Top
 Profile  
Reply with quote  
PostPosted: Sun May 24, 2020 3:31 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8509
Location: Midwestern USA
barrym95838 wrote:
Jopo12321 wrote:
I also tried something with code an now I only got 2 errors after compiling.

expression must be constant
.IF (* & $FF) == $FD

What does * means in this IF statement?

The intent of this .IF is to ensure that the return address of the following JSR doesn't end in $FF, or something to that effect. There's a 255 out of 256 chance that you can proceed without it, should it become too difficult to translate.

Note that such a check is unnecessary if the target system is running a 65C02 or 65C816, as neither has the JMP (<addr>) bug.

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


Top
 Profile  
Reply with quote  
PostPosted: Sun May 24, 2020 3:41 am 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1949
Location: Sacramento, CA, USA
Err ... not so fast, BDD. The return address is incremented incompletely in software inside the subroutine at LAB_1B5B, so it doesn't matter if it's hosted on NMOS or otherwise. Four (or even two, if you want to get fancy) extra bytes of code could do the job "properly", but apparently Lee chose this route of "fixing" it during assembly instead.
Code:
LAB_1B5B
      PLA                     ; get return addr low byte
      STA   ut1_pl            ; save it
      INC   ut1_pl            ; increment it (was ret-1 pushed? yes!)
                              ; note! no check is made on the high byte! if the calling
                              ; routine assembles to a page edge then this all goes
                              ; horribly wrong !!!
      PLA                     ; get return addr high byte
      STA   ut1_ph            ; save it
      LDA   FAC1_s            ; get FAC1 sign (b7)
      PHA                     ; push sign
      ...
      ...
      JMP   (ut1_pl)          ; return, sort of

_________________
Got a kilobyte lying fallow in your 65xx's memory map? Sprinkle some VTL02C on it and see how it grows on you!

Mike B. (about me) (learning how to github)


Top
 Profile  
Reply with quote  
PostPosted: Sun May 24, 2020 7:53 am 
Offline

Joined: Sat Jul 28, 2012 11:41 am
Posts: 442
Location: Wiesbaden, Germany
barrym95838 wrote:
...but apparently Lee chose this route of "fixing" it during assembly instead.
Actually, I applied this fix. Lee left it to the comments in the code. Unfortunately vasm6502 cannot handle variables in .if statements. From the vasm manual "Oldstyle Syntax Module" section:
Quote:
6.6 Known Problems
Some known problems of this module at the moment:
- Addresses assigned to org or to the current pc symbol ’*’ (on the z80 the pc symbol is ’$’) must be constant.
- Expressions in an if directive must be constant.

_________________
6502 sources on GitHub: https://github.com/Klaus2m5


Top
 Profile  
Reply with quote  
PostPosted: Sun May 24, 2020 8:51 am 
Offline
User avatar

Joined: Thu May 21, 2020 9:43 pm
Posts: 5
Location: Slovakia
After looking for error I also found vasm can't work with constants in .IF so I commented these block an after compiling code and comparing with binaries from simulator they were same. So I guess I should be okay then right?


Top
 Profile  
Reply with quote  
PostPosted: Sun May 24, 2020 1:33 pm 
Offline

Joined: Sat Jul 28, 2012 11:41 am
Posts: 442
Location: Wiesbaden, Germany
Jopo12321 wrote:
After looking for error I also found vasm can't work with constants in .IF so I commented these block an after compiling code and comparing with binaries from simulator they were same. So I guess I should be okay then right?
As long as the simulator doesn't insert a NOP you're O.K. The chance of hitting a page crosser requiring to insert a NOP instruction in one of the 2 if-blocks is less than 1% (1/256*2).

_________________
6502 sources on GitHub: https://github.com/Klaus2m5


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC


Who is online

Users browsing this forum: GARTHWILSON and 66 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: