updated the lunar lander example

This commit is contained in:
Luxferre
2025-04-30 13:23:54 +03:00
parent a3bddcbc36
commit 6f9f954df3
2 changed files with 85 additions and 87 deletions
+62 -63
View File
@@ -1,63 +1,62 @@
1 5 1 0 50 1 5 10 0 52
2 5 10 0 52 2 5 16 2500 53
3 5 16 2500 53 3 5 7480 0 54
4 5 7480 0 54 4 5 3 4483 55
5 5 3 4483 55 5 5 2900 0 56
6 5 2900 0 56 6 5 1930 0 40
7 5 1930 0 40 7 5 100 0 57
8 5 100 0 57 8 7 0 57 40
9 7 0 57 40 9 5 1609 0 41
10 5 1609 0 41 10 5 7260 0 42
11 5 7260 0 42 11 5 4444 0 30
12 5 4444 0 30 12 5 5555 0 31
13 5 5555 0 31 13 5 6666 0 32
14 5 6666 0 32 14 5 7777 0 33
15 5 7777 0 33 15 5 8888 0 34
16 5 8888 0 34 16 5 26 6667 0
17 5 26 6667 0 17 5 9 7300 0
18 5 9 7300 0 18 5 4 4445 0
19 5 4 4445 0 19 5 0 4500 0
20 5 0 4500 0 20 3 40 42 0
21 3 40 42 0 21 5 0 0 2
22 5 0 0 2 22 1 4 42 27
23 1 4 42 28 23 4 1 1 0
24 4 1 1 0 24 6 1 1 2
25 6 1 1 2 25 7 0 55 2
26 7 0 55 2 26 6 1 42 3
27 6 1 42 3 27 7 54 127 3
28 7 54 50 3 28 8 3 2 4
29 8 3 2 4 29 9 3 4 1
30 9 3 4 1 30 13 1 1 1
31 13 1 1 1 31 7 0 56 1
32 7 0 56 1 32 8 41 1 41
33 8 41 1 41 33 7 53 127 41
34 7 53 50 41 34 6 1 41 3
35 6 1 41 3 35 7 0 52 3
36 7 0 52 3 36 8 40 3 40
37 8 40 3 40 37 8 42 2 42
38 8 42 2 42 38 1 1 42 40
39 1 1 42 41 39 5 0 0 42
40 5 0 0 42 40 1 1 40 42
41 1 1 40 43 41 5 0 0 40
42 5 0 0 40 42 8 40 52 1
43 8 40 52 1 43 1 1 1 20
44 1 1 1 21 44 3 40 42 0
45 3 40 42 0 45 8 41 39 1
46 8 41 39 1 46 1 1 1 49
47 1 1 1 50 47 3 34 34 0
48 3 34 34 0 48 1 6 0 62
49 1 6 0 63 49 8 41 38 1
50 8 41 38 1 50 1 1 1 53
51 1 1 1 54 51 3 33 33 0
52 3 33 33 0 52 1 6 0 62
53 1 6 0 63 53 8 41 37 1
54 8 41 37 1 54 1 1 1 57
55 1 1 1 58 55 3 32 32 0
56 3 32 32 0 56 1 6 0 62
57 1 6 0 63 57 8 41 36 1
58 8 41 36 1 58 1 1 1 61
59 1 1 1 62 59 3 31 31 0
60 3 31 31 0 60 1 6 0 62
61 1 6 0 63 61 3 30 30 0
62 3 30 30 0 62 0 0 0 0
63 0 0 0 0
+23 -24
View File
@@ -12,7 +12,6 @@
; 8888 is a perfect landing. ; 8888 is a perfect landing.
; Created by Luxferre in 2025, released into public domain ; Created by Luxferre in 2025, released into public domain
set 1 0 50 ; set constant 1 to loc 50
set 10 0 52 ; altitude threshold AND time period into loc 52 set 10 0 52 ; altitude threshold AND time period into loc 52
set 16 2500 53 ; freefall speed delta into loc 53 set 16 2500 53 ; freefall speed delta into loc 53
set 7480 0 54 ; capsule weight (in kg) into loc 54 set 7480 0 54 ; capsule weight (in kg) into loc 54
@@ -20,7 +19,7 @@ set 3 4483 55 ; fuel burn rate (3.4483) into loc 55
set 2900 0 56 ; exhaust velocity (m/s) into loc 56 set 2900 0 56 ; exhaust velocity (m/s) into loc 56
set 1930 0 40 ; starting altitude (m) into loc 40 set 1930 0 40 ; starting altitude (m) into loc 40
set 100 0 57 ; store 100 into loc 57 set 100 0 57 ; store 100 into loc 57
fma 0 57 40 ; multiply this altitude value by 100 mul 57 40 ; multiply this altitude value by 100
set 1609 0 41 ; starting speed (m/s) into loc 41 set 1609 0 41 ; starting speed (m/s) into loc 41
set 7260 0 42 ; starting fuel (in kg) into loc 42 set 7260 0 42 ; starting fuel (in kg) into loc 42
set 4444 0 30 ; disaster code into loc 30 set 4444 0 30 ; disaster code into loc 30
@@ -34,44 +33,44 @@ set 4 4445 0 38 ; criterion for good landing into loc 38
set 0 4500 0 39 ; criterion for perfect landing into loc 39 set 0 4500 0 39 ; criterion for perfect landing into loc 39
:lp out 40 42 0 ; loop start; print altitude, speed and fuel :lp out 40 42 0 ; loop start; print altitude, speed and fuel
set 0 0 2 ; set fuel loss in loc 2 to 0 set 0 0 2 ; set fuel loss in loc 2 to 0
jmp 4 42 :cnt ; skip prompting for thrust if already out of fuel jle 42 :cnt ; skip prompting for thrust if already out of fuel
inp 1 1 0 ; prompt for thrust into loc 1 inp 1 1 0 ; prompt for thrust into loc 1
cpy 1 1 2 ; copy thrust into loc 2 dva 1 2 ; copy thrust into loc 2
fma 0 55 2 ; multiply thrust by fuel burn rate to get fuel loss in loc 2 mul 55 2 ; multiply thrust by fuel burn rate to get fuel loss in loc 2
cpy 1 42 3 ; copy fuel weight into loc 3 dva 42 3 ; copy fuel weight into loc 3
:cnt fma 54 50 3 ; add capsule weight and fuel weight to get m0 in loc 3 :cnt fma 54 127 3 ; add capsule weight and fuel weight to get m0 in loc 3
sub 3 2 4 ; subtract m0 and fuel loss value to get m1 in loc 4 sub 3 2 4 ; subtract m0 and fuel loss value to get m1 in loc 4
div 3 4 1 ; divide m0 by m1 and rewrite the result into loc 1 div 3 4 1 ; divide m0 by m1 and rewrite the result into loc 1
nel 1 1 1 ; calculate natural logarithm of the previous result log 1 1 ; calculate natural logarithm of the previous result
fma 0 56 1 ; multiply the result by the exhaust velocity to get thrust speed delta mul 56 1 ; multiply the result by the exhaust velocity to get thrust speed delta
sub 41 1 41 ; subtract the thrust speed delta from the current speed sub 41 1 41 ; subtract the thrust speed delta from the current speed
fma 53 50 41 ; add the freefall speed delta to the current speed fma 53 127 41 ; add the freefall speed delta to the current speed
cpy 1 41 3 ; copy the speed value into loc 3 dva 41 3 ; copy the speed value into loc 3
fma 0 52 3 ; multiply speed by time period into loc 3 mul 52 3 ; multiply speed by time period into loc 3
sub 40 3 40 ; decrease the altitude by the result of this operation sub 40 3 40 ; decrease the altitude by the result of this operation
sub 42 2 42 ; decrease the amount of fuel by fuel loss value still at loc 2 sub 42 2 42 ; decrease the amount of fuel by fuel loss value still at loc 2
jmp 1 42 :flc ; skip the next instruction if the amount of fuel is positive jgt 42 :flc ; skip the next instruction if the amount of fuel is positive
set 0 0 42 ; just set the amount of fuel to zero if it's negative set 0 0 42 ; just set the amount of fuel to zero if it's negative
:flc jmp 1 40 :al ; do the same for altitude :flc jgt 40 :al ; do the same for altitude
set 0 0 40 ; set it to zero if negative set 0 0 40 ; set it to zero if negative
:al sub 40 52 1 ; subtract the threshold from the altitude :al sub 40 52 1 ; subtract the threshold from the altitude
jmp 1 1 :lp ; go to the loop start if the altitude is above the threshold jgt 1 :lp ; go to the loop start if the altitude is above the threshold
out 40 42 0 ; print the final altitude/speed/fuel out 40 42 0 ; print the final altitude/speed/fuel
sub 41 39 1 ; subtract the perfect speed sub 41 39 1 ; subtract the perfect speed
jmp 1 1 :good ; skip if > 0 jgt 1 :good ; skip if > 0
out 34 34 0 ; output the perfect score out 34 34 0 ; output the perfect score
jmp 6 0 :end ; go to end juc :end ; go to end
:good sub 41 38 1 ; subtract the good speed :good sub 41 38 1 ; subtract the good speed
jmp 1 1 :dmg ; skip if > 0 jgt 1 :dmg ; skip if > 0
out 33 33 0 ; output the good score out 33 33 0 ; output the good score
jmp 6 0 :end ; go to end juc :end ; go to end
:dmg sub 41 37 1 ; subtract the damage speed :dmg sub 41 37 1 ; subtract the damage speed
jmp 1 1 :crsh ; skip if > 0 jgt 1 :crsh ; skip if > 0
out 32 32 0 ; output the damage score out 32 32 0 ; output the damage score
jmp 6 0 :end ; go to end juc :end ; go to end
:crsh sub 41 36 1 ; subtract the crash speed :crsh sub 41 36 1 ; subtract the crash speed
jmp 1 1 :disa ; skip if > 0 jgt 1 :disa ; skip if > 0
out 31 31 0 ; output the crash score out 31 31 0 ; output the crash score
jmp 6 0 :end ; go to end juc :end ; go to end
:disa out 30 30 0 ; output the disaster score :disa out 30 30 0 ; output the disaster score
:end nop 0 0 0 ; program end label :end nnn ; program end label