Code: Alles auswählen
{{HIVE-BASIC
Jeder Befehl ist immer 2 long's lang.
Der Programmcode beginnt ab adresse 0 und endet bei 7CFF das sind genau 4000 Befehle.
Alle 32 Strings sind 255 + 0x00 lang davon sind genau 26 direckt ansprechbar der rest ist internen Funktionen vorbehalten
prog.long[0] 1.long
' = byte[0]+byte[1] Befehl
' = byte[2]+byte[3] Argument 1
prog.long[4] 2.long
' = byte[4]+byte[5] Argument 2 + als 32Bit Argument
' = byte[6]+byte[7] Argument 3 +
prog.long[8]...
0 1 2 3 4 5 6 7 8 9 A B C D E F
long x,x, x,x, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0
Variabeln sind immer ein long lang egal was für ein Typ sich dahinter verbirgt.
bit1.long[7D00]
'a b c d e f g h i j k l m n o p q r s t u v w x y z (interne Variabeln oder Zeiger)
long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0
bit8.long[7D80]
'a b c d e f g h i j k l m n o p q r s t u v w x y z
long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0
bit16.long[7E00]
'a b c d e f g h i j k l m n o p q r s t u v w x y z
long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0
bit32.long[7E80]
'a b c d e f g h i j k l m n o p q r s t u v w x y z
long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0
text.long[7F00]
'a b c d e f g h i j k l m n o p q r s t u v w x y z (Zeiger auf Externen Ram jede Variable=255 Byte)
long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0
frei.long[7F80]...
boot.long[7FE8]...[7FF7]
Dateiname des zu ladenden Programm's (8 + . + 3 + 0x00) = 13 Bytes
addr.long[7FF8]
Adresse des Programmspeichers dient zur syncronisation der COG's
1.) Adresse lesen
2.) Abarbeiten
ja Neue adresse schreiben
nein warten auf neue Adresse
status.long[7FFC]
Sreuerregiste zum steuern der Runtimmodule
>0 = Stop
0 = Go
}}
CON
_clkmode = xtal1+pll16x
_xinfreq = 5_000_000
PUB main|a
long[$1FFF]:=$FFFFFFFF 'Stop all Runtimes
ifnot ini
reboot
repeat a from $7F00 to $7FFF
byte[a]:=0 'Speicher löschen
long[$7FFC]:=$7F7FF7F7 'Ini Runtime load von SD-Karte der Dateiname muss vorher in $1FF0 eingetragen werden
long[$7FF8]:=$7f00 'adresse verbiegen
'*********************************************************************************************************************
long[$7f00]:=$01020000 'Test CODE
long[$7f04]:=$33323130 'Test CODE
'*********************************************************************************************************************
long[$7ff8]:=$00007654 'CODE stop
long[$7ffc]:=$FEDCBA98 'CODE
long[$7FFC]:=0 ' Start test
cogstop(cogid) ' Kill Spinn könnte vom HBASIC gestartet werden
PRI ini
if not cognew(@runtime, 0) + 1
return false
return TRUE
DAT{{Runtime COG***********************************************************************************}}
runtime
org 0
' ---------------------------------------------------------------------
INI0
rdlong temp1, stat 'status laden
cmp temp1, h7F7FF7F7 wz
if_z jmp #m0
jmp #INI0 'Test auf inifreigabe ><h7F7FF7F7 = Stop =h7F7FF7F7 = Start
' ---------------------------------------------------------------------
m0 ' Load Programm vom externen Ram
' ---------------------------------------------------------------------
RESTART ' ini SYSTEM
mov line, h00000000
' ---------------------------------------------------------------------
TLOOP
wrlong line, areg 'neuen Linezeiger schreiben
' ---------------------------------------------------------------------
RTLOOP
rdlong temp1, stat 'status laden
cmp temp1, h00000000 wz
if_nz jmp #RTLOOP 'Test auf startfreigabe >0 = Stop =0 = Start
rdlong line, areg 'Linezeiger laden
' ---------------------------------------------------------------------
rdlong code, line 'Code und Arg1 laden
mov arg1, code '
shr code, $10
and arg1, h0000ffff
add line, h00000004
rdlong arg23, line 'Arg2 und Arg3 Laden
mov arg2, arg23 '
mov arg3, arg23 '
shr arg2, $10
and arg3, h0000ffff
add line, h00000004
' ---------------------------------------------------------------------
cmp code, T0000 wz 'STOP
if_z jmp #J0000
cmp code, T0001 wz 'END
if_z jmp #J0001
cmp code, T0002 wz 'GOTO
if_z jmp #J0002
' TOK-CODE Senden an Bellatrix ---------------------------------------------------------
cmp code, T0100 wz 'write_Bellatrix_word+long
if_z jmp #J0100
cmp code, T0101 wz 'write_Bellatrix_byte+long
if_z jmp #J0101
cmp code, T0102 wz 'write_Bellatrix_long
if_z jmp #J0102
cmp code, T0103 wz 'write_Bellatrix_byte+word
if_z jmp #J0103
cmp code, T0104 wz 'write_Bellatrix_lword
if_z jmp #J0104
cmp code, T0105 wz 'write_Bellatrix_byte
if_z jmp #J0105
' Variabel Senden an Bellatrix ---------------------------------------------------------------------
cmp code, T0106 wz 'write_Bellatrix_long Variabel_long
if_z jmp #J0106
cmp code, T0107 wz 'write_Bellatrix_byte+word Variabel_long
if_z jmp #J0107
cmp code, T0108 wz 'write_Bellatrix_word Variabel_long
if_z jmp #J0108
cmp code, T0109 wz 'write_Bellatrix_byte Variabel_long
if_z jmp #J0109
' String Senden an Bellatrix ---------------------------------------------------------------------
cmp code, T010A wz 'write_Bellatrix_byte Variabel_byte
if_z jmp #J010A
' TOK-CODE Senden an Administra -----------------------------------------------------
cmp code, T0110 wz 'write_Bellatrix_word+long
if_z jmp #J0110
cmp code, T0111 wz 'write_Bellatrix_byte+long
if_z jmp #J0111
cmp code, T0112 wz 'write_Bellatrix_long
if_z jmp #J0112
cmp code, T0113 wz 'write_Bellatrix_byte+word
if_z jmp #J0113
cmp code, T0114 wz 'write_Bellatrix_lword
if_z jmp #J0114
cmp code, T0115 wz 'write_Bellatrix_byte
if_z jmp #J0115
' Variabel Senden an Administra --------------------------------------------------------------------
cmp code, T0116 wz 'write_Bellatrix_long Variabel_long
if_z jmp #J0116
cmp code, T0117 wz 'write_Bellatrix_byte+word Variabel_long
if_z jmp #J0117
cmp code, T0118 wz 'write_Bellatrix_word Variabel_long
if_z jmp #J0118
cmp code, T0119 wz 'write_Bellatrix_byte Variabel_long
if_z jmp #J0119
' String Senden an Administra --------------------------------------------------------------------
cmp code, T011A wz 'write_Bellatrix_byte Variabel_byte
if_z jmp #J011A
' Variabel Empfang von Bellatrix ---------------------------------------------------------------------
cmp code, T0120 wz 'read_Bellatrix_long Variabel_long
if_z jmp #J0120
cmp code, T0121 wz 'read_Bellatrix_byte+word Variabel_long
if_z jmp #J0121
cmp code, T0122 wz 'read_Bellatrix_word Variabel_long
if_z jmp #J0122
cmp code, T0123 wz 'read_Bellatrix_byte Variabel_long
if_z jmp #J0123
' String Empfang von Bellatrix --------------------------------------------------------------------
cmp code, T012A wz 'read_Bellatrix_byte Variabel_byte
if_z jmp #J012A
' Variabel Empfang von Administra ---------------------------------------------------------------------
cmp code, T0130 wz 'read_Administra_long Variabel_long
if_z jmp #J0130
cmp code, T0131 wz 'read_Administra_byte+word Variabel_long
if_z jmp #J0131
cmp code, T0132 wz 'read_Administra_word Variabel_long
if_z jmp #J0132
cmp code, T0133 wz 'read_Administra_byte Variabel_long
if_z jmp #J0133
' String Empfang von Administra --------------------------------------------------------------------
cmp code, T013A wz 'read_Administra_byte Variabel_byte
if_z jmp #J013A
' ---------------------------------------------------------------------
jmp #RTLOOP
'starttext byte 1,"HIVE-BASIC 0.1 (PIC18F2550)", $0A, "Runtime 0 running", $0A, 0"
' ---------------------------------------------------------------------
T0000 long $00000000 'STOP
J0000 ' Statusregister auf 1 setzen um IDE zu zeigen das ein STOP-Befehl empfangen wurde
' Zeilenregister zeigt auf nächste Zeile
wrlong h00000001, stat
jmp #TLOOP
' ---------------------------------------------------------------------
T0001 long $00000001 'END
J0001 ' Statusregister auf 0 setzen um alle Runtimmodule zu stoppen und ihre internen Register in grundstellung zu bringen
' Zeilenregister auf 1. Zeile stellen
wrlong h00000000, stat
jmp #RESTART
' ---------------------------------------------------------------------
T0002 long $00000002 'GOTO
J0002 ' Zeilenregister auf neue Zeile(arg1) setzen
mov line, arg1
jmp #TLOOP
' ---------------------------------------------------------------------
T0100 long $00000100 'write_Bellatrix_word+long
T0101 long $00000101 'write_Bellatrix_byte+long
T0102 long $00000102 'write_Bellatrix_long
T0103 long $00000103 'write_Bellatrix_byte+word
T0104 long $00000104 'write_Bellatrix_word
T0105 long $00000105 'write_Bellatrix_byte
'[CODE+arg1]+[arg2+arg3]
'Zeilenregister zeigt auf nächste Zeile
J0100 mov temp1, arg1 'arg3.hbyte
shr temp1, $8
call #bput
J0101 mov temp1, arg1 'arg3.lbyte
call #bput
J0102 mov temp1, arg2 'arg2.hbyte
shr temp1, $8
call #bput
J0103 mov temp1, arg2 'arg2.lbyte
call #bput
J0104 mov temp1, arg3 'arg3.hbyte
shr temp1, $8
call #bput
J0105 mov temp1, arg3 'arg3.lbyte
call #bput
jmp #TLOOP
' ---------------------------------------------------------------------
T0106 long $00000106 'write_Bellatrix_long Variabel_long
J0106 ' Zeilenregister zeigt auf nächste Zeile
rdlong arg23, arg1
jmp #J0102
' ---------------------------------------------------------------------
T0107 long $00000107 'write_Bellatrix_byte+word Variabel_long
J0107 ' Zeilenregister zeigt auf nächste Zeile
rdlong arg23, arg1
jmp #J0103
' ---------------------------------------------------------------------
T0108 long $00000108 'write_Bellatrix_word Variabel_long
J0108 ' Zeilenregister zeigt auf nächste Zeile
rdlong arg23, arg1
jmp #J0104
' ---------------------------------------------------------------------
T0109 long $00000109 'write_Bellatrix_byte, Variabel_long
J0109 ' Zeilenregister zeigt auf nächste Zeile
rdlong arg23, arg1
jmp #J0105
' ---------------------------------------------------------------------
T010A long $0000010A 'write_Bellatrix_byte, Variabel_String
J010A ' Zeilenregister zeigt auf nächste Zeile
' *********************************************************
jmp #J0105
' ---------------------------------------------------------------------
T0110 long $00000110 'write_Administra_word+long
T0111 long $00000111 'write_Administra_byte+long
T0112 long $00000112 'write_Administra_long
T0113 long $00000113 'write_Administra_byte+word
T0114 long $00000114 'write_Administra_word
T0115 long $00000115 'write_Administra_byte
'[CODE+arg1]+[arg2+arg3]
'Zeilenregister zeigt auf nächste Zeile
J0110 mov temp1, arg1 'arg3.hbyte
shr temp1, $8
call #bput
J0111 mov temp1, arg1 'arg3.lbyte
call #bput
J0112 mov temp1, arg2 'arg2.hbyte
shr temp1, $8
call #bput
J0113 mov temp1, arg2 'arg2.lbyte
call #bput
J0114 mov temp1, arg3 'arg3.hbyte
shr temp1, $8
call #bput
J0115 mov temp1, arg3 'arg3.lbyte
call #bput
jmp #TLOOP
' ---------------------------------------------------------------------
T0116 long $00000116 'write_Administra_long Variabel_long
J0116 ' Zeilenregister zeigt auf nächste Zeile
rdlong arg23, arg1
jmp #J0112
' ---------------------------------------------------------------------
T0117 long $00000117 'write_Administra_byte+word Variabel_long
J0117 ' Zeilenregister zeigt auf nächste Zeile
rdlong arg23, arg1
jmp #J0113
' ---------------------------------------------------------------------
T0118 long $00000118 'write_Administra_word Variabel_long
J0118 ' Zeilenregister zeigt auf nächste Zeile
rdlong arg23, arg1
jmp #J0114
' ---------------------------------------------------------------------
T0119 long $00000119 'write_Administra_byte, Variabel_long
J0119 ' Zeilenregister zeigt auf nächste Zeile
rdlong arg23, arg1
jmp #J0115
' ---------------------------------------------------------------------
T011A long $0000011A 'write_Administra_byte, Variabel_String
J011A ' Zeilenregister zeigt auf nächste Zeile
' *********************************************************
jmp #J0115
' ---------------------------------------------------------------------
T0120 long $00000120 'read_Bellatrix_long
T0121 long $00000121 'read_Bellatrix_byte+word
T0122 long $00000122 'read_Bellatrix_word
T0123 long $00000123 'read_Bellatrix_byte
'[CODE+arg1]+[arg2+arg3] Arg1=Adresse von variabel
'Zeilenregister zeigt auf nächste Zeile
J0120 call #bget
mov arg23, temp1
shl arg23, #$8
J0121 call #bput
add arg23, temp1
shl arg23, #$8
J0122 call #bget
mov arg23, temp1
shl arg23, #$8
J0123 call #bput
add arg23, temp1
wrlong arg1, arg23 'ergebnis in arg23
mov arg23, h00000000 'Puffer wieder Löschen
jmp #TLOOP
' ---------------------------------------------------------------------
T012A long $0000012A 'read_Bellatrix_byte, Variabel_String
J012A 'Zeilenregister zeigt auf nächste Zeile
' *********************************************************
jmp #TLOOP
' ---------------------------------------------------------------------
T0130 long $00000130 'read_Administra_long
T0131 long $00000131 'read_Administra_byte+word
T0132 long $00000132 'read_Administra_word
T0133 long $00000133 'read_Administra_byte
'[CODE+arg1]+[arg2+arg3] Arg1=Adresse von variabel
'Zeilenregister zeigt auf nächste Zeile
J0130 call #bget
mov arg23, temp1
shl arg23, #$8
J0131 call #bput
add arg23, temp1
shl arg23, #$8
J0132 call #bget
mov arg23, temp1
shl arg23, #$8
J0133 call #bput
add arg23, temp1
wrlong arg1, arg23 'ergebnis in arg23
mov arg23, h00000000 'Puffer wieder Löschen
jmp #TLOOP
' ---------------------------------------------------------------------
T013A long $0000013A 'read_Administra_byte, Variabel_String
J013A ' Zeilenregister zeigt auf nächste Zeile
' *********************************************************
jmp #TLOOP
'---------------------------------------------------------------------
' businterface
' ---------------------------------------------------------------------
aput ' zeichen zu administra senden
mov temp2,_a1
mov temp3,_a2
jmp #put
bput ' zeichen zu belatrix senden
mov temp2,_b1
mov temp3,_b2
put waitpeq _hs,_hs ' warte auf hs=1 (slave bereit)
and temp1, #$ff ' wert maskieren
or temp1,temp2 ' + bel=0 wr=0 clk=0
mov outa,temp1 ' daten + signale ausgeben
mov dira,dout ' bus auf ausgabe schalten
or outa,temp3 ' clk=0 --> clk=1
waitpeq h00000000,_hs ' warte auf hs=0
mov dira,dinp ' bus auf eingabe schalten
mov outa,_s1 ' bussignale inaktiv
aput_ret
bput_ret ret
' ---------------------------------------------------------------------
aget ' zeichen von administra empfangen
mov temp2,_a3
jmp #get
bget ' zeichen von belatrix empfangen
mov temp2,_b3
get waitpeq _hs,_hs ' warte auf hs=1 (slave bereit)
mov outa,temp2 ' bel=0 wr=1 clk=1
waitpeq h00000000,_hs ' warte auf hs=0
mov temp1,ina ' daten einlesen
and temp1, #$ff ' wert maskieren
mov outa,_s1 ' bussignale inaktiv
aget_ret
bget_ret ret
'---------------------------------------------------------------------
'Konstanten
h00000000 long $00000000 '0
h00000001 long $00000001 ' STOP-Statusmeldung
h00000004 long $00000004 '1 ein long weiter
h000000ff long $000000FF '8 bit Lowmaske
h0000ffff long $0000FFFF '16 bit Lowmaske
dinp long %00000111_11111111_11111111_00000000 ' bus input
dout long %00000111_11111111_11111111_11111111 ' bus output
_s1 long %00000100_01111000_00000000_00000000 ' bus inaktiv
_b1 long %00000000_00111000_00000000_00000000 ' adm=1, bel=0, wr=0, busclk=0
_b2 long %00000010_00111000_00000000_00000000 ' adm=1, bel=0, wr=0, busclk=1
_b3 long %00000110_00111000_00000000_00000000 ' adm=1, bel=0, wr=1, busclk=1
_a1 long %00000000_01011000_00000000_00000000 ' adm=0, bel=1, wr=0, busclk=0
_a2 long %00000010_01011000_00000000_00000000 ' adm=0, bel=1, wr=0, busclk=1
_a3 long %00000110_01011000_00000000_00000000 ' adm=0, bel=1, wr=1, busclk=1
_hs long %00001000_00000000_00000000_00000000 ' hs=1?
'---------------------------------------------------------------------
h7F7FF7F7 long $7F7FF7F7 '32 bitmaske für LOAD SYSTEM von externen Ram (STATUS)
'---------------------------------------------------------------------
'Variabeln
stat long $7FFC 'Zeiger auf Statusregister
areg long $7FF8 'Zeiger auf token im hRAM
line long 0 'Merker line Nummer
code long 0 'Tockencode
arg1 long 0 'Tokenargument 1
arg23 long 0 'Longargument
arg2 long 0 'Tokenargument 2
arg3 long 0 'Tokenargument 3
temp1 long 0 'Merker
temp2 long 0 'Merker
temp3 long 0 'Merker
fit $1F0
das würde die Abarbeitung wesendlich beschleunigen.