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

All times are UTC




Post new topic Reply to topic  [ 123 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6 ... 9  Next
Author Message
PostPosted: Sun Sep 13, 2015 10:28 am 
Offline

Joined: Sat Jul 28, 2012 11:41 am
Posts: 442
Location: Wiesbaden, Germany
mkl0815 wrote:
It seems that VTL/K had a simple peek and poke feature.
Poke: @(n)=<EXPRESSION>
Peek: A=@(n)

Maybe we can add this feature to our 65C02 VTL. It would also make handling arrays much easier.

Mario.


An easier way to implement peek and poke would require a reserved variable as the address pointer used. At first I thought I could take double quote as it is already used for sys calls (greater than). However, that does not allow for later increments like "="+1 as it would be decoded as a string on the right side of the equation.

To implement one just has to copy the behavior of $ after labels exec1 and getval2. Instead of jsr outch and jsr inch you need to implement an indirect store or load with the designated address variable.

So one can poke some address with its own low address byte (assuming + as the address variable) :
10 +=512
20 @=+
30 +=++1
40 #=20*+<520

or peek and print the same range:
50 +=512
60 ?=@
70 +=++1
80 #=60*+<520

Poke the high byte: @=A/256
Peek the high byte: A=@*256 ...or if low byte was already read: A=@*256+A

I will put it on my todo list, which already has "put VTL02 on GitHub" as discussed with Ed in private mails. But this will have to wait at least one month until I return home from Greece.

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


Top
 Profile  
Reply with quote  
PostPosted: Sun Sep 13, 2015 5:30 pm 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1949
Location: Sacramento, CA, USA
Thank you for the excellent idea, Klaus! I will attempt to implement your suggestion and my ;A) idea, and see which one feels right. As long as the interpreter code doesn't exceed 1KB, either could do the job with minimal fuss.

Ed has added my original source into the6502.org source code repository, and I will be keeping in touch with him if I need to request any significant updates there (dclxvi's suggestions are being incorporated as well, but progress is slow, due to my limited spare time).

Mike B.

[Edit: I'm starting to lean toward a @A) notation, to allow backwards compatibility with standard VTL-2 programs that may use ; as a simple variable (like my Super Star Trek port in the works):
Code:
10 @255)=128) POKE 255,128
20 Z=@32768)&127) Z = PEEK(32768) AND 127
30 @P)=@P)^128) Flip the high bit of port at P

The & | ^ operators are so easy to add, I'm going to do that as well, keeping the 1KB limit in mind. To support legacy keyboards and displays that may not be able to support the | character for bit-wise OR, I will add an assembly-time equate to change it to \ or !
]


Last edited by barrym95838 on Thu Oct 01, 2015 4:16 am, edited 2 times in total.

Top
 Profile  
Reply with quote  
PostPosted: Tue Sep 15, 2015 10:49 pm 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1949
Location: Sacramento, CA, USA
Klaus2m5 wrote:
... An easier way to implement peek and poke would require a reserved variable as the address pointer used. At first I thought I could take double quote as it is already used for sys calls (greater than). However, that does not allow for later increments like "="+1 as it would be decoded as a string on the right side of the equation ...

Well, you could just go "=1+" since the ?=" check only looks at the character directly after the =

I really want to try my @A) notation (see edit of my previous post) first, but I will give your proposal serious consideration.

Mike B.

P.S. I'm also considering allowing the interpreter to ignore space characters inside expressions, to allow more aesthetically pleasing program listings, at a slight cost in memory usage and execution speed. This would prevent using the space character as a variable name, but that would be a very small price to pay.


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 16, 2015 5:58 am 
Offline

Joined: Sat Jul 28, 2012 11:41 am
Posts: 442
Location: Wiesbaden, Germany
The variable used to represent the peek and poke address can still be used as a normal variable if neither peek nor poke will be used. So your Super Star Trek port would still work.

Remember, that the @ in your original version is still assigned as a line erase. I replaced it in my version with 0x1b (escape key). I also replaced _ with 0x08 (backspace) and 0x7f (delete). But this may cause a problem for people with a true teletype printer or a simple terminal.

Disallowing space as a variable is a good move (invisible operators and variables at the end of a line) and sets it free for internal use.

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


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 16, 2015 6:27 am 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1949
Location: Sacramento, CA, USA
Good points, Klaus. I think I would like to target the Apple 1 as my "lowest-common-denominator" target. It can accept the full 7-bit ASCII set as input, but can only display codes 32 through 95 (and 13). I have already added the & | and ^ operators, at a total cost of 45 bytes. I'm still experimenting with the PEEK/POKE equivalents, but I should have something to show before you get back from Greece, with a bit of luck. Disallowing space (as a valid user variable and default operator) will be my final enhancement attempt for VTL02B, but I have set a hard size limit of 1024 bytes for the interpreter, and it's going to be tight.

Mike B.


Top
 Profile  
Reply with quote  
PostPosted: Sat Sep 19, 2015 4:30 pm 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1949
Location: Sacramento, CA, USA
Update: my @A) enhancement is certainly doable, but is more expensive than Klaus' suggestion to use @ as a special memory access variable and another variable like < for the access pointer (which can be used as a normal variable if the @ feature is avoided). I'm going to back-track a bit and implement Klaus' proposal instead, then work on neutering the space character. I am cautiously optimistic that both of these enhancements (and & | ^) will still fit inside 1KB.

Source coming soon, I hope!

Mike B.

P.S. I have also moved all of the I/O subroutines to the end, to prevent any out-of-range branch hassles for those of you who need some extra code space to deal with systems having no built-in monitor I/O support (my interpreter does a lot of internal code sharing with unstructured branch instructions, to save space).

P.P.S. I have to test it out on AppleWin, but it looks like the VTL02B Apple 2 version will come in under 1KB, with 48 bytes to spare, allowing enough space to tweak the terminal I/O subroutines and port it to most 6502 systems.

Code:
[ ... ]
;------------------------------------------------------
; 2015: Revision B, with several space optimizations
;   (suggested by dclxvi) and enhancements (suggested
;   by mkl0815 and Klaus2m5).
;
; New features in Revision B:
; * Bit-wise operators & | ^ (and, or, xor)
;   Example:  A=$|128) Get a char and set hi-bit
;
; * Absolute addressed 8-bit memory load and store
;   via the @ <) facility:
;   Example:  <=P) Point to the I/O port at P
;             @=@&254^128) Clear low-bit & flip hi-bit
;
; * The space character is no longer a valid user
;     variable nor a "valid" binary operator.  It is
;     now only significant in strings and program
;     listings, where it may be used to improve human
;     readability, at a slight cost in execution
;     speed and memory consumption.
;   Example:
;   * (VTL-2)
;       1000 A=1)         Init loop index
;       1010 ?=A)           Print index
;       1020 ?="")          Newline
;       1030 A=A+1)         Update index
;       1040 #=A<10*1010) Loop until done
;   * (VTL02B)
;       1000 A = 1             ) Init loop index
;       1010     ? = A         )   Print index
;       1020     ? = ""        )   Newline
;       1030     A = A + 1     )   Update index
;       1040 # = A < 10 * 1010 ) Loop until done
;------------------------------------------------------
[ ... ]

P.P.S. Er ... 45 bytes to spare, and I still have a significant bug to squash. Has anyone here used AppleWin's debug feature? How steep is the learning curve? I debugged the first one through detailed run-time observation and a few carefully-selected break-points, but I might try something different this time ...


Top
 Profile  
Reply with quote  
PostPosted: Fri Sep 25, 2015 6:16 am 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1949
Location: Sacramento, CA, USA
dclxvi wrote:
... At CVBIN2, save 2 bytes by using EOR #$30 CMP #10 BCC CVBIN3 before the PLA ...

Ooh ... if you weren't so awesome, I would have a few choice words to say to you ... that's supposed to be BCS CVBIN3 !!

Anyway, I have the source ready to share with y'all. It's still set up for sbasm, but I took some extra time to make the source file a bit easier to translate to other assemblers. I hope you guys enjoy it!

Attachment:
vtl02ba2.asm [34.03 KiB]
Downloaded 243 times


Cheers,

Mike B.


Top
 Profile  
Reply with quote  
PostPosted: Fri Sep 25, 2015 2:48 pm 
Offline

Joined: Sun Feb 23, 2014 2:43 am
Posts: 78
Tried this today, the formatting is nice and indeed only required minor changes to work. Pretty neat for under 1K, nice job.


Top
 Profile  
Reply with quote  
PostPosted: Fri Sep 25, 2015 3:05 pm 
Offline

Joined: Mon Mar 25, 2013 9:26 pm
Posts: 183
Location: Germany
Perfect timing. I have some days of free time to convert and test the new version. It will be featured in my tech-talk at the Vintage Computing Festival Berlin next week.

Mario.

_________________
How should I know what I think, until I hear what I've said.


Top
 Profile  
Reply with quote  
PostPosted: Sun Sep 27, 2015 5:10 pm 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1949
Location: Sacramento, CA, USA
Combing through the source again, I found four more bytes to squeeze, but I've definitely reached the point of diminishing returns with the NMOS instruction set. I estimate that at least 20 bytes could be saved by using 'c02 extensions, and at least 80 bytes could be saved with 'c802/816 extensions, but I'm content with playing to the lowest common denominator for now, which is the NMOS Apple 1 (although a patch for the multiply routine would be necessary for ROR-bug specimens).

Chores and many other projects await ... I need to move on, but I appreciate your patience, feedback, praise, camaraderie and critique. What an awesome little community we have here!

Cheers,

Mike B.


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 30, 2015 6:45 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Brought over from the prime number challenge thread:

barrym95838 wrote:
BigEd wrote:
... I tried and so far failed to port VTL to Beeb ...

Is it the I/O or page-zero conflicts that's throwing a wrench in the works? The Apple 1 and Apple 2 monitors only need about a dozen (or less) zp locations, and they're all in the lower half, so it was safe for me to usurp $80 to $ff for the interpreter.


Initially it was the zero page allocation - the Beeb allows the first half for the "current language", initially Basic but would be VTL once CALLed. But... I think there's some mixing of values and locations, and I'm not sure if relocating the workarea was working. Plus, I think there are some assumptions about Apple's ASCII having the high bit set - perhaps linked to the zp locations in a cunning way. So, probably needs a thorough sweep of uses of bytesize values and what the value of the top bit should be.

(Minor things like connecting I/O and switching the line-end convention seemed straightforward - I feel as if I've done that before!)


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 30, 2015 9:30 pm 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1949
Location: Sacramento, CA, USA
VTL02 and 02B work with the high-bit clear ASCII internally, and only "translate" for terminal I/O, as necessary.

You should check out the following subroutine:
Code:
;-----------------------------------------------------;
; Set var[x] to the address of the variable named in a
; entry:  a holds variable name, @[y] -> text holding
;         array index expression (if a = ':')
; uses:   plus, eval, oper8d, {@ &}
; exit:   (eq): var[x] -> variable, @[y] unchanged
;         (ne): var[x] -> array element,
;               @[y] -> following text
; 27 bytes
convp:
    cmp  #':'       ; array element?
    beq  varray
    asl             ;   no: var[x] -> simple variable
    ora  #$80
    bmi  oper8d     ;     (always taken)
varray:
    jsr  eval       ;   yes: evaluate array index at
    asl  0,x        ;     @[y] and advance y
    rol  1,x
    lda  ampr       ;     var[x] -> array element
    sta  2,x        ;       at address 2*index+&
    lda  ampr+1
    sta  3,x
    jmp  plus

I am almost certain this is where your problem lies, especially the ASL ORA #$80 BMI sequence. Although it is not well commented (sorry), this is where the named variable is translated from ASCII to a zp address. 'A' translates to $82, '!' to $c2, etc., which matches my zp equates at the beginning of the source. If you want to use $00 to $7f, just change that critical sequence to ASL AND#$7f BPL, and make sure that 'A' corresponds to $02, '!' to $42 etc. in your equates.

Mike B.


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 30, 2015 9:33 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Thanks - that makes sense. I'll give it a go...


Top
 Profile  
Reply with quote  
PostPosted: Mon Oct 05, 2015 3:54 am 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1949
Location: Sacramento, CA, USA
mkl0815 wrote:
Perfect timing. I have some days of free time to convert and test the new version. It will be featured in my tech-talk at the Vintage Computing Festival Berlin next week.

Mario.

I found your video here. I must say that you are a very handsome geek! It's a pity that I don't speak more than a dozen words of German, but I enjoyed it as much as I could, under the circumstances. It's also a pity that your copy/paste was dropping characters at the beginning of each line, spoiling your VTL02 presentation a bit.

Mike B.


Top
 Profile  
Reply with quote  
PostPosted: Mon Oct 05, 2015 5:38 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8512
Location: Midwestern USA
barrym95838 wrote:
I found your video here. I must say that you are a very handsome geek! It's a pity that I don't speak more than a dozen words of German, but I enjoyed it as much as I could, under the circumstances. It's also a pity that your copy/paste was dropping characters at the beginning of each line, spoiling your VTL02 presentation a bit.

The visuals helped quite a bit, plus some technical words in German are similar enough to their English equivalents for me to figure out.

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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 123 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6 ... 9  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 7 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: