Spin2CPP, FlexSpin, FlexCC, FlexProp (PASM, Spin, BASIC, C)

Offtopic Themen bitte hier hinein.
Benutzeravatar
yeti
Beiträge: 2300
Registriert: Fr 27. Aug 2010, 14:48
Wohnort: Wrong Planet
Kontaktdaten:

spin2cpp-3.8.x

Beitrag von yeti »

----------8<-----{20180517-2110-GMT}----->8----------

Spin to C / C++ / PASM / binary converter version 3.8.0
totalspectrum hat geschrieben:The 3.8.0 series also adds multiple assignment of variables and multiple return values from functions (both features proposed for Spin2). Note that these features do, in fact, work on the Propeller 1 as well!
----------8<-----{20180517-2312-GMT}----->8----------

Mehrere Rückgabewerte einer Funktion sind scheinbar noch etwas zickig und wollen Extratätscheleien: https://github.com/totalspectrum/spin2cpp/issues/28

Ich wette, binnen weniger Stunden ist entweder erklärt, warum das so sein muß oder falls ich da auf einen Käfer trat, sogar behoben.

Ich harre gespannt der Antwort... war es vielleicht doch PEBCAK?

----------8<-----{20180518-1411-GMT}----->8----------

A) Nix PEBCAK.
B) Behoben in fastspin-3.8.1-beta.
C) \o/

----------8<-----{20180519-0308-GMT}----->8----------

...und schon geht's weiter:

Spin to C / C++ / PASM / binary converter version 3.8.1

----------8<-----{20180519-2248-GMT}----->8----------

Den Hinweis auf...

Spin to C / C++ / PASM / binary converter version 3.8.2

...lasse ich einfach mal ausfallen.

Niemand hat die Absicht, das zu merken! :LACHEN

----------8<-----{20180521-1418-GMT}----->8----------

Spin to C / C++ / PASM / binary converter version 3.8.3
totalspectrum hat geschrieben:I've also added some of the Spin2 operators, such as a\b for "use a then set a to b".
Häääääää?!?!?!
Auch Freitags?
;-)

----------8<-----{20180524-0354-GMT}----->8----------

...uuuuund weiter geht's:

Spin to C / C++ / PASM / binary converter version 3.8.4

https://forums.parallax.com/discussion/ ... nt_1438864 hat auch ein paar Zeilen dazu.

----------8<-----{20180529-0434-GMT}----->8----------

...und es ward 3.8.5:

Spin to C / C++ / PASM / binary converter version 3.8.5

https://forums.parallax.com/discussion/ ... nt_1439210 mit lokaler Erleuchtung hierzu.

----------8<-----{20180530-1537-GMT}----->8----------

...und Version 3.8.6 verheimliche ich mal einfach...

Jawollja!

----------8<-----{20180608-2055-GMT}----->8----------

<flüster>Version 3.8.7</flüster>
<murmel>https://forums.parallax.com/discussion/ ... nt_1440276</murmel>

----------8<-----{FastSpin? Nur mit Schal, Helm und Gurt!!!}----->8----------
𝖂𝖎𝖗 𝖐𝖔̈𝖓𝖓𝖊𝖓 𝖆𝖑𝖑𝖊𝖘 𝖆𝖚𝖘𝖘𝖊𝖗 𝖎𝖓 𝕱𝖗𝖚̈𝖍𝖑𝖎𝖓𝖌, 𝕾𝖔𝖒𝖒𝖊𝖗, 𝕳𝖊𝖗𝖇𝖘𝖙 𝖚𝖓𝖉 𝖂𝖎𝖓𝖙𝖊𝖗! – 𝕯𝖊𝖚𝖙𝖘𝖈𝖍𝖑𝖆𝖓𝖉.
"Du willst hier nicht klicken. Dies interessiert Dich nicht." — Yeti.
"DNA is a four letter word!" — Yeti.
Benutzeravatar
yeti
Beiträge: 2300
Registriert: Fr 27. Aug 2010, 14:48
Wohnort: Wrong Planet
Kontaktdaten:

Re: spin2cpp

Beitrag von yeti »

----------8<-----{20180904-0502-GMT}----->8----------

New BASIC compiler for Prop1 and Prop2

:DAUMENHOCH
Eric schafft das!
Ganz bestimmt!!!

Reinschauen, während die BASIC-Bits noch gemeißelt, gefeilt und poliert werden, kann man beispielsweise im Log des Branchs "basic" der spin2cpp-Quelltextlagerstätte.

----------8<-----{20180904-0850-GMT}----->8----------

Code: Alles auswählen

