V-FORTH - Forth-83 for the VIC

Basic and Machine Language

Moderator: Moderators

Post Reply
User avatar
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: V-FORTH - Forth-83 for the VIC

Post by srowe »

funkheld wrote: Wed Sep 11, 2019 2:18 pm hello, thanks for the help.

Will the compiler bug be fixed?
Sure, I've tracked it down to 0>

Code: Select all

-32767 0> . 0 ok
-32768 0> . -1 ok
The problem is 0> is defined as

Code: Select all

: 0> negate 0< ;
and -32768 negate returns -32768.

This bug came in when I converted to Forth-83, I copied the implementation from someone else's code.

I need to think how to fix this given the very limited space available, the core code must be less than 8K to fit in the ROM image.
can you put down an asm program at $a000 and call "CALL $ a000"

Thank you.
Greeting
There are a couple of ways.

system.fs defines sys that allows you to call machine code just like from BASIC, you pass register values in using the variable sareg, sxreg and syreg and on return those variables contain the results.

assembler.fs allows you to define words that contain machine code

Code: Select all

include assembler

hex
code test
    2a # lda,  ffd2 jsr,  next jmp,
end-code
The code called must not over-write the parts of zero page that V-FORTH uses, and if you are using the assembler you must preserve .X as this is the data stack pointer.
funkheld
Vic 20 Devotee
Posts: 241
Joined: Tue Sep 10, 2019 4:23 am

Re: V-FORTH - Forth-83 for the VIC

Post by funkheld »

Hi good afternoon.

when I come to the assembler loading "MSG # 4".

what is that?

Thank you.
greeting
Attachments
asm.jpg
User avatar
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: V-FORTH - Forth-83 for the VIC

Post by srowe »

funkheld wrote: Thu Sep 12, 2019 7:22 am when I come to the assembler loading "MSG # 4".

what is that?
MSG #4 is a word redefinition warning, the check isn't clever enough to handle the fact it is in a separate vocabulary.

Errors are documented here

https://eden.mose.org.uk/gitweb/?p=vfor ... xt;hb=HEAD
funkheld
Vic 20 Devotee
Posts: 241
Joined: Tue Sep 10, 2019 4:23 am

Re: V-FORTH - Forth-83 for the VIC

Post by funkheld »

hello thanks for the help.

greeting
funkheld
Vic 20 Devotee
Posts: 241
Joined: Tue Sep 10, 2019 4:23 am

Re: V-FORTH - Forth-83 for the VIC

Post by funkheld »

hello good day.

if change the A and B it ok:
------------------------------------------------------------------
create chra 255 c, 129 c, 129 c, 129 c, 129 c, 129 c, 129 c, 255 c,
create chrb 255 c, 12 c, 12 c, 12 c, 12 c, 12 c, 12 c, 255 c,

: chara
8 0 do i chra + c@ i 5128 + c! loop
8 0 do i chrb + c@ i 5136 + c! loop;
-----------------------------------------------------------------
chara 5120 charbase! >>>>>>>>>> it ok !


this is not ok:
-----------------------------------------------------------------
: charneu
2047 0 do i 32768 + c@ i 5120 + c! loop ;
----------------------------------------------------------------
charneu 5120 charbase! >>>>>>> it not ok !
not a single letter is changed.

greeting
User avatar
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: V-FORTH - Forth-83 for the VIC

Post by srowe »

Please download the latest D64 image, I've made a simple fix for the 0> bug.

This version of your code now works, it uses cmove rather than a loop

Code: Select all

hex
create chrbyte ff c, 81 c, 81 c, 81 c, 81 c, 81 c, 81 c, ff c,

: charset
cd 9005 c!
8000 1400 800 cmove
chrbyte 1408 8 cmove ;
User avatar
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: V-FORTH - Forth-83 for the VIC

Post by srowe »

funkheld wrote: Thu Sep 12, 2019 1:00 am I started vforth.
Now I want to load an asm program "test.p" to $ a000
"load" test.p ", 8,1
how is that possible?
You'll need to define a word that calls the various KERNAL routines

Code: Select all

: load
name count $setnam
1 8 8 $setlfs
0 $load ?ioerr drop ;

load test.p
funkheld
Vic 20 Devotee
Posts: 241
Joined: Tue Sep 10, 2019 4:23 am

Re: V-FORTH - Forth-83 for the VIC

Post by funkheld »

Hello, good evening.
Thank you for your tireless help.
the vforth is a great thing for the vic20.

the command "charset" does not work.

I enter: charset 5120 charbase!

Thank you.
greeting
Attachments
charset10.jpg
funkheld
Vic 20 Devotee
Posts: 241
Joined: Tue Sep 10, 2019 4:23 am

Re: V-FORTH - Forth-83 for the VIC

Post by funkheld »

hello, this works
this is your demo, something shortened:
-------------------------------------
hex
create chrbyte ff c, 81 c, 81 c, 81 c, 81 c, 81 c, 81 c, ff c,
: charset
chrbyte 1408 8 cmove ;
------------------------------------


2048 Char-byte to 5120 , asm starts with $a000:

Code: Select all

!to "charsetasm.p", cbm

*=$a000

 charmem = $fb
 charmem1= $fd
  bloecke   = 8
	
start
  lda #$00            
  sta charmem
  lda #$80
  sta charmem+1
 lda #$00            
  sta charmem1
  lda #$14
  sta charmem1+1 
  ldx #bloecke 
  ldy #0
schleife  
  lda (charmem),y
  sta (charmem1),y  	
  iny                 
  bne schleife   
	  
  inc charmem+1 
  inc charmem1+1  
	
  dex                  
  bne schleife  

  rts     

start with:

load "vforth.p",8,1
sys 8192
load charsetasm.p
sys 40960 >>>> a000
5120 charbase!
charset

everything ok.
Attachments
sook.jpg
User avatar
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: V-FORTH - Forth-83 for the VIC

Post by srowe »

Did you try my example with the latest disk image downloaded from https://eden.mose.org.uk/download/?
funkheld
Vic 20 Devotee
Posts: 241
Joined: Tue Sep 10, 2019 4:23 am

Re: V-FORTH - Forth-83 for the VIC

Post by funkheld »

Hi good afternoon.

can you please explain the text exactly for the graphics and the mode?

Thank you.
greeting

----------------------------------------------
104 80 bitmap mode gr
60 96 bitmap multi-colour or mode mg
160 160 bitmap double-height or mode dg
20 10 0 mode tx
-----------------------------------------------
User avatar
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: V-FORTH - Forth-83 for the VIC

Post by srowe »

funkheld wrote: Fri Sep 13, 2019 1:00 pm Hi good afternoon.

can you please explain the text exactly for the graphics and the mode?

Thank you.
greeting

----------------------------------------------
104 80 bitmap mode gr
60 96 bitmap multi-colour or mode mg
160 160 bitmap double-height or mode dg
20 10 0 mode tx
-----------------------------------------------
The first two values are the maximum x and y values. The third is a set of mode bits to choose text vs bitmap, multicolour, double height.

Trying the examples something seems to be not working, it just hangs after clearing the screen.

I will try to spend some time this weekend re-writing the graphics subsystem to be simpler.
funkheld
Vic 20 Devotee
Posts: 241
Joined: Tue Sep 10, 2019 4:23 am

Re: V-FORTH - Forth-83 for the VIC

Post by funkheld »

hello, thanks for overworking it.
will you get the fs out again?


Thank you for your many work.
i like this vforth especially because you have the
all vic20 so clean can address.

Thanks & Greetings
funkheld
Vic 20 Devotee
Posts: 241
Joined: Tue Sep 10, 2019 4:23 am

Re: V-FORTH - Forth-83 for the VIC

Post by funkheld »

vforth.d64 2019-09-12 18:13 171K

the charset will not be rewritten here either.
only one letter is converted.

greeting.
funkheld
Vic 20 Devotee
Posts: 241
Joined: Tue Sep 10, 2019 4:23 am

Re: V-FORTH - Forth-83 for the VIC

Post by funkheld »

Hi good afternoon.
I can not find a solution.

if "xb <0" xb should remain 0 , xb is then 21 , why ???
if "yb <0" yb should remain 0 , yb is then 22 , why ?

the key operation is:
for x: Q / E
for y: W / S


thanks
greeting

Code: Select all

variable xb 
variable yb 

: cls
510 0 do 32 i 4096 + c! loop ;

: t81
if xb c@ 1 - xb c!  then  xb c@ 0  < if 0  xb c!  then ; 

: t69
if xb c@ 1 + xb c!  then  xb c@ 21 > if 21 xb c!  then ;

: t87
if yb c@ 1 - yb c!  then  yb c@ 0  < if 0  yb c!  then ;

: t83
if yb c@ 1 + yb c!  then  yb c@ 22 > if 22 yb c!  then ;

: gehe 
cls 
10 yb c!  10 xb  c! 
begin
	key  
	dup 81 = t81
	dup 69 = t69
	dup 87 = t87
	    83 = t83
			
	." x= " xb c@ . ." y= " yb c@ . cr 
	?terminal  
until  ;
 
Post Reply