PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : State Machine: LOADLABEL in DATA einsetzen



-tomas-
20.06.2006, 20:31
ich programmiere gerade für den Butterfly ein Menü als State Machine möchte in die Datensätzen (DATA) die Einsprungadresse zu den Unterprogrammen ablegen (LOADLABEL).

Obwohl BASCOM den Befehl LOADLABEL während des Compilier-Laufs als Konstante auflöst, lehnt er die Verbindung mit Data ab:

DATA LOADLABEL(Marke_1)
auch ein Workaround über CONST wird abgelehnt:

CONST Adr_1 = LOADLABEL(Marke_1)
Adr_Data:
DATA Adr_1


so bleibt mir nur der lange Weg:

Select Case State
Case St_avrbf_rev : Gosub Revision
Case St_time_clock_func : Gosub Showclock
Case St_time_clock_adjust_func : Gosub Setclock
Case St_time_clockformat_adjust_func : Gosub Setclockformat
Case St_time_date_func : Gosub Showdate
Case St_time_date_adjust_func : Gosub Setdate
Case St_time_dateformat_adjust_func : Gosub Setdateformat
Case St_music_select : Gosub Selectsound
Case St_music_play : Gosub Music
Case St_vcard_func : Gosub Vcard
Case St_vcard_enter_name_func : Gosub Entername
Case St_vcard_download_name_func : Gosub Rs232
Case St_temperature_func : Gosub Temperaturefunc
Case St_voltage_func : Gosub Voltagefunc
Case St_light_func : Gosub Lightfunc
Case St_options_display_contrast_func : Gosub Setcontrast
Case St_options_boot_func : Gosub Bootfunc
Case St_options_power_save_func : Gosub Powersavefunc
Case St_options_auto_power_save_func : Gosub Autopower
Case St_options_keyclick_func : Gosub Keyclick
End Select

'Datensätze der State Machine
State_machine:
' STATE INPUT NEXT STATE
Data St_avrbf , Key_plus , St_options
Data St_avrbf , Key_next , St_avrbf_rev
Data St_avrbf , Key_minus , St_time

Data St_avrbf_rev , Key_prev , St_avrbf

Data St_time , Key_plus , St_avrbf
Data St_time , Key_next , St_time_clock
Data St_time , Key_prev , St_avrbf
Data St_time , Key_minus , St_music

Data St_time_clock , Key_plus , St_time_date
Data St_time_clock , Key_next , St_time_clock_func
Data St_time_clock , Key_prev , St_time
Data St_time_clock , Key_minus , St_time_date

Data St_time_clock_adjust , Key_plus , St_time_clockformat_adjust
Data St_time_clock_adjust , Key_enter , St_time_clock_adjust_func
Data St_time_clock_adjust , Key_prev , St_time_clock_func
Data St_time_clock_adjust , Key_minus , St_time_clockformat_adjust

Data St_time_clockformat_adjust , Key_plus , St_time_clock_adjust
Data St_time_clockformat_adjust , Key_enter , St_time_clockformat_adjust_func
Data St_time_clockformat_adjust , Key_prev , St_time_clock_func
Data St_time_clockformat_adjust , Key_minus , St_time_clock_adjust

Data St_time_date , Key_plus , St_time_clock
Data St_time_date , Key_next , St_time_date_func
Data St_time_date , Key_prev , St_time
Data St_time_date , Key_minus , St_time_clock

Data St_time_date_adjust , Key_plus , St_time_dateformat_adjust
Data St_time_date_adjust , Key_enter , St_time_date_adjust_func
Data St_time_date_adjust , Key_prev , St_time_date_func
Data St_time_date_adjust , Key_minus , St_time_dateformat_adjust

Data St_time_dateformat_adjust , Key_plus , St_time_date_adjust
Data St_time_dateformat_adjust , Key_enter , St_time_dateformat_adjust_func
Data St_time_dateformat_adjust , Key_prev , St_time_date_func
Data St_time_dateformat_adjust , Key_minus , St_time_date_adjust