$ ./fastspin
Propeller Spin/PASM Compiler 'FastSpin' (c) 2011-2018 Total Spectrum Software Inc.
Version 3.8.8-beta Compiled on: Sep  4 2018
usage: ./fastspin
  [ -h ]              display this help
  [ -L or -I <path> ] add a directory to the include path
  [ -o ]             output filename
  [ -b ]             output binary file format
  [ -e ]             output eeprom file format
  [ -c ]             output only DAT sections
  [ -l ]             output DAT as a listing file
  [ -f ]             output list of file names
  [ -q ]             quiet mode (suppress banner and non-error text)
  [ -p ]             disable the preprocessor
  [ -D <define> ]    add a define
  [ -u ]             ignore for openspin compatibility (unused method elimination always enabled)
  [ -2 ]             compile for Prop2
  [ -O# ]            set optimization level:
          -O0 = no optimization
          -O1 = basic optimization
          -O2 = all optimization
  [ -w ]             compile for COG with Spin wrappers
  [ --code=cog ]     compile for COG mode instead of LMM
  [ --fcache=N ]     set FCACHE size to N (0 to disable)
...so weit keine großen Überraschungen.

Code: Alles auswählen

$ cat btest003.bas 
class FDS input "FullDuplexSerial.spin"

dim ser as FDS
dim i as byte

ser.start(31, 30, 0, 115_200)
for i = 1 to 10
  ser.dec(i)
  ser.tx(13)
  ser.tx(10)
next i

waitcnt(0)
Back dat!

Code: Alles auswählen

$ ./fastspin -O2 -L /opt/parallax.spin.src/spin btest003.bas 
Propeller Spin/PASM Compiler 'FastSpin' (c) 2011-2018 Total Spectrum Software Inc.
Version 3.8.8-beta Compiled on: Sep  4 2018
btest003.bas
|-FullDuplexSerial.spin
btest003.pasm
Done.
Program size is 1676 bytes
$ /opt/parallax/bin/spinsim -b btest003.binary 
1
2
3
4
5
6
7
8
9
10
... da fehlt nun noch die Cogs sauber runterzufahren, damit SpinSim terminiert, aber diese Feinheit irgorieren wir jetzt mal... ok?

----------8<-----{20180904-1155-GMT}----->8----------

Code: Alles auswählen

class FDS input "FullDuplexSerial.spin"

dim ser as FDS
dim i as byte

ser.start(31, 30, 0, 115_200)
for i = 1 to 10
  ser.dec(i)
  ser.tx(13)
  ser.tx(10)
next i

waitcnt(clkfreq+getcnt())

ser.stop()
...terminiert dann auch brav in SpinSim, aber warum "clkfreq" eine Variable zu sein scheint und "cnt" ansich nicht existiert, wohl aber als Funktion "getcnt()", das durchblick ich grad nicht wirklich und wer weiß, ob das nach weiteren Revisionen noch immer so sein wird. Wie Spins "<<" in BASIC heißt hab ich auch noch nicht raus, ansonsten hätt ich längst mit Fixpunktarithmetik rumgemacht... mwhuaaahaahahahaaaa... ***flöööt!***

----------8<-----{20180905-1130-GMT}----->8----------

Hmmmm.... ich seh auch nicht wo und wer da den Quarzplutimikator und die Quarzfreqenz setzt. Gear meint, das Kompilat sei für die typischen 5MHz mal 16 konfiguriert, aber das find ich nicht in der PASM-Ausgabe.

Vermutlich ist das Alles noch eher näher an einer Alpha- als einer Beta-Release, aber ich bleibe dabei: Eric schafft das! Ich werd ihn mal nicht mit Fragen bestürmen, sondern ihn einfach wuppen lassen...

----------8<-----{20180907-1612-GMT}----->8----------

Heiliges GOTO!!!

Code: Alles auswählen

$ cat moo.bas
yipyip:
  print"Moo!"
  goto yipyip
$ /opt/spin2cpp/src/spin2cpp.basic/build/fastspin -O2 moo.bas
Propeller Spin/PASM Compiler 'FastSpin' (c) 2011-2018 Total Spectrum Software Inc.
Version 3.8.8-beta Compiled on: Sep  7 2018
moo.bas
moo.pasm
Done.
Program size is 500 bytes
$ /opt/spinsim/bin/spinsim -b moo.binary | head
Moo!
Moo!
Moo!
Moo!
Moo!
Moo!
Moo!
Moo!
Moo!
Moo!
...das "| head" sorgt nur für einen Abbruch nach 10 Zeilen.

----------8<-----{20180907-1621-GMT}----->8----------

Code: Alles auswählen

$ cat tinpb.bas 
print"This is not PropBASIC!"
let x%=(1+2)*3
rem    ^   ^
rem ...alles klar?
print"(1+2)*3=",x%
$ /opt/spin2cpp/src/spin2cpp.basic/build/fastspin -O2 -q tinpb.bas 
$ /opt/spinsim/bin/spinsim -b tinpb.binary 
This is not PropBASIC!
(1+2)*3=9
...eeendlich ein ordentlicher Ausdrucksparser!

----------8<-----{20180909-1133-GMT}----->8----------

Ich kann es einfach nicht lassen:

Code: Alles auswählen

$ cat mandelbrot16.bas
'
' translated to BASIC from mandelbrot16-20180406-fds.spin
'

'++
' I need printing without forced LF at the end, so:
'
  class FDS input "FullDuplexSerial.spin"
  dim ser as FDS
  ser.start(31,30,0,115200)
'--

'++
' as constants
'
  let xmin%=-8601
  let xmax%=2867

  let ymin%=-4915
  let ymax%=4915

  let maxiter%=32

  let MPX%=79 ' 0..79
  let MPY%=24 ' 0..24

  let dx%=(xmax%-xmin%)/MPX%
  let dy%=(ymax%-ymin%)/MPY%

  let c4%=4<<12
'--

'++
' ...aaaaand action!
'
  let cy%=ymin%
  for py%=0 to MPY%
    let cx%=xmin%
    for px%=0 to MPX%
      let x%=0
      let y%=0
      let iter%=0
      while iter%=<maxiter%
'       let x2%=(x%*x%)>>12
        let x2%=ssr(x%*x%,12)
'       let y2%=(y%*y%)>>12
        let y2%=ssr(y%*y%,12)
        if x2%+y2%>c4% goto breakwhile
'       let y%=((x%*y%)>>11)+cy%
        let y%=ssr(x%*y%,11)+cy%
        let x%=x2%-y2%+cx%
        let iter%=iter%+1
      end while
breakwhile:
      let cx%=cx%+dx%
      ser.tx(iter%+32)
    next px%
    let cy%=cy%+dy%
    ser.tx(13)
    ser.tx(10)
  next py%
'--

'++
' let FDS transmit potentially queued chars before shutdown
'
  waitcnt(80_000_000+cnt)
  ser.stop()
'--

'++
' signed shift right
'
function ssr(x%,n%)
  if x%>=0 return x%>>n%
  return -((-x%)>>n%)
end function
'--
$ /opt/spin2cpp/src/spin2cpp.basic/build/fastspin -O2 -L /opt/parallax.spin.src/spin mandelbrot16.bas 
Propeller Spin/PASM Compiler 'FastSpin' (c) 2011-2018 Total Spectrum Software Inc.
Version 3.8.8-beta Compiled on: Sep  8 2018
mandelbrot16.bas
|-FullDuplexSerial.spin
mandelbrot16.pasm
Done.
Program size is 2436 bytes
$ /opt/parallax/bin/spinsim -b mandelbrot16.binary 
!!!!!!!!!!!!!!!"""""""""""""####################################""""""""""""""""
!!!!!!!!!!!!!"""""""""#######################$$$$$$$%'+)%%%$$$$$#####"""""""""""
!!!!!!!!!!!"""""""#######################$$$$$$$$%%%&&(+,)++&%$$$$$$######""""""
!!!!!!!!!"""""#######################$$$$$$$$$$%%%%&')*5:/+('&%%$$$$$$#######"""
!!!!!!!!""""#####################$$$$$$$$$$%%%&&&''),AAAAAAA,'&%%%%%$$$$########
!!!!!!!"""####################$$$$$$$$%%%&'())((())*-AAAAAA/+))('&&&&)'%$$######
!!!!!!""###################$$$$$%%%%%%&&&'+.AA=/;AAAAAAAAAAAAAAA/++A..;5%%$#####
!!!!!"################$$$%%%%%%%%%%&&&&'),+2AAAAAAAAAAAAAAAAAAAAAAAAA1(&&%$$####
!!!!"##########$$$$$%%&(-('''''''''''((*,5AAAAAAAAAAAAAAAAAAAAAAAAAAAA+)-&%$$###
!!!!####$$$$$$$$%%%%%&'(*-A1.+.A-4+))**AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4-(&%$$$##
!!!!#$$$$$$$$$%%%%%%'''++.6AAAAAAAAA8/0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA3(%%$$$$#
!!!#$$$$$$$%&&&&''()/-7.5AAAAAAAAAAAAA>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'&%%$$$$#
!!!(**+/+<524/40046>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4+)'&&%%$$$$#
!!!#$$$$$$$%&&&&''().-2/AAAAAAAAAAAAAA?AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'&%%$$$$#
!!!!#$$$$$$$$$%%%%%&'''/,/7AAAAAAAAA;/0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA0'%%$$$$#
!!!!####$$$$$$$$%%%%%&'(*-;2.,/>-5+))*+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4+(&%$$$##
!!!!"##########$$$$$%%&(,(''''(''''''((*-4AAAAAAAAAAAAAAAAAAAAAAAAAAA4+).&%$$###
!!!!!"################$$$%%%%%%%%%%&&&&'):,4AAAAAAAAAAAAAAAAAAAAAAAAA/('&%%$####
!!!!!!""##################$$$$$$%%%%%%&&&'*.AAA0AAAAAAAAAAAAAAAA1,,A//9)%%$#####
!!!!!!!"""####################$$$$$$$$%%%&(())((()**-AAAAAA/+)))'&&&')'%$$######
!!!!!!!!""""#####################$$$$$$$$$$%%%&&&''(,AAAAAAA+'&&%%%%%$$$########
!!!!!!!!!"""""#######################$$$$$$$$$$%%%%&')*8A0+('&%%%$$$$$#######"""
!!!!!!!!!!!"""""""######################$$$$$$$$$%%%&&(+-).*&%$$$$$$######""""""
!!!!!!!!!!!!!"""""""""#######################$$$$$$%%'4(%%%$$$$$######""""""""""
!!!!!!!!!!!!!!!""""""""""""#####################################""""""""""""""""
$ █
Ein das Vorzeichen erhaltendes Shift-Right gibt es leider noch nicht.
FIX: Teuer (lahmsan) selber zimmern.

Wie man "print" den Zeilenvorschub abgewöhnt, weiß ich nicht. Es ist vermutlich noch ein fehlendes Feature.
FIX: Spin's FDS stattdessen nehmen.

Wie man "while"-Schlaufen ohne "goto" verläßt, seh ich auch noch nicht.
FIX: "goto" nehmen.

----------8<-----{20180909-1820-GMT}----->8----------

Ok: Aus Typenkonsequenz sollte obige Funktion "ssr" doch eher "ssr%" heißen. Das wird in weiteren Versionen korrigiert oder einer Funktion für die komplette Fixpunkt-Multiplikation weichen. Eines Tages soll es auch Vorzeichen erhaltendes Bitschieben geben, schrieb Eric, aber das soll Hand in Hand gehen mit mehr Typen (signed und unsigned Integer). Bis dahin brauch ich halt die eigenen Shift- oder Plutimizier-Funktionen...

----------8<-----{20180909-2205-GMT}----->8----------

Code: Alles auswählen

$ cat mandelbrot16.bas
'
' translated to BASIC from mandelbrot16-20180406-fds.spin
'

'++
' as constants
'
  let xmin%=-8601
  let xmax%=2867

  let ymin%=-4915
  let ymax%=4915

  let maxiter%=32

  let MPX%=79 ' 0..79
  let MPY%=24 ' 0..24

  let dx%=(xmax%-xmin%)/MPX%
  let dy%=(ymax%-ymin%)/MPY%

  let c4%=4<<12
'--

'++
' ...aaaaand action!
'
  let cy%=ymin%
  for py%=0 to MPY%
    let cx%=xmin%
    for px%=0 to MPX%
      let x%=0
      let y%=0
      let iter%=0
      while iter%=<maxiter%
'       let x2%=(x%*x%)>>12
        let x2%=ssr%(x%*x%,12)
'       let y2%=(y%*y%)>>12
        let y2%=ssr%(y%*y%,12)
        if x2%+y2%>c4% goto breakwhile
'       let y%=((x%*y%)>>11)+cy%
        let y%=ssr%(x%*y%,11)+cy%
        let x%=x2%-y2%+cx%
        let iter%=iter%+1
      end while
breakwhile:
      let cx%=cx%+dx%
      print chr$(iter%+32);
    next px%
    let cy%=cy%+dy%
    print
  next py%
'--

'++
' signed shift right
'
function ssr%(x%,n%)
  if x%>=0 return x%>>n%
  return -((-x%)>>n%)
end function
'--

'++
' chr$() (from ersmith)
' (I didn't see the "@" possibilities or they are new)
'
'' this is a bit of a hack for now, until we have
'' a standard string library

