@@ -65,6 +65,10 @@ def __init__(self, text_program: str, *, build_debuginfo: bool = False) -> None:
65
65
mov_status_count = None
66
66
mov_status_param = None
67
67
68
+ def require_before_instruction ():
69
+ if len (instructions ) != 0 :
70
+ raise RuntimeError (f"{ words [0 ]} must be before first instruction" )
71
+
68
72
def require_version (required_version , instruction ):
69
73
if pio_version < required_version :
70
74
raise RuntimeError (
@@ -89,8 +93,10 @@ def int_in_range(arg, low, high, what, radix=0):
89
93
raise RuntimeError ("Multiple programs not supported" )
90
94
program_name = line .split ()[1 ]
91
95
elif line .startswith (".pio_version" ):
96
+ require_before_instruction ()
92
97
pio_version = int_in_range (words [1 ], 0 , 2 , ".pio_version" )
93
98
elif line .startswith (".origin" ):
99
+ require_before_instruction ()
94
100
offset = int (line .split ()[1 ], 0 )
95
101
elif line .startswith (".wrap_target" ):
96
102
wrap_target = len (instructions )
@@ -102,12 +108,14 @@ def int_in_range(arg, low, high, what, radix=0):
102
108
sideset_count = int (line .split ()[1 ], 0 )
103
109
sideset_enable = "opt" in line
104
110
elif line .startswith (".fifo" ):
111
+ require_before_instruction ()
105
112
fifo_type = line .split ()[1 ]
106
113
required_version = FIFO_TYPES .get (fifo_type )
107
114
if required_version is None :
108
115
raise RuntimeError (f"Invalid fifo type { fifo_type } " )
109
116
require_version (required_version , line )
110
117
elif line .startswith (".mov_status" ):
118
+ require_before_instruction ()
111
119
required_version = 0
112
120
mov_status_param = 0
113
121
mov_status_type = words [1 ]
0 commit comments