Data St_music , Key_plus , St_time
Data St_music , Key_next , St_music_select
Data St_music , Key_prev , St_avrbf
Data St_music , Key_minus , St_vcard

Data St_sound_music , Key_next , St_music_select
Data St_sound_music , Key_prev , St_music

Data St_vcard , Key_plus , St_music
Data St_vcard , Key_next , St_vcard_func
Data St_vcard , Key_prev , St_avrbf
Data St_vcard , Key_minus , St_temperature

Data St_vcard_enter_name , Key_plus , St_vcard_download_name
Data St_vcard_enter_name , Key_enter , St_vcard_enter_name_func
Data St_vcard_enter_name , Key_prev , St_vcard_func
Data St_vcard_enter_name , Key_minus , St_vcard_download_name

Data St_vcard_download_name , Key_plus , St_vcard_enter_name
Data St_vcard_download_name , Key_enter , St_vcard_download_name_func
Data St_vcard_download_name , Key_prev , St_vcard_func
Data St_vcard_download_name , Key_minus , St_vcard_enter_name

Data St_temperature , Key_plus , St_vcard
Data St_temperature , Key_next , St_temperature_func
Data St_temperature , Key_prev , St_avrbf
Data St_temperature , Key_minus , St_voltage

Data St_voltage , Key_plus , St_temperature
Data St_voltage , Key_next , St_voltage_func
Data St_voltage , Key_prev , St_avrbf
Data St_voltage , Key_minus , St_light

Data St_light , Key_plus , St_voltage
Data St_light , Key_next , St_light_func
Data St_light , Key_prev , St_avrbf
Data St_light , Key_minus , St_options

Data St_options , Key_plus , St_light
Data St_options , Key_next , St_options_display
Data St_options , Key_prev , St_avrbf
Data St_options , Key_minus , St_avrbf

Data St_options_display , Key_plus , St_options_keyclick
Data St_options_display , Key_next , St_options_display_contrast
Data St_options_display , Key_prev , St_options
Data St_options_display , Key_minus , St_options_boot

Data St_options_display_contrast , Key_enter , St_options_display_contrast_func
Data St_options_display_contrast , Key_prev , St_options_display

Data St_options_boot , Key_plus , St_options_display
Data St_options_boot , Key_next , St_options_boot_func
Data St_options_boot , Key_prev , St_options
Data St_options_boot , Key_minus , St_options_power_save

Data St_options_power_save , Key_plus , St_options_boot
Data St_options_power_save , Key_next , St_options_power_save_func
Data St_options_power_save , Key_prev , St_options
Data St_options_power_save , Key_minus , St_options_auto_power_save

Data St_options_auto_power_save , Key_plus , St_options_power_save
Data St_options_auto_power_save , Key_next , St_options_auto_power_save_func
Data St_options_auto_power_save , Key_prev , St_options
Data St_options_auto_power_save , Key_minus , St_options_keyclick

Data St_options_keyclick , Key_plus , St_options_auto_power_save
Data St_options_keyclick , Key_next , St_options_keyclick_func
Data St_options_keyclick , Key_prev , St_options
Data St_options_keyclick , Key_minus , St_options_display

Data 255 , 255 , 255

Hat jemand eine Idee, wie man den Select Case ... GOSUB elegant umgehen kann indem man die Labels der Unterprogramme gleich in DATA einpflegt?

PicNick
21.06.2006, 07:04
Das hätt' ich auch gerne gehabt, aber "loadlabel" funzt nur zur run-time.
Alle Varianten probiert, ist mir nicht gelungen, irgendwie sowas
DATA vec, vec, ....
zu erzeugen.
"Loadlabel" is ja nicht das Problem, eigentlich ist es "data", der so bescheuert ist.
Auch mit Inline-Assembler probiert, nix zu machen.

Wenn deine "select case" variable irgendwie eine halbwegs geschlossene Zahl ist, geht "on var gosub vec, vec, ....." ganz gut.

Eventuell die States mit LOOKDOWN (-->help) zuerst auf so eine 0-x Zahl umwandeln