BASIC and strings

Hardware Hacking, Programming and Game Solutions/Cheats
jedie
Posts: 655
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: BASIC and strings

Post by jedie »

Anyone knows if dragon replace "tokens" in comments in memory and on tape?

e.g.:

Code: Select all

10 ' PRINT "FOOBAR"
would be changed to:

Code: Select all

10 ' $87 "FOOBAR"
btw. REM and ' are themself tokens... Maybe the line would be stored as:

Code: Select all

10 $83 $87 "FOOBAR"
... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
Sarah
Posts: 177
Joined: Wed Apr 13, 2011 3:36 pm
Contact:

Re: BASIC and strings

Post by Sarah »

No. The text is treated as text.
jedie
Posts: 655
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: BASIC and strings

Post by jedie »

Now i can test it in DragonPy... I used this listing and used the function to extract the BASIC Listing...

I used this example code line:

Code: Select all

10 ' PRINT "PRINT"
And extract it, i see this debug output:

Code: Select all

BASIC program dump:
$1e $16 
$00
$0a $3a $83 $20 $50 $52 $49 $4e $54 $20 $22 $50 $52 $49 $4e $54 $22 
$00

$00
$00
progam start $1e01
next_address: $1e16
line_number: 10
length: 21
tokens: $3a,$83,$20,$50,$52,$49,$4e,$54,$20,$22,$50,$52,$49,$4e,$54,$22,$00
progam start $1e16
next_address: $0000
So, yes: No tokens in comment lines... A translation:

Code: Select all

0x0a -> 10
0x3a -> ":"
0x83 -> "'"
0x20 -> ' '
0x50 -> 'P'
0x52 -> 'R'
0x49 -> 'I'
0x4e -> 'N'
0x54 -> 'T'
0x20 -> ' '
0x22 -> '"'
0x50 -> 'P'
0x52 -> 'R'
0x49 -> 'I'
0x4e -> 'N'
0x54 -> 'T'
0x22 -> '"'
The interesting thing here is, that there is a : inserted before the comment!
e.g.: You write this:

Code: Select all

10 ' FOO
and the internal representations is this:

Code: Select all

10 :' FOO
... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
User avatar
JeeK
Posts: 67
Joined: Fri Aug 16, 2013 10:45 am
Location: Vienna, Austria
Contact:

Re: BASIC and strings

Post by JeeK »

jedie wrote:Now i can test it in DragonPy... I used this listing and used the function to extract the BASIC Listing...
[..]
So, yes: No tokens in comment lines... A translation:

Code: Select all

0x0a -> 10
0x3a -> ":"
0x83 -> "'"
0x20 -> ' '
0x50 -> 'P'
0x52 -> 'R'
0x49 -> 'I'
0x4e -> 'N'
0x54 -> 'T'
0x20 -> ' '
0x22 -> '"'
0x50 -> 'P'
0x52 -> 'R'
0x49 -> 'I'
0x4e -> 'N'
0x54 -> 'T'
0x22 -> '"'
The interesting thing here is, that there is a : inserted before the comment!
e.g.: You write this:

Code: Select all

10 ' FOO
and the internal representations is this:

Code: Select all

10 :' FOO
This is to satisfy how the interpreter is working. Since the commentary single quote can start right after a basic statement, the interpreter has to be told that the comment starts. The comment is also a "statement" and a statement can only start at a line beginning or after the statement separator ":". The BASIC tokenizer silently inserts the ":" and LIST does the suppress.
Same for ELSE.
The dragon on my side: http://klasek.at/hc/dragon/
jedie
Posts: 655
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: BASIC and strings

Post by jedie »

That makes sense. And yes, i see the same with "ELSE"...

Are ' and ELSE the only "exceptions" ?

Maybe i add simple replace rules:

Code: Select all

":'" -> "'"
":ELSE" -> "ELSE"
... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
User avatar
JeeK
Posts: 67
Joined: Fri Aug 16, 2013 10:45 am
Location: Vienna, Austria
Contact:

Re: BASIC and strings

Post by JeeK »

jedie wrote:That makes sense. And yes, i see the same with "ELSE"...

Are ' and ELSE the only "exceptions" ?

Maybe i add simple replace rules:

Code: Select all

":'" -> "'"
":ELSE" -> "ELSE"
I think so, but I actually didn't analyze the LIST routine in ROM where such thing could be observed. Even with my de-tokenizer script I saw no other "constructions" like this (for a limited collection of programs I wrote). But this observation is probably neither complete nor will prove this fact ... ;)
The dragon on my side: http://klasek.at/hc/dragon/
jedie
Posts: 655
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: BASIC and strings

Post by jedie »

With https://github.com/jedie/DragonPy/commi ... c2990eb096 i do the ' <-> :' and ELSE <-> :ELSE replacement internally in my Emulator<->BASIC-Editor

Seems to work fine :D
... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
Post Reply