6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu Mar 28, 2024 4:27 pm

All times are UTC




Post new topic Reply to topic  [ 13 posts ] 
Author Message
PostPosted: Mon Oct 06, 2014 9:47 pm 
Offline

Joined: Mon Oct 06, 2014 9:08 pm
Posts: 4
So, as you can see, I'm quite new to both these forums and working with 6502 emulators. Here's my problem:
Being from a primarily Java/C background, I was looking around for a good emulator to start with, and found Py65. After downloading/installing it, I started looking for a Forth interpreter designed for 6502-based processors. The first thing I found was the source code for fig-6502. Interested, I tried to assemble it with Ophis. That operation finished with 2043 errors. On almost each line of code, it gave 3 errors: "Expected: "EOL", ","", "Expected: "OPCODE"", and "Expected: expression. Wondering if it was a problem with the assembler, I tried using Acme. After using that, though, it gives errors on lines 66 ("Program counter is unset"), 73-80, and 83. The error was a warning saying "Implicit label definition not in leftmost column." and a syntax error.

After this, I decided to try something else. After browsing these forums for a bit, I found Tali Forth. I downloaded it and attempted to use the preassembled version in Py65. The program boots up correctly, but does not produce any output after entering anything. I got the same result after assembling it myself with Ophis (assembling with Acme produced more syntax errors).

Wondering if it could be a problem with the emulator, I tested it with the prepackaged ehbasic.bin (Enhanced Basic). That also booted fine, but also did not produce any output. If I typed an illegal statement (without a line number at the beginning) it would produce a syntax error, but otherwise would not produce anything.

Could someone please tell me what I may be doing wrong?

P.S. I know that Py65 is technically a simulator as opposed to an emulator.

Edit: To clarify, here are my questions:
1. Where is the problem(s) and what is causing it?
2. How can I fix this?
3. Are there any alternative methods that would yield a better result?


Top
 Profile  
Reply with quote  
PostPosted: Mon Oct 13, 2014 8:43 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10760
Location: England
Hello 0x277F, and welcome. I have a working installation of py65, on ubuntu linux. Namely, version 0.15 of py65, probably installed using
Code:
pip install py65


What OS are you running, and how did you install py65?

As you report that you don't get any output from ehbasic, that seems like a good test. I can load and run ehbasic like so:
Code:
$ py65mon

Py65 Monitor

       PC  AC XR YR SP NV-BDIZC
6502: 0000 00 00 00 ff 00110000
.load examples/ehbasic.bin
Wrote +65536 bytes from $0000 to $ffff

       PC  AC XR YR SP NV-BDIZC
6502: 0000 00 00 00 ff 00110000
.goto ff80

6502 EhBASIC [C]old/[W]arm ?

Memory size ? 16000

15231 Bytes free

Enhanced BASIC 2.22

Ready
PRINT 22/7
 3.14286

An alternative invocation is
Code:
$ py65mon -r examples/ehbasic.bin
Wrote +65536 bytes from $0000 to $ffff

       PC  AC XR YR SP NV-BDIZC
6502: 0000 00 00 00 ff 00110000

6502 EhBASIC [C]old/[W]arm ?


(What I have found, is that the pip-installed version of py65 is interfering with the working of an unpacked version from github.)

Cheers
Ed


Top
 Profile  
Reply with quote  
PostPosted: Mon Oct 13, 2014 3:58 pm 
Offline