dim buf(2) as ubyte

function chr$(x)
  buf(1) = x
  return @buf(1)
end function
'--
Es gab Code-Updates vom Meister!
"print irgendwas;" unterdrückt jetzt den Zeilenvorschub und ich bekam einen Tip, wie man "chr$(n)" selber bauen kann. Somit kann FDS nun wieder rausfliegen. So schnell kann Fortschritt zuschlagen. :-)

Code: Alles auswählen

$ make mandelbrot16.binary -B
/opt/spin2cpp/src/spin2cpp.basic/build/fastspin -O2 mandelbrot16.bas
Propeller Spin/PASM Compiler 'FastSpin' (c) 2011-2018 Total Spectrum Software Inc.
Version 3.8.8-beta Compiled on: Sep  9 2018
mandelbrot16.bas
mandelbrot16.pasm
Done.
Program size is 1512 bytes
Ohne FDS ist das Binary doch deutlich geschrumpft.

Das entstehende Apfelbrötchen hat sich dadurch nicht verändert und wird daher nicht nochmal hierreinge-control-v-t.

----------8<-----{20180910-0210-GMT}----->8----------

Keine Atempause! Integer mit und ohne Vorzeichen werden nun unterschiedlich bitweise nach rechts geschubst und somit kann die "ssr"-Funktion nun entfallen und wo sie benutzt wird die darüber wegkommentierte Zeile statt der Zeile mit "ssr" benutzt werden.

----------8<-----{20180911-1122-GMT}----->8----------

Das 32-bittige Apfelbrötchen mit 24 Nachkommabits ist nun auch geBASICt:

Code: Alles auswählen

$ cat mandelbrot32hacks.spin 
pub mul(x,y)
  return (x**y)<<8 | (x*y)>>24

pub multimes2(x,y)
  return (x**y)<<9 | (x*y)>>23
$ cat mandelbrot32.bas
' translated from mandelbrot32-20180317-b.spin

'++
class hacks input "mandelbrot32hacks.spin"
dim hack as hacks
' hack.mul(x,y) does s8p24 fp multiplication
' hack.multimes2(x,y) does mul(x,y)*2
'--

'++
' constants

  let xmin%=(-21<<24)/10
  let xmax%=(  7<<24)/10

  let ymin%=(-12<<24)/10
  let ymax%=( 12<<24)/10

  let maxiter%=32

  let MPX%=79
  let MPY%=24

  let dx%=(xmax%-xmin%)/MPX%
  let dy%=(ymax%-ymin%)/MPY%

  let c4%=4<<24
'--

'++
' was main

  let cy%=ymin%
  for py%=0 to MPY%
    let cx%=xmin%
    for px%=0 to MPX%
      let x%=0
      let y%=0
      let iter%=0
      while iter%<=maxiter%
        let x2%=hack.mul(x%,x%)
        let y2%=hack.mul(y%,y%)
        if x2%+y2%>c4% goto breakwhile
        let y%=hack.multimes2(x%,y%)+cy%
        let x%=x2%-y2%+cx%
        let iter%=iter%+1
      end while
breakwhile:
      let cx%=cx%+dx%
      print chr$(iter%+32);
    next px%
    let cy%=cy%+dy%
    print
  next py%
'--

'++
' chr$() (from ersmith)
'
'' this is a bit of a hack for now, until we have
'' a standard string library

dim buf(2) as ubyte

function chr$(x)
  buf(1) = x
  return @buf(1)
