Skip to content

Commit 0eefc73

Browse files
committed
Throw error when a word for cross compile doesn't have assembly.
1 parent f8d2c2d commit 0eefc73

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

pkg/forth/word.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ func (w *WordPrimitive) BuildAssembly(u *Ulp) (string, error) {
220220
asm := make([]string, 0)
221221
switch u.compileTarget {
222222
case UlpCompileTargetToken:
223+
if len(w.Ulp.Asm) == 0 {
224+
return "", EntryError(w.Entry, "does not have any subroutine threaded assembly")
225+
}
223226
asm = append(asm, w.Ulp.Asm...)
224227
switch w.Ulp.Next {
225228
case TokenNextNonstandard:
@@ -233,6 +236,9 @@ func (w *WordPrimitive) BuildAssembly(u *Ulp) (string, error) {
233236
return "", fmt.Errorf("Unknown compile target %d, please file a bug report", w.Ulp.Next)
234237
}
235238
case UlpCompileTargetSubroutine:
239+
if len(w.UlpSrt.Asm) == 0 {
240+
return "", EntryError(w.Entry, "does not have any subroutine threaded assembly")
241+
}
236242
asm = append(asm, w.UlpSrt.Asm...)
237243
if !w.UlpSrt.NonStandardNext {
238244
standardNext := []string{

util/pulse_test.f

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@
1717

1818
\ create the assembly to toggle a pin as fast as possible
1919
string" reg_wr 257, 28, 28, 1\nreg_wr 258, 28, 28, 1\n"
20-
string" unique_label_to_skip_assembly_optimizations_in_pulse_test_f:\n"
21-
string" jump __next_skip_load"
22-
3 \ 3 assembly objects to compile
23-
assembly asm-pulse \ create the assembly word named "asm-pulse"
20+
string" __safe_jump:\n"
21+
2 \ number of assembly objects to compile
22+
string" reg_wr 257, 28, 28, 1\nreg_wr 258, 28, 28, 1\n"
23+
string" __safe_jump:\n"
24+
2 \ number of assembly objects to compile
25+
assembly-both asm-pulse
26+
token_next_skip_load last set-ulp-asm-next
2427

2528
: main
2629
pin_init

0 commit comments

Comments
 (0)