RosettaCodeData/Task/Subleq/EasyLang/subleq.easy

40 lines
733 B
Text
Raw Permalink Normal View History

2023-12-16 21:33:55 -08:00
global inpos inp$ .
func inp .
if inpos = 0
inp$ = input
2025-06-11 20:16:52 -04:00
if error = 1 : return 255
2023-12-16 21:33:55 -08:00
inpos = 1
.
if inpos <= len inp$
h = strcode substr inp$ inpos 1
inpos += 1
return h
.
inpos = 0
return 10
.
2025-06-11 20:16:52 -04:00
proc subleq &mem[] .
2023-12-16 21:33:55 -08:00
repeat
2026-04-30 12:34:36 -04:00
a = mem[p + 1]
b = mem[p + 2]
c = mem[p + 3]
2023-12-16 21:33:55 -08:00
p += 3
if a = -1
2026-04-30 12:34:36 -04:00
mem[b + 1] = inp
2023-12-16 21:33:55 -08:00
elif b = -1
2026-04-30 12:34:36 -04:00
write strchar mem[a + 1]
2023-12-16 21:33:55 -08:00
else
2026-04-30 12:34:36 -04:00
mem[b + 1] -= mem[a + 1]
if mem[b + 1] <= 0
2023-12-16 21:33:55 -08:00
p = c
.
.
until p < 0
.
.
prog[] = [ 15 17 -1 17 -1 -1 16 1 -1 16 3 -1 15 15 0 0 -1 72 101 108 108 111 44 32 119 111 114 108 100 33 10 0 ]
subleq prog[]
#
input_data
dummy data