Joined: Mon Oct 06, 2014 9:08 pm
Posts: 4
I'm running fedora linux, and I installed py65 with pip as shown. So, upon re-installing py65, I was able to get ehbasic to work. However, I am still unable to assemble my forth interpreter. Upon assembling FIG6502.ASM, here was the output:
Code:
$ acme FIG6502.ASM
Error - File FIG6502.ASM, line 66 (Zone <untitled>): Program counter is unset.
Warning - File FIG6502.ASM, line 66 (Zone <untitled>): Offset assembly still active at end of segment. Switched it off.
Warning - File FIG6502.ASM, line 73 (Zone <untitled>): Implicit label definition not in leftmost column.
Error - File FIG6502.ASM, line 73 (Zone <untitled>): Syntax error.
Warning - File FIG6502.ASM, line 74 (Zone <untitled>): Implicit label definition not in leftmost column.
Error - File FIG6502.ASM, line 74 (Zone <untitled>): Syntax error.
Warning - File FIG6502.ASM, line 75 (Zone <untitled>): Implicit label definition not in leftmost column.
Error - File FIG6502.ASM, line 75 (Zone <untitled>): Syntax error.
Warning - File FIG6502.ASM, line 76 (Zone <untitled>): Implicit label definition not in leftmost column.
Error - File FIG6502.ASM, line 76 (Zone <untitled>): Syntax error.
Warning - File FIG6502.ASM, line 77 (Zone <untitled>): Implicit label definition not in leftmost column.
Error - File FIG6502.ASM, line 77 (Zone <untitled>): Syntax error.
Warning - File FIG6502.ASM, line 78 (Zone <untitled>): Implicit label definition not in leftmost column.
Error - File FIG6502.ASM, line 78 (Zone <untitled>): Syntax error.
Warning - File FIG6502.ASM, line 79 (Zone <untitled>): Implicit label definition not in leftmost column.
Error - File FIG6502.ASM, line 79 (Zone <untitled>): Syntax error.
Warning - File FIG6502.ASM, line 80 (Zone <untitled>): Implicit label definition not in leftmost column.
Error - File FIG6502.ASM, line 80 (Zone <untitled>): Syntax error.
Warning - File FIG6502.ASM, line 83 (Zone <untitled>): Implicit label definition not in leftmost column.
Error - File FIG6502.ASM, line 83 (Zone <untitled>): Syntax error.

And, I'm still unable to get Tali Forth to work either. Any thoughts on that?


Top
 Profile  
Reply with quote  
PostPosted: Mon Oct 13, 2014 4:36 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10760
Location: England
Mostly, 6502 code is written with some conventions and assumptions which means the choice of assembler can be important. (There is a "standard" but that doesn't help you when using someone else's code.)

For Tali Forth, do you at least get the announcement at startup?

Code:
.goto ddd1

Booting Kernel for the Überquirrel Mark Zero


It looks like the I/O convention changed at some point, so you might need to patch:
Code:
.assemble de67
$de67  ad 04 f0  LDA $f004     
$de6a           


Having said which, I don't seem to be able to get Tali Forth to accept input.

Ed


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 14, 2014 3:00 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10760
Location: England
Update: tried again using the pip version of py65 on ubuntu, and it works as expected:

Code:
: double dup + ;  ok
6 double . 12  ok


So, yesterday's unsuccessful effort on OS X was probably not relevant.


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 14, 2014 4:49 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10760
Location: England
I got hold of acme and made a variant of figforth which assembles correctly - the conversion is a bit tedious but consists of
- changing .BYTE to !text and single-quoted strings to double-quoted strings (and handling the case of '(."' )
- changing .WORD to !word
- removing A from ASL A and ROL A
- adding a missing semicolon comment character at L54
- commenting out the presumably extraneous +2 on line 298
- replacing the last line with TOP=*
- fixing up two actions on *

There's one remaining discrepancy compared to the version produced by mas65, but I think that's because mas65 didn't handle the > operator on
line 2671.

See attached. Note that I haven't tested the result: it looks like this figforth source assumes some monitor routines at
Code:
;         Monitor calls for terminal support
;
OUTCH     =$D2C1         ; output one ASCII char. to term.
INCH      =$D1DC         ; input one ASCII char. to term.
TCR       =$D0F1         ; terminal return and line feed.
and
Code:
;    Monitor routines needed to trace.
;
XBLANK    =$D0AF         ; print one blank
CRLF      =$D0D2         ; print a carriage return and line feed.
HEX2      =$D2CE         ; print accum as two hex numbers
LETTER    =$D2C1         ; print accum as one ASCII character
ONEKEY    =$D1DC         ; wait for keystroke
so these would need to be patched out, or supplied.


Attachments:
FIG6502.acme.ASM [97.5 KiB]
Downloaded 91 times
Top
 Profile  
Reply with quote  
PostPosted: Wed Oct 15, 2014 8:45 pm 
Offline

Joined: Mon Oct 06, 2014 9:08 pm
Posts: 4
Thanks so much for your help! By the way, should figforth run with py65mon -r, or do I need to do something else?


Top
 Profile  
Reply with quote  
PostPosted: Wed Oct 15, 2014 8:55 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10760
Location: England
I think you'll need something other than -r, because -r loads an image to the top of memory. Figforth (as written) loads to 0200. Unfortunately it looks like -l loads an image at 0, so that's only useful if you can pre-pad your image to load to the bottom of memory. In any case you should be able to load the program interactively:
load filename.bin 0200
goto 0200

Hope this helps
Ed


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 16, 2014 5:37 pm 
Offline

Joined: Mon Oct 06, 2014 9:08 pm
Posts: 4
Oddly, that doesn't work.
Code:
       PC  AC XR YR SP NV-BDIZC
6502: 0000 00 00 00 ff 00110000
.load figforth.bin 0200
Wrote +6260 bytes from $0200 to $1a73

       PC  AC XR YR SP NV-BDIZC
6502: 0000 00 00 00 ff 00110000
.goto 0200

       PC  AC XR YR SP NV-BDIZC
6502: d0d2 e8 00 00 fb 10110000
.



Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 16, 2014 6:26 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10760
Location: England
Not really odd - we still need to provide the I/O routines and remove the tracing behaviour...

load forth65/FIG6502.acme.bin 0200

assemble d1dc
LDA $f004
BEQ $d1dc
RTS

assemble d2c1
STA $f001
RTS

assemble d0f1
LDA #$0d
STA $f001
LDA #$0a
STA $f001
RTS

assemble 07dc
NOP
NOP
NOP

assemble 024f
NOP
NOP
NOP

goto 0200

fig-FORTH 1.0
22000 7 / OK
. 3142 OK
: double dup + ; OK
12 double . 24 OK


Top
 Profile  
Reply with quote  
PostPosted: Wed Oct 22, 2014 9:03 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10760
Location: England
Here's a loadable dump of the whole memory, patched up and with a reset vector of 0200.

Code:
$ py65mon -r FIG65-0200.mem

Wrote +65536 bytes from $0000 to $ffff

       PC  AC XR YR SP NV-BDIZC
6502: 0000 00 00 00 ff 00110000

fig-FORTH  1.0


Attachments:
File comment: FIG65 tweaked source and memory image
FIG65-py65.zip [22.17 KiB]
Downloaded 68 times
Top
 Profile  
Reply with quote  
PostPosted: Sun Nov 02, 2014 8:01 pm 
Offline

Joined: Mon Jan 07, 2013 2:42 pm
Posts: 576
Location: Just outside Berlin, Germany
Hi 0x277F, sorry I'm late to the party -- I'm the author of Tali Forth and have just moved my main system from OS X to Xubuntu, so that might help. Let me go through the tool chain I use here, maybe we can find the problem.

This is Linux core 3.13.0-39-generic #66-Ubuntu (Xubuntu 14.04 LTS) and Python 2.7.6. For Ophis:

Code:
git clone https://github.com/michaelcmartin/Ophis
cd src
sudo python setup.py install
cd <TALIS DIR>
ophis --65c02 Tali-Main-A001.asm

This will produce a file named ophis.bin. NOTE: I don't remember what I uploaded, but you might want to make sure that the addresses for py65 are correct in Tali-Kernel.asm; the need to point to stuff like $F001. Anyway, for py65:

Code:
sudo apt-get install python-pip
sudo pip install -U py65
py65mon --mpu 65C02 -r ophis.bin

And this gives me:

Code:
Booting Kernel for the Überquirrel Mark Zero
Scot W. Stevenson <scot.stevenson@gmail.com>
Kernel Version Alpha 002 (25. Feb 2014)

Tali Forth for the 65c02
Version ALPHA 003 (15. May 2014)
Tali Forth comes with absolutely no warranty
Type 'bye' to exit