end function
'--
$ make mandelbrot32.log
/opt/spin2cpp/src/spin2cpp.basic/build/fastspin -O2 mandelbrot32.bas
Propeller Spin/PASM Compiler 'FastSpin' (c) 2011-2018 Total Spectrum Software Inc.
Version 3.8.8-beta Compiled on: Sep 11 2018
mandelbrot32.bas
|-mandelbrot32hacks.spin
mandelbrot32.pasm
Done.
Program size is 1488 bytes
/opt/parallax/bin/spinsim -b mandelbrot32.binary 2>&1 | tee mandelbrot32.log
!!!!!!!!!!!!!!!"""""""""""""####################################""""""""""""""""
!!!!!!!!!!!!!"""""""""#######################$$$$$$$%'0(%%%$$$$$#####"""""""""""
!!!!!!!!!!!"""""""#######################$$$$$$$$%%%&&(++)++&$$$$$$$######""""""
!!!!!!!!!"""""#######################$$$$$$$$$$%%%%&')*A;/*('&%%$$$$$$#######"""
!!!!!!!!""""#####################$$$$$$$$$$%%%&&&''),AAAAAA@+'&%%%%%$$$$########
!!!!!!!"""####################$$$$$$$$%%%&'())((())*-AAAAAA.+))('&&&&+&%$$######
!!!!!!""###################$$$$$%%%%%%&&&'+.AAA08AAAAAAAAAAAAAAA/+,A//A)%%$#####
!!!!!"################$$$%%%%%%%%%%&&&&')-+7AAAAAAAAAAAAAAAAAAAAAAAAA4(&&%$$####
!!!!"##########$$$$$%%&(,('''''''''''((*-5AAAAAAAAAAAAAAAAAAAAAAAAAAA3+)4&%$$###
!!!!####$$$$$$$$%%%%%&'(*-A1.+/A-4+))**AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA3+'&%$$$##
!!!!#$$$$$$$$$%%%%%%'''++.7AAAAAAAAA9/0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA<6'%%$$$$#
!!!#$$$$$$$%&&&&''().-2.6AAAAAAAAAAAAA>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'&%%$$$$#
!!!379<@AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA2+)'&&%%$$$$#
!!!#$$$$$$$%&&&&''().-2.6AAAAAAAAAAAAA>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'&%%$$$$#
!!!!#$$$$$$$$$%%%%%%'''++.7AAAAAAAAA9/0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA<6'%%$$$$#
!!!!####$$$$$$$$%%%%%&'(*-A1.+/A-4+))**AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA3+'&%$$$##
!!!!"##########$$$$$%%&(,('''''''''''((*-5AAAAAAAAAAAAAAAAAAAAAAAAAAA3+)4&%$$###
!!!!!"################$$$%%%%%%%%%%&&&&')-+7AAAAAAAAAAAAAAAAAAAAAAAAA4(&&%$$####
!!!!!!""###################$$$$$%%%%%%&&&'+.AAA08AAAAAAAAAAAAAAA/+,A//A)%%$#####
!!!!!!!"""####################$$$$$$$$%%%&'())((())*-AAAAAA.+))('&&&&+&%$$######
!!!!!!!!""""#####################$$$$$$$$$$%%%&&&''),AAAAAA@+'&%%%%%$$$$########
!!!!!!!!!"""""#######################$$$$$$$$$$%%%%&')*A;/*('&%%$$$$$$#######"""
!!!!!!!!!!!"""""""#######################$$$$$$$$%%%&&(++)++&$$$$$$$######""""""
!!!!!!!!!!!!!"""""""""#######################$$$$$$$%'0(%%%$$$$$#####"""""""""""
!!!!!!!!!!!!!!!"""""""""""""####################################""""""""""""""""
$ █
Die in BASIC noch unbekannte spinsche "**"-Operation hab ich auf dem Umweg über Spin bereitgestellt.

Edit @20180914-0625-GMT: Graphischer Output des 32-Bit-BASIC-Mandelbrotprogrammes ist samt dafür modifizierten Quellen in einem Nachbarthread zu finden.

----------8<-----{20180914-1523-GMT}----->8----------
Spin to C / C++ / PASM converter version 3.9.1 hat geschrieben:This release fixes various bugs in 3.8.7. It also includes the framework for supporting BASIC in fastspin, but that code is not production ready yet.

fastspin is a command line tool that compiles Spin code to executable PASM code. On P1 it produces LMM code by default; on P2 it produces hubexec code. Because the output is executable instructions rather than Spin bytecodes, the binaries produced by fastspin are larger than the ones produced by the PropTool or openspin, but also much much faster.

spin2cpp is a command line tool to convert Spin code to C++ or C code, which may then be compiled with PropGCC (or other C compilers; in some cases spin2cpp output may be used on a PC or other device).
...also eher Bugfix-Release für den Ast ohne BASIC. Z.B. ist ein fetter Bug für FastSpin-Spin's ASM/ENDASM-Feature gekillt worden.⁽¹⁾

1) An dem ich viel zu lange scheiterte und mich dämlicherweise für viel zu plööt für LMM-PASM hielt, statt einen Fehler zu unterstellen und diesen zu melden, aber das ist ein anderes Drama und nun glücklicherweise Kaffee von Vorgestern!

----------8<-----{20180918-2102-GMT}----->8----------

Es hat sich viel getan in FastSpin-BASIC. Insbesondere gibt es nun umschaltbar einen 16.16-Fixpunkt-Typ und Fließkommazahlen. Normal kompiliert ist "single" ein echter Float, mit "--fixed" kompiliert werden es Fixpunktzahlen mit je 16 Bit für Vor- und Nachkommastellen. Ein paar andere Neuerlichungen machen den "chr$()"-Hack überflüssig, per "const" definierte Konstanten sind hübscher und wie man "let" ausfallen lassen darf hab ich nun auch verinnerlicht... :-)

Code: Alles auswählen

'
' translated to BASIC from mandelbrot16-20180406-fds.spin
'-------------------------------------------------------------------------------

'++
  const xmin = -2.1
  const xmax =  0.7

  const ymin = -1.2
  const ymax =  1.2

  const maxiter = 32

  const MPX = 79 ' 0..79
  const MPY = 24 ' 0..24

  const dx = (xmax-xmin)/MPX
  const dy = (ymax-ymin)/MPY

  const c4 = 4.0 ' square of escape radius
'--

'++
' was main
'
  dim x,y,x2,y2,cx,cy as single
  dim iter as integer

  cy = ymin
  for py = 0 to MPY
    cx = xmin
    for px = 0 to MPX
      x = 0.0
      y = 0.0
      iter = 0
      while iter < maxiter
        x2 = x*x
        y2 = y*y
        if x2+y2 > c4 goto breakwhile
        y = 2.0*x*y+cy
        x = x2-y2+cx
        iter = iter+1
      end while
breakwhile:
      cx = cx+dx
      print \(iter+32);
    next px
    cy = cy+dy
    print
  next py
'--
Noch Fragen, Kienzle?

----------8<-----{20180921-1620-GMT}----->8----------

Code: Alles auswählen

$ /opt/spin2cpp/bin/fastspin 
Propeller Spin/PASM Compiler 'FastSpin' (c) 2011-2018 Total Spectrum Software Inc.
Version 3.9.2 Compiled on: Sep 21 2018
usage: /opt/spin2cpp/bin/fastspin
  [ -h ]              display this help
  [ -L or -I <path> ] add a directory to the include path
  [ -o ]             output filename
  [ -b ]             output binary file format
  [ -e ]             output eeprom file format
  [ -c ]             output only DAT sections
  [ -l ]             output DAT as a listing file
  [ -f ]             output list of file names
  [ -q ]             quiet mode (suppress banner and non-error text)
  [ -p ]             disable the preprocessor
  [ -D <define> ]    add a define
  [ -u ]             ignore for openspin compatibility (unused method elimination always enabled)
  [ -2 ]             compile for Prop2
  [ -O# ]            set optimization level:
          -O0 = no optimization
          -O1 = basic optimization
          -O2 = all optimization
  [ -w ]             compile for COG with Spin wrappers
  [ --code=cog ]     compile for COG mode instead of LMM
  [ --fcache=N ]     set FCACHE size to N (0 to disable)
  [ --fixedreal ]    use 16.16 fixed point in place of floats
...das "-beta" hinter der Versionsnummer verschwand mit den neuen Commits und die Dokumentation wächst deutlich.

----------8<-----{20180921-2121-GMT}----->8----------

Spin to C / C++ / PASM converter version 3.9.2

----------8<-----{20180925-1649-GMT}----->8----------

Spin to C / C++ / PASM converter version 3.9.3

Mehr dazu: http://forums.parallax.com/discussion/c ... nt_1446411

----------8<-----{20180926-1533-GMT}----->8----------

Code: Alles auswählen

$ cat asm.bas
function asmadd(a,b as integer) as integer
  dim r as integer
  asm
    mov r,a
    add r,b
  end asm
  return r
end function

print asmadd(1337,4711)

waitcnt(getcnt()+clkfreq)
$ make asm.log -B
/opt/spin2cpp/bin/fastspin -O2 asm.bas
Propeller Spin/PASM Compiler 'FastSpin' (c) 2011-2018 Total Spectrum Software Inc.
Version 3.9.4 Compiled on: Sep 26 2018
asm.bas
asm.pasm
Done.
Program size is 700 bytes
/opt/parallax/bin/spinsim -b asm.binary 2>&1 | tee asm.log
6048
:mrgreen:

----------8<-----{20181003-0150-GMT}----->8----------

Spin to C / C++ / PASM converter version 3.9.4

Mehr dazu: https://forums.parallax.com/discussion/ ... nt_1447574

----------8<-----{20181015-1745-GMT}----->8----------

Spin to C / C++ / PASM converter version 3.9.5

----------8<-----{20181019-1837-GMT}----->8----------

Spin to C / C++ / PASM converter version 3.9.6

----------8<-----{20181021-2202-GMT}----->8----------

Spin to C / C++ / PASM converter version 3.9.7

----------8<-----{20181027-0018-GMT}----->8----------

Fast noch zu heiß, um es zu erwähnen:
FastSpin-C kann schon fast ein Mandelbrötchen-C-Programm kompilieren.
Aber von mir hab ihr das nicht!?!?!
Klar???

----------8<-----{20181027-1715-GMT}----->8----------
20181027-170405-GMT--mbi-fastspin-bfb3754-binary.png
mbi.c
(898 Bytes) 540-mal heruntergeladen
:mrgreen:

----------8<-----{20181027-1825-GMT}----->8----------

Da kneif mich doch mal jemand!
20181027-181901-GMT--mbf-fastspin-bfb3754-binary.png
mbf.c
(595 Bytes) 538-mal heruntergeladen
Nicht nur Fixpunkt-Brötchen, sondern sogar Fleißkomma-Brötchen klappen schon!

----------8<-----{20181028-1710-GMT}----->8----------

Spin to C / C++ / PASM converter version 3.9.8

Mehr dazu: https://forums.parallax.com/discussion/ ... nt_1451157
Eric hat geschrieben:There's also an undocumented feature which will be obvious to those who've read the source, but isn't ready for prime-time yet so I've left it as an "easter egg". :) (Hint: .bas is no longer the only file extension that's handled specially).
Jetzt ist es also quasi offiziell, was ich oben schon erwähnte. Als großen Bruch irgendwelcher Geheimhaltung hatte ich das nie aufgefaßt, denn die Änderungen in Spin2CPPs Quelltextlagerstätte verfolgen konnte ja nicht nur ich und die ersten Indizien für C lagen dort schon länger herum. Ich schaute dann erst genauer hin, als im Verzeichnis mit den Tests auch C-Quellen auftauchten.

----------8<-----{20181031-0340-GMT}----->8----------
20181031-033010-GMT--FastSpin-C__getting_PROPy.png
\o/

----------8<-----{20181106-1618-GMT}----->8----------

Langsam bekomm ich Routine im Zusammenschmeißen von Spin Objekten und BASIC Hauptprogrammen. Nebenan im GEARigen Thread finden sich zwei Beispiele für das Benutzen der 512x384x1-Monochrom-Graphik in FastSpin-BASIC.

----------8<-----{20181107-1650-GMT}----->8----------

Spin to C / C++ / PASM converter version 3.9.9

Mehr dazu: https://forums.parallax.com/discussion/ ... nt_1452473

----------8<-----{FastSpin!}----->8----------
𝖂𝖎𝖗 𝖐𝖔̈𝖓𝖓𝖊𝖓 𝖆𝖑𝖑𝖊𝖘 𝖆𝖚𝖘𝖘𝖊𝖗 𝖎𝖓 𝕱𝖗𝖚̈𝖍𝖑𝖎𝖓𝖌, 𝕾𝖔𝖒𝖒𝖊𝖗, 𝕳𝖊𝖗𝖇𝖘𝖙 𝖚𝖓𝖉 𝖂𝖎𝖓𝖙𝖊𝖗! – 𝕯𝖊𝖚𝖙𝖘𝖈𝖍𝖑𝖆𝖓𝖉.
"Du willst hier nicht klicken. Dies interessiert Dich nicht." — Yeti.
"DNA is a four letter word!" — Yeti.
Benutzeravatar
yeti
Beiträge: 2300
Registriert: Fr 27. Aug 2010, 14:48
Wohnort: Wrong Planet
Kontaktdaten:

Re: Spin2CPP, FastSpin-Spin, FastSpin-BASIC, FastSpin-C

Beitrag von yeti »

----------8<-----{20181111-1603-GMT}----->8----------

Es wird immer krasser:

Code: Alles auswählen

$ cat main-c.c
#include <stdio.h>

void main(void) {
        printf("Hi from C!\r\n");
}
$ cat main.bas
dim C as class using "main-c.c"

C.main()
$ fastspin -O2 -I /opt/propellerbasics/include/fastspin main.bas
Propeller Spin/PASM Compiler 'FastSpin' (c) 2011-2018 Total Spectrum Software Inc.
Version 3.9.10-beta-6f57b5b Compiled on: Nov 11 2018
main.bas
|-main-c.c
main.pasm
Done.
Program size is 1384 bytes
$ spinsim -b main.binary 
Hi from C!
FastSpin-C braucht noch etwas Zeit auf der Weide, FastSpin-BASIC nähert sich dem Schlachthaus-Alter... ääääääh... der Vergleich is blöd... also FastSpin-BASIC ist kurz vor fertig.

Die Mischbarkeit der diversen Sprachen ist ein nettes Feature! FastSpin-Spin von FastSpin-BASIC aus benutzen hab ich ja schon eifrig praktiziert. Die Idee, das mal mit FastSpin-C zu testen, kam mir erst heute zwischen die Hirnhälften. Offensichtlich sind da noch ein paar andere Mischungen meinerseits ungetestet...

----------8<-----{20181117-1612-GMT}----->8----------


Spin to C / C++ / PASM converter version 3.9.10

Mehr dazu: http://forums.parallax.com/discussion/c ... nt_1454004

----------8<-----{20181206-0516-GMT}----->8----------

Spin to C / C++ / PASM converter version 3.9.11

Mehr dazu: https://forums.parallax.com/discussion/ ... nt_1456991

----------8<-----{20181210-0529-GMT}----->8----------

Spin to C / C++ / PASM converter version 3.9.12

Mehr dazu: https://forums.parallax.com/discussion/ ... nt_1457478

----------8<-----{20181212-1745-GMT}----->8----------

Als Beispiel, wie weit man mit FlexSpins LMM kommt, hatte Eric schon vor Ewiglichkeiten "SimpleSerial.spin" beigelegt. Die essenziellen Bestandteile dessen hab ich mal ziemlich 1:1 in C umgefummelt und es läuft sogar!
:JUBELN

Code: Alles auswählen

$ cat SimpleSerial.c
#include <stdint.h>

int8_t txpin, rxpin;
int32_t baud, txmask, rxmask, bitcycles;

int32_t start(int8_t rx_pin, int8_t tx_pin, /*unused:*/ int32_t mode, int32_t baudrate)
{
  baud = baudrate;
  bitcycles = clkfreq / baudrate;
  txpin = tx_pin;
  txmask = (1<<txpin);
  rxpin = rx_pin;
  rxmask = (1<<rxpin);
  return 1;
}

void tx(int32_t c)
{
  int32_t val, waitcycles;
#ifdef __P2__
  OUTB |= txmask;
  DIRB |= txmask;
#else
  OUTA |= txmask;
  DIRA |= txmask;
#endif
  val = (c | 256) << 1; /* Startbit c Stopbit */
  waitcycles = CNT;
  for(int32_t i=0; i<10; i++) // would a shorter type be faster?
  {
    waitcnt(waitcycles += bitcycles);
#ifdef __P2__
    if (val & 1)
      OUTB |= txmask;
    else
      OUTB &= !txmask;
#else
    if (val & 1)
      OUTA |= txmask;
    else
      OUTA &= !txmask;
#endif
     val >>= 1;
  }
}

void str(const char *s)
{
  int8_t c;
  while( c = *s++ )
    tx(c);
}

int32_t rx(void)
{
  int32_t waitcycles, cycles, mask, val, x;

  mask = rxmask;
  cycles = bitcycles;
  DIRA &= !mask;  // set for input
  // wait for start bit
  do {
    x = INA;
  } while ( x & mask );
  val = 0;
  waitcycles = CNT + (cycles >> 1);  // sync for one half bit
  for( int32_t i=0; i<8; i++ ){
    val >>= 1;
    waitcnt(waitcycles += cycles);
    x = INA;
    if ( x & mask )
      val |= 0x80;
  }
  // wait for stop bit?
  // skip it for now
  // waitpeq(mask, mask, 0)
  
  return val;
}

int32_t stop(void)
{
  waitcnt(clkfreq + cnt);
  return 1;
}


/*
 * test it...
 */
void main(void)
{
  start(31,30,0,19200);

  str("Type something. End using ESC.\r\n\n");

  {
    char c;
    while( (c = rx()) != 27 )
      tx( c );
  }

  stop();
}
$ fastspin -O2 SimpleSerial.c -I /opt/propellerbasics/include/fastspin
Propeller Spin/PASM Compiler 'FastSpin' (c) 2011-2018 Total Spectrum Software Inc.
Version 3.9.13-beta-f68f5b4 Compiled on: Dec 12 2018
SimpleSerial.c
SimpleSerial.pasm
Done.
Program size is 1132 bytes
$ spinsim -b19200 SimpleSerial.binary
Type something. End using ESC.

Hallo Drohnen!
:-)
Entzückt ich bin!

----------8<-----{20181231-2103-GMT}----->8----------


Spin to C / C++ / PASM converter version 3.9.13

Mehr dazu: https://forums.parallax.com/discussion/ ... nt_1459798

----------8<-----{20190107-0230-GMT}----->8----------

Spin to C / C++ / PASM converter version 3.9.14

Mehr dazu: https://forums.parallax.com/discussion/ ... nt_1460441

----------8<-----{20190119-0357-GMT}----->8----------

Spin to C / C++ / PASM converter version 3.9.15

Mehr dazu: https://forums.parallax.com/discussion/ ... nt_1461955

----------8<-----{20190130-0035-GMT}----->8----------

Spin to C / C++ / PASM converter version 3.9.16

Weniger dazu: https://forums.parallax.com/discussion/ ... nt_1462921

----------8<-----{20190203-1320-GMT}----->8----------

Spin to C / C++ / PASM converter version 3.9.17

Jetzt mit Zeilennummern und ":" als Trenner zwischen Befehlen:

Code: Alles auswählen

$ cat numberz.bas
10 print"Totally retro!"
20 let i=i+1 : if i<3 goto 10
30 print"Yo män!"
$ fastspin numberz.bas 
Propeller Spin/PASM Compiler 'FastSpin' (c) 2011-2019 Total Spectrum Software Inc.
Version 3.9.17 Compiled on: Feb  3 2019
numberz.bas
numberz.pasm
Done.
Program size is 1624 bytes
$ spinsim -b numberz.binary 
Totally retro!
Totally retro!
Totally retro!
Yo män!
...mir hat beides nicht gefehlt!
:P

----------8<-----{20190204-0505-GMT}----->8----------
[url]https://forums.parallax.com/discussion/comment/1463539/#Comment_1463539[/url] Eric hat geschrieben:Doing a kind of CMM mode (where we use PASM instructions, but compressed) should be very easy in fastspin; again, I just haven't had time to get to it. That would just be a slight variation of the existing ASM backend. For real bytecode like the Spin2 interpreter we'd want a new backend. I've tried to make the compiler modular enough to make that possible (there are already backends to produce C code and ASM) but I'm sure there will be details that'll need working out.
Nett, daß diese Gedanken noch nicht vom Tisch sind!
Von einem solchen CMM-Codegenerator würden in FastSpin sofort allen Sprachen profitieren und FlexSpin vielleicht sogar (wieder, fast) die vom normalen Spin bekannte Codedichte erreichen.
Schaunwermal, was da noch kommt... ;-)

----------8<-----{20190210-1403-GMT}----->8----------

Jetzt ist das Trio Zeilennummern, GOTO, GOSUB komplett!

Spin to C / C++ / PASM converter version 3.9.18

----------8<-----{20190211-1404-GMT}----->8----------

Spin to C / C++ / PASM converter version 3.9.19

Mehr dazu: https://forums.parallax.com/discussion/ ... nt_1464232

----------8<-----{20190211-1745-GMT}----->8----------

Anschnallen vorm Lesen: https://forums.parallax.com/discussion/ ... nt_1464234

...das ist mehr als nur eine kleine Neuerung.

----------8<-----{20190216-1600-GMT}----->8----------

Spin to C / C++ / PASM converter version 3.9.20

Im Forum: https://forums.parallax.com/discussion/ ... nt_1464765

----------8<-----{20190223-1749-GMT}----->8----------

Spin to C / C++ / PASM converter version 3.9.21

Im Forum: https://forums.parallax.com/discussion/ ... nt_1465603

----------8<-----{20190305-1844-GMT}----->8----------

Spin to C / C++ / PASM converter version 3.9.22

Im Forum: https://forums.parallax.com/discussion/ ... nt_1466325

----------8<-----{20190317-1113-GMT}----->8----------

Spin to C / C++ / PASM converter version 3.9.23

----------8<-----{20190324-2040-GMT}----->8----------

Spin to C / C++ / PASM converter version 3.9.24

----------8<-----{20190415-1100-ZELZ}----->8----------

Spin to C / C++ / PASM converter version 3.9.25

Im Forum: https://forums.parallax.com/discussion/ ... nt_1469036

----------8<-----{20190506-2350-ZELZ}----->8----------

Spin to C / C++ / PASM converter version 3.9.26

Im Forum: https://forums.parallax.com/discussion/ ... nt_1470154

----------8<-----{20190528-0457-ZELZ}----->8----------

Spin to C / C++ / PASM converter version 3.9.27

Im Forum: https://forums.parallax.com/discussion/ ... nt_1471165

----------8<-----{20190801-1626-ZELZ}----->8----------

Spin to C / C++ / PASM converter version 3.9.28

Im Forum: https://forums.parallax.com/discussion/ ... nt_1474905

----------8<-----{20190814-1518-ZELZ}----->8----------

Spin to C / C++ / PASM converter version 3.9.29

Im Forum: https://forums.parallax.com/discussion/ ... nt_1475992

----------8<-----{20190913-0237-ZELZ}----->8----------

Spin2Cpp-v3.9.30 erschien mit Spin2GUI-v3.9.30 gebündelt, aber Eric vergaß, es alleine anzukündigen. Und da Klickikram immer beliebter wird, verweis ich diesmal auch auf:

Spin2gui version 3.9.31

Spin to C / C++ / PASM converter version 3.9.31

Im Forum: https://forums.parallax.com/discussion/ ... nt_1477895

----------8<-----{Fortsetzung wird fortgesetzt...}----->8----------
𝖂𝖎𝖗 𝖐𝖔̈𝖓𝖓𝖊𝖓 𝖆𝖑𝖑𝖊𝖘 𝖆𝖚𝖘𝖘𝖊𝖗 𝖎𝖓 𝕱𝖗𝖚̈𝖍𝖑𝖎𝖓𝖌, 𝕾𝖔𝖒𝖒𝖊𝖗, 𝕳𝖊𝖗𝖇𝖘𝖙 𝖚𝖓𝖉 𝖂𝖎𝖓𝖙𝖊𝖗! – 𝕯𝖊𝖚𝖙𝖘𝖈𝖍𝖑𝖆𝖓𝖉.
"Du willst hier nicht klicken. Dies interessiert Dich nicht." — Yeti.
"DNA is a four letter word!" — Yeti.
Benutzeravatar
yeti
Beiträge: 2300
Registriert: Fr 27. Aug 2010, 14:48
Wohnort: Wrong Planet
Kontaktdaten:

Re: Spin2CPP, FastSpin (FlexSpin, FlexBASIC, FlexC)

Beitrag von yeti »

----------8<-----{20190919-1702-ZELZ}----->8----------

K+K - Kreise und Kwadrate

Nach https://hive-project.de/board/viewtopic ... 981#p16981 musste ich auch mal in C damit spielen:
K+K - Kreise und Kwadrate im 16x16-Raster.
K+K - Kreise und Kwadrate im 16x16-Raster.
Das kleine Geständnis zwischendurch: Ich hab das bisher nur im Simulator rennen lassen, denn ich muß meinem letzten Lieblings-Monoprop erst einen VGA-Anschluß bauen und der Hive ist einfach zu gut verpackt weggeräumt.
n16.zip
Nimm die Soße, Lukas!
(57.04 KiB) 467-mal heruntergeladen
Ein Ende ohne Cliffhanger!
Einfach so!

----------8<-----{20190920-1236-ZELZ}----->8----------

Ich glaub, ich sollt lamsan mal kappieren, wie man "Text-Terminals" baut und ob das auch mit 16x16 als Zeichengröße geht... ;-)

SANTA!!!
Wo bleibt der 100-Stunden-Tag?

----------8<-----{20190922-1712-ZELZ}----->8----------

Die Schleife am Ende hab ich im geheimen FastSpin-Rezeptebuch dann sogar noch etwas umgestrickt:

Code: Alles auswählen

for( uint32_t t=CNT ;; waitcnt(t+=CLKFREQ) )
  randtile(rand()%(vga.hp>>4),rand()%(vga.vp>>4),rand()&1);
Dies als "ab CNT dauerhaft (weil keine Abbruchbedingung) und in CLKFREQ-Abständen" zu lesen macht es fast schon zu Coding-Lyrik. Man darf es häßlicher finden, aber daß dies legitimes C ist sollt man schon irgendwann mal zur Kenntnis genommen haben.

----------8<-----{Echt jetzt?}----->8----------
Zuletzt geändert von yeti am So 22. Sep 2019, 16:12, insgesamt 1-mal geändert.
𝖂𝖎𝖗 𝖐𝖔̈𝖓𝖓𝖊𝖓 𝖆𝖑𝖑𝖊𝖘 𝖆𝖚𝖘𝖘𝖊𝖗 𝖎𝖓 𝕱𝖗𝖚̈𝖍𝖑𝖎𝖓𝖌, 𝕾𝖔𝖒𝖒𝖊𝖗, 𝕳𝖊𝖗𝖇𝖘𝖙 𝖚𝖓𝖉 𝖂𝖎𝖓𝖙𝖊𝖗! – 𝕯𝖊𝖚𝖙𝖘𝖈𝖍𝖑𝖆𝖓𝖉.
"Du willst hier nicht klicken. Dies interessiert Dich nicht." — Yeti.
"DNA is a four letter word!" — Yeti.
Benutzeravatar
yeti
Beiträge: 2300
Registriert: Fr 27. Aug 2010, 14:48
Wohnort: Wrong Planet
Kontaktdaten:

Re: Spin2CPP, FastSpin (FlexSpin, FlexBASIC, FlexC)

Beitrag von yeti »

----------8<-----{20190921-2257-GMT}----->8----------
[url=https://forums.parallax.com/discussion/comment/1478607/#Comment_1478607]Alldieweil in einem unscheinbaren Forum jenseits einer etwas größeren Pfütze:[/url] ersmith hat geschrieben: I've posted new versions of fastspin and the GUI for it. That gui is now called "FlexGUI" instead of "spin2gui" to better reflect the multi-language nature of it.

The current versions of both are 3.9.32, and they are available at:

https://www.patreon.com/totalspectrum
https://www.github.com/totalspectrum/flexgui/releases
https://www.github.com/totalspectrum/spin2cpp/releases

The "flexgui.zip" file contains everything you'll need for development on Windows, including fastspin.

This new release supports the new silicon via a "-2b" flag. The old silicon is still available as "-2a". Just plain "-2" selects the most common P2 variant, which is still "2a" but eventually will become "2b". FlexGUI has a button to switch between these.

Other changes are some more editor configuration options in FlexGUI, better handling of loc and jmps in PASM within Spin objects, and some C library fixes.
Das war's auch schon!

----------8<-----{Na sowas!}----->8----------
𝖂𝖎𝖗 𝖐𝖔̈𝖓𝖓𝖊𝖓 𝖆𝖑𝖑𝖊𝖘 𝖆𝖚𝖘𝖘𝖊𝖗 𝖎𝖓 𝕱𝖗𝖚̈𝖍𝖑𝖎𝖓𝖌, 𝕾𝖔𝖒𝖒𝖊𝖗, 𝕳𝖊𝖗𝖇𝖘𝖙 𝖚𝖓𝖉 𝖂𝖎𝖓𝖙𝖊𝖗! – 𝕯𝖊𝖚𝖙𝖘𝖈𝖍𝖑𝖆𝖓𝖉.
"Du willst hier nicht klicken. Dies interessiert Dich nicht." — Yeti.
"DNA is a four letter word!" — Yeti.
Benutzeravatar
yeti
Beiträge: 2300
Registriert: Fr 27. Aug 2010, 14:48
Wohnort: Wrong Planet
Kontaktdaten:

Re: Spin2CPP, FastSpin (FlexSpin, FlexBASIC, FlexC)

Beitrag von yeti »

----------8<-----{20190922-2343-ZELZ}----->8----------

Es ist zum Melkschemel an Mäuse stellen ... usw! Ich verdaddel mich bei der 8x8-Variante der obigen Spielerei in FlexSPIN entweder konsequent oder bin da einem Käfer auf der Spur. Schaunwermal, was sich davon irgendwann später mal als zutreffend erweist.

Um nicht ganz wie verschusselt dazustehen, mußte ich mir in FlexC beweisen, daß ich nicht ganz auf dem Holzweg bin:

KKUKK - kleine Kreise und kleine Kwadrate
n8.png
n8.zip
(59.23 KiB) 451-mal heruntergeladen
Und jetzt erstmal horizontalisieren, statt weiterer Fehlersuche...

----------8<-----{20190923-0952-ZELZ}----->8----------

Hmmm... auch die in https://hive-project.de/board/viewtopic ... 981#p16981 erwähnte ClassicSPIN-Version zeigt mit FastSpin kompiliert das selbe Fehlverhalten wie mein FlexSPIN-Neuschrieb. Ich fühl mich also dann doch etwas rehabilitiert.

----------8<-----{20190923-1018-ZELZ}----->8----------

Und noch krasser: Das unveränderte "nostalgie3.spin" von neulich, frisch mit OpenSpin kompiliert, will heute auch nicht.

Gear hat Launen?
Wetterabhängig oder was?
Aber die FlexC-Version läuft auch heute!
Wer bitte soll das verstehen?

Ich brauch erstmal Pause!

----------8<-----{20190923-1649-ZELZ}----->8----------

...und ein paar Stunden später liefen dann die ClassicSPIN- und FlexSPIN-Bug-Umzingel-Testprogramme wieder in Gear als wäre nienicht je was gewesen. Aber meine Laune, die FlexSPIN-Variante des Truchet-Tiles-Beispieles zu schnitzen ist noch nicht wieder zurückgekehrt. Mit diesem Bug hat mich Gear schon mehrfach geärgert, aber da das bislang nicht mehrfach beim selben Programm auftrat und wieder verschwand hatte ich das noch nicht als Gear-Bug eingestuft.

Auf die FlexBASIC-Variante schielte ich auch, aber derzeit seh ich im FlexBASIC-Standard-Zutaten-Regal nur "rnd()" für Fließkommazufall. "rand()" aus der C-schen "stdlib.h" läßt sich sicher auch irgendwie in FlexBASIC benutzen, aber das muß ich erst noch vertüftelieren.

----------8<-----{20190924-0612-GMT}----->8----------

Code: Alles auswählen

$ cat pseudorandom-integer.bas 
dim stdlib as class using "stdlib.h"

for i=1 to 3
  print stdlib.rand()
next i
$ fastspin -q -O2 pseudorandom-integer.bas 
$ spinsim -b pseudorandom-integer.binary 
16807
282475249
1622650073
Ach... ist DAS wirklich ALLES??? :-)

...aber der Bock auf Truchet-Tiles in FlexBASIC läßt noch auf sich warten.

Ommmmmmmmm...

----------8<-----{ZZZzzzzzz.........}----->8----------
𝖂𝖎𝖗 𝖐𝖔̈𝖓𝖓𝖊𝖓 𝖆𝖑𝖑𝖊𝖘 𝖆𝖚𝖘𝖘𝖊𝖗 𝖎𝖓 𝕱𝖗𝖚̈𝖍𝖑𝖎𝖓𝖌, 𝕾𝖔𝖒𝖒𝖊𝖗, 𝕳𝖊𝖗𝖇𝖘𝖙 𝖚𝖓𝖉 𝖂𝖎𝖓𝖙𝖊𝖗! – 𝕯𝖊𝖚𝖙𝖘𝖈𝖍𝖑𝖆𝖓𝖉.
"Du willst hier nicht klicken. Dies interessiert Dich nicht." — Yeti.
"DNA is a four letter word!" — Yeti.
Benutzeravatar
yeti
Beiträge: 2300
Registriert: Fr 27. Aug 2010, 14:48
Wohnort: Wrong Planet
Kontaktdaten:

Re: Spin2CPP, FastSpin (FlexSpin, FlexBASIC, FlexC)

Beitrag von yeti »

----------8<-----{20190926-1725-ZELZ}----->8----------

Ich Kopfschüttele noch immer...

Die FlexSPIN-Versionen der Fliesenlegerei rennen oder humpeln soweit in Gear. Die 8x8-Pixel schluckauft manchmal, aber noch konnte ich einen vergleichbaren Effekt nicht bei der 16x16-Variante entdecken.

Code: Alles auswählen

dat
  cg
    word %0_0_0_1_1_0_0_0_0_0_0_1_1_0_0_0, %0_0_0_1_1_0_0_0_0_0_0_1_1_0_0_0
    word %0_0_0_0_1_1_0_0_0_0_1_1_0_0_0_0, %0_0_0_1_1_0_0_0_0_0_0_1_1_0_0_0
    word %0_0_0_0_0_1_1_0_0_1_1_0_0_0_0_0, %0_0_0_1_1_0_0_0_0_0_0_1_1_0_0_0
    word %1_0_0_0_0_0_1_1_1_1_0_0_0_0_0_1, %1_1_1_1_1_0_0_0_0_0_0_1_1_1_1_1
    word %1_1_0_0_0_0_0_1_1_0_0_0_0_0_1_1, %1_1_1_1_1_0_0_0_0_0_0_1_1_1_1_1
    word %0_1_1_0_0_0_0_0_0_0_0_0_0_1_1_0, %0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0
    word %0_0_1_1_0_0_0_0_0_0_0_0_1_1_0_0, %0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0
    word %0_0_0_1_1_0_0_0_0_0_0_1_1_0_0_0, %0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0
    word %0_0_0_1_1_0_0_0_0_0_0_1_1_0_0_0, %0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0
    word %0_0_1_1_0_0_0_0_0_0_0_0_1_1_0_0, %0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0
    word %0_1_1_0_0_0_0_0_0_0_0_0_0_1_1_0, %0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0
    word %1_1_0_0_0_0_0_1_1_0_0_0_0_0_1_1, %1_1_1_1_1_0_0_0_0_0_0_1_1_1_1_1
    word %1_0_0_0_0_0_1_1_1_1_0_0_0_0_0_1, %1_1_1_1_1_0_0_0_0_0_0_1_1_1_1_1
    word %0_0_0_0_0_1_1_0_0_1_1_0_0_0_0_0, %0_0_0_1_1_0_0_0_0_0_0_1_1_0_0_0
    word %0_0_0_0_1_1_0_0_0_0_1_1_0_0_0_0, %0_0_0_1_1_0_0_0_0_0_0_1_1_0_0_0
    word %0_0_0_1_1_0_0_0_0_0_0_1_1_0_0_0, %0_0_0_1_1_0_0_0_0_0_0_1_1_0_0_0

con
  tiles = vga#xtiles * vga#ytiles

obj
  vga : "VGA_512x384_Bitmap.spin"
  lib : "stdlib.h"

var
  long sync
  word wordmap[vga#vp * vga#hp >> 4]
  word colors[tiles]

pub main | x, y
  vga.start(16, @colors, @wordmap, @sync)
  wordfill(@colors,%001100_00_010101_00,tiles)

  repeat y from 0 to 23
    repeat x from 0 to 31
      randtile(x, y)

  repeat
    randtile(lib.rand // 32, lib.rand // 24)

pri randtile(x, y) | c, p
  p := y << 9 + x
  c := @cg + (lib.rand & 2)
  repeat 16
    wordmap[p \ p + 32] := word[c \ c + 4]
...liefert...
truchet-tiles-16x16-vga-512x384x1.spin.png
...und afglitscht bislang nicht.

Code: Alles auswählen

dat
  cg
    byte %0_0_0_1_1_0_0_0, %0_0_0_1_1_0_0_0
    byte %0_0_0_1_1_0_0_0, %0_0_0_1_1_0_0_0
    byte %0_0_1_1_0_0_0_0, %0_0_0_0_1_1_0_0
    byte %1_1_1_0_0_0_1_1, %1_1_0_0_0_1_1_1
    byte %1_1_0_0_0_1_1_1, %1_1_1_0_0_0_1_1
    byte %0_0_0_0_1_1_0_0, %0_0_1_1_0_0_0_0
    byte %0_0_0_1_1_0_0_0, %0_0_0_1_1_0_0_0
    byte %0_0_0_1_1_0_0_0, %0_0_0_1_1_0_0_0

con
  tiles = vga#xtiles * vga#ytiles

obj
  vga : "VGA_512x384_Bitmap.spin"
  lib : "stdlib.h"

var
  long sync
  byte bytemap[vga#vp * vga#hp >> 3]
  word colors[tiles]

pub main | x, y
  vga.start(16, @colors, @bytemap, @sync)
  wordfill(@colors,%001100_00_010101_00,tiles)

  repeat y from 0 to 47
    repeat x from 0 to 63
      randtile(x, y)

  repeat
    randtile(lib.rand // 64, lib.rand // 48)

pri randtile(x, y) | c, p
  p := y << 9 + x
  c := @cg + (lib.rand & 1)
  repeat 8
    bytemap[p \ p + 64] := byte[c \ c + 2]
...schluckauft manchmal...
truchet-tiles-8x8-vga-512x384x1-glitch.spin.png
...aber fängt sich dann auch von selber wieder:
truchet-tiles-8x8-vga-512x384x1.spin.png
Hier der aktuëlle Krimskram:
truchet-tiles-spin.zip
(196.26 KiB) 428-mal heruntergeladen
Ich hab mittlerweile Muskelkater vom Kopfschütteln, aber werd es im Zweifel dennoch nicht lassen können, in Kürze (wo liegt das eigentlich?) auch noch die FlexBASIC-Beispiele hierfür zu dengeln.

...und bis ich mehr Informationen habe bleibe ich bei der Theorie, daß es sich um Gear-Schluckauf handelt.

----------8<-----{20191004-0715-ZELZ}----->8----------

Nach technischen Problemen (Display) mit meinem bislangigen Lieblings-Not-eBook (und ein paar Tagen mit einem Oldtimer als Ersatz) ist nun das Ersatzgrät da und leicht (~11%) schneller und die gggGG (ganz gemeinen graphischen Gear-Glitschereien) sehen nur sehr ähnlich, aber nicht richtig identisch aus. Dies wohlgemerkt ohne Änderungen am Quellcode und somit identischem Propellercode-Binary. Ich denke, die Wahrscheinlichkeit, daß es sich um ein vom Timing abhängiges Gear-Problem handelt ist somit gestiegen.

----------8<-----{In seinem nudeligen Namen: Pasta und Ramen!}----->8----------
𝖂𝖎𝖗 𝖐𝖔̈𝖓𝖓𝖊𝖓 𝖆𝖑𝖑𝖊𝖘 𝖆𝖚𝖘𝖘𝖊𝖗 𝖎𝖓 𝕱𝖗𝖚̈𝖍𝖑𝖎𝖓𝖌, 𝕾𝖔𝖒𝖒𝖊𝖗, 𝕳𝖊𝖗𝖇𝖘𝖙 𝖚𝖓𝖉 𝖂𝖎𝖓𝖙𝖊𝖗! – 𝕯𝖊𝖚𝖙𝖘𝖈𝖍𝖑𝖆𝖓𝖉.
"Du willst hier nicht klicken. Dies interessiert Dich nicht." — Yeti.
"DNA is a four letter word!" — Yeti.
Benutzeravatar
yeti
Beiträge: 2300
Registriert: Fr 27. Aug 2010, 14:48
Wohnort: Wrong Planet
Kontaktdaten:

Re: Spin2CPP, FastSpin (FlexSpin, FlexBASIC, FlexC)

Beitrag von yeti »

----------8<-----{20191005-0238-ZELZ}----->8----------

FlexGUI version 4.0.0 preview release

Das entgültige 4.0.0-Release ist vermutlich nimmer weit und der Versionssprung in der linkesten Ziffer wird vermutlich schon etwas zu bedeuten haben. Ich bau mir das entsprechende FastSpin mal ohne GUI aus den GIT-Beständen und spiel etwas damit.

----------8<-----{In seinem nudeligen Namen: Pasta und Ramen!}----->8----------
𝖂𝖎𝖗 𝖐𝖔̈𝖓𝖓𝖊𝖓 𝖆𝖑𝖑𝖊𝖘 𝖆𝖚𝖘𝖘𝖊𝖗 𝖎𝖓 𝕱𝖗𝖚̈𝖍𝖑𝖎𝖓𝖌, 𝕾𝖔𝖒𝖒𝖊𝖗, 𝕳𝖊𝖗𝖇𝖘𝖙 𝖚𝖓𝖉 𝖂𝖎𝖓𝖙𝖊𝖗! – 𝕯𝖊𝖚𝖙𝖘𝖈𝖍𝖑𝖆𝖓𝖉.
"Du willst hier nicht klicken. Dies interessiert Dich nicht." — Yeti.
"DNA is a four letter word!" — Yeti.
Benutzeravatar
yeti
Beiträge: 2300
Registriert: Fr 27. Aug 2010, 14:48
Wohnort: Wrong Planet
Kontaktdaten:

Re: Spin2CPP, FastSpin (FlexSpin, FlexBASIC, FlexC)

Beitrag von yeti »

----------8<-----{20191005-0442-ZELZ}----->8----------

Ich konnt's nicht lassen!

Das im OpenSpin-Thread erwähnte Hybrid-FastSpin/OpenSpin-Testprogramm, dessen im ersten Anlauf nicht Funktionieren zur Ersatzspielerei mit den reinen OpenSpin-Truchet-Tiles führte ist nun doch am Rennen und ich weiß sogar, was damals fehlte: Das __cognew ***hust!***, echt peinlich!

Code: Alles auswählen

$ cat hybrid-tx.spin 
''
'' tx only uart - pin and baud hardcoded
''
CON
  txpin  = 30
  baud   = 115200
  txmask = 1 << txpin

VAR
  long t_fullbit

PUB start
  t_fullbit := clkfreq / baud
  OUTA      |= txmask                   ' line idle = 1
  DIRA      |= txmask                   ' set for output

PUB stop                                ' to complete the start/stop duality

PUB tx(c) | t_next
  c := (c | 256) << 1                   ' 1_dddddddd_0
  t_next := CNT                         ' remember now
  repeat 10
     if c & 1
       OUTA |= txmask
     else
       OUTA &= !txmask
     c >>= 1
     waitcnt(t_next += t_fullbit)       ' until old t_next plus a bit's duration

Code: Alles auswählen

$ fastspin -O2 -w hybrid-tx.spin 
Propeller Spin/PASM Compiler 'FastSpin' (c) 2011-2019 Total Spectrum Software Inc.
Version 4.0.0-beta-317bfbe5 Compiled on: Oct  5 2019
hybrid-tx.spin

Code: Alles auswählen

$ ls -l hybrid-tx.cog.spin 
-rw-r--r-- 1 yeti yeti 6680 Oct  5 02:28 hybrid-tx.cog.spin

Code: Alles auswählen

$ cat hybrid-tx-test.spin 
con
  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000

obj
  out : "hybrid-tx.cog.spin"

pub main
  out.__cognew
  out.start

  repeat 3
    str(string("Hello Spin!", 13, 10))

  out.__cogstop

pub str(s) | c
  repeat while c := byte[s++]
    out.tx(c)

Code: Alles auswählen

$ openspin -u hybrid-tx-test.spin 
Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2018 Parallax Inc. DBA Parallax Semiconductor.
Version 1.00.81 Compiled on Jul 15 2019 17:50:54
Compiling...
hybrid-tx-test.spin
|-hybrid-tx.cog.spin
Done.
Unused Method Elimination:
    2 methods removed
    0 objects removed
   28 bytes saved
--------------------------
Program size is 656 bytes

Code: Alles auswählen

$ spinsim -b hybrid-tx-test.binary 
Hello Spin!
Hello Spin!
Hello Spin!
Die von FastSpin kompilierte Senderoutine wird als in einem eigenen Cog laufenden Object nach CogPASM übersetzt und mit passendem Klebstoffcode versehen, um dies von klassischem Spin aus aufzurufen. Mehr dazu in FastSpins Dokumentation: https://github.com/totalspectrum/spin2c ... n-wrappers

Das Testprogramm wird von OpenSpin kompiliert und bindet den durch FastSpin gebackenen hybrid-tx.cog.spin-Code als Objekt ein.

Wie schnell die so gestrickte Nur-Senden-UART maximal plappern kann, hab ich nicht ausgetestet, 115200 Baud finde ich schon nett genug für ein paar Zeilen durch FastSpin geschubsten Spin-Code.

----------8<-----{20191005-0441-ZELZ}----->8----------
𝖂𝖎𝖗 𝖐𝖔̈𝖓𝖓𝖊𝖓 𝖆𝖑𝖑𝖊𝖘 𝖆𝖚𝖘𝖘𝖊𝖗 𝖎𝖓 𝕱𝖗𝖚̈𝖍𝖑𝖎𝖓𝖌, 𝕾𝖔𝖒𝖒𝖊𝖗, 𝕳𝖊𝖗𝖇𝖘𝖙 𝖚𝖓𝖉 𝖂𝖎𝖓𝖙𝖊𝖗! – 𝕯𝖊𝖚𝖙𝖘𝖈𝖍𝖑𝖆𝖓𝖉.
"Du willst hier nicht klicken. Dies interessiert Dich nicht." — Yeti.
"DNA is a four letter word!" — Yeti.
Benutzeravatar
yeti
Beiträge: 2300
Registriert: Fr 27. Aug 2010, 14:48
Wohnort: Wrong Planet
Kontaktdaten:

Re: Spin2CPP, FastSpin (FlexSpin, FlexBASIC, FlexC)

Beitrag von yeti »

----------8<-----{20191023-1437-GMT}----->8----------

FlexGUI version 4.0.0 final release
Spin / BASIC to C / C++ / PASM converter version 4.0.0

Mehr (oder weniger) dazu:
https://forums.parallax.com/discussion/ ... nt_1480355
https://forums.parallax.com/discussion/ ... nt_1480357

----------8<-----{20191025-2131-GMT}----->8----------

FlexGUI version 4.0.1
Spin / BASIC to C / C++ / PASM converter version 4.0.1

----------8<-----{Widerstand ist zwecklos!}----->8----------
Zuletzt geändert von yeti am Fr 25. Okt 2019, 22:31, insgesamt 1-mal geändert.
𝖂𝖎𝖗 𝖐𝖔̈𝖓𝖓𝖊𝖓 𝖆𝖑𝖑𝖊𝖘 𝖆𝖚𝖘𝖘𝖊𝖗 𝖎𝖓 𝕱𝖗𝖚̈𝖍𝖑𝖎𝖓𝖌, 𝕾𝖔𝖒𝖒𝖊𝖗, 𝕳𝖊𝖗𝖇𝖘𝖙 𝖚𝖓𝖉 𝖂𝖎𝖓𝖙𝖊𝖗! – 𝕯𝖊𝖚𝖙𝖘𝖈𝖍𝖑𝖆𝖓𝖉.
"Du willst hier nicht klicken. Dies interessiert Dich nicht." — Yeti.
"DNA is a four letter word!" — Yeti.
Antworten