And then it crashes, because I'm in the middle of rewriting the +LOOP code. Ahem. The version I upload shouldn't do that, and WORDS should show you which Forth words are available.

I'm in the process of learning Git so stuff like this doesn't happen anymore, and once I know what I'm doing, I'll upload Tali Forth to GitHub, and this all should be easier.

Hope this helps,
Y, Scot


Top
 Profile  
Reply with quote  
PostPosted: Sun Nov 02, 2014 9:42 pm 
Offline

Joined: Mon Jan 07, 2013 2:42 pm
Posts: 576
Location: Just outside Berlin, Germany
So it turns out there are two more problems with the current setup.

First, py65 removed the blocking_getc address from $F005 (see https://github.com/mnaberez/py65/commit/0a6f7b90a26eb2f2a6945a81a5b41e5091accc4b), and suggests you use $F004 (getc) instead. Since the Tali Forth kernel looks for the character at $F005, it only returns zeros.

(Note that these addresses are hardwired as "magic numbers" in the py65 source code instead of being configurable. If you want to change them to reflect your hardware, on Ubuntu you have to go to /usr/local/lib/python2.7/dist-packages/py65/ and edit lines 213 and 214 of monitor.py. If my notes are correct, OS X Mavericks stores this file at /Library/Python/2.7/site-packages/py65-0.15-py2.7.egg/py65/)

Second, for some reason the xfce4 terminal 0.6.3 insists on sending CR instead of LF at the end of a line. I've added a check for both LF and CR now, which is a bit more bute-force than I like it, but okay.

I'm including the .zip file of my current version, the ophis.bin file should work with py65 out of the box. You should see this now (after typing WORDS):

Code:
Booting Kernel for the Überquirrel Mark Zero
Scot W. Stevenson <scot.stevenson@gmail.com>
Kernel Version Alpha 002 (25. Feb 2014)

Tali Forth for the 65c02
Version ALPHA 003 (15. May 2014)
Tali Forth comes with absolutely no warranty
Type 'bye' to exit

words  LOOP DO REPEAT WHILE UNTIL ELSE THEN IF WORDS DROP 2DROP ! @ >R R> R@ OVER 2OVER DUP ?DUP 2DUP SWAP 2SWAP NIP TUCK ROT DEPTH 1- 1+ FALSE TRUE BRANCH (BRANCH) 0BRANCH (0BRANCH) BEGIN AGAIN (DO) I J LEAVE UNLOOP (LOOP) ABS DABS + - * / */ */MOD UM* M* UM/MOD UD/MOD SM/REM FM/MOD MOD /MOD M+ AND OR XOR INVERT NEGATE DNEGATE MAX MIN LSHIFT RSHIFT S>D D>S D+ D- <# # #S HOLD SIGN #> U. U.R UD. . .R D. D.R 2 1 0 < = > 0= 0< COUNT >IN TYPE EMIT CHAR [CHAR] TOUPPER IN-PORT OUT-PORT KEY BASE HERE PAD UNUSED ERASE FILL CELL+ CELLS CHAR+ CHARS C, C! C@ CMOVE CMOVE> MOVE ALIGN ALIGNED ALLOT , ' >BODY >NAME EXECUTE EVALUATE STATE COMPILE, : ; ] [ POSTPONE IMMEDIATE COMPILE-ONLY NATIVE-COMPILE CREATE DOES> (DOES>) VARIABLE 2VARIABLE CONSTANT +! SOURCE DECIMAL HEX BINARY DIGIT>NUMBER NUMBER >NUMBER BL CR SPACE SPACES AT-XY PAGE BOLD REGULAR BELL ." (.") S" (S") .( ( \ /STRING -TRAILING FIND ACCEPT PARSE PARSE-NAME .S SEE DUMP QUIT ABORT LITERAL (LITERAL) COLD BYE ok

Let me know if there are any other problems. There is now a KNOWNISSUES.txt file, but it doesn't reflect all the problems yet :-) .

Y, Scot


Attachments:
TaliForth20141102.zip [97.81 KiB]
Downloaded 79 times
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC


Who is online

Users browsing this forum: Proxy and 3 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: