initial upload

This commit is contained in:
Luxferre
2025-04-22 20:02:27 +03:00
commit 6bc0a916eb
8 changed files with 977 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
; A simple compound interest calculator in MU8A for mu808 VM
; Prompts for the percentage and then for the period, outputs the resulting multiplier
; Created by Luxferre in 2025, released into public domain
set 100 0 1 ; store the constant 100 at loc 1
inp 2 3 0 ; prompt for the percentage into loc 2 and the period into loc 3
div 2 1 4 ; divide the percentage value at loc 2 by the constant at loc 1 into loc 4
set 1 0 5 ; set the loc 5 to 1
fma 5 4 5 ; add the constant at loc 5 to the value at loc 4 into loc 5
nel 1 5 5 ; replace loc 5 with its ln
fma 0 3 5 ; replace loc 5 with loc 3 * ln loc 5
nel 0 5 5 ; replace loc 4 with its nexp
out 5 5 0 ; output the resulting value
+19
View File
@@ -0,0 +1,19 @@
set 72 0 1 ; fill in the data bytes from 1 to 10
set 101 0 2
set 108 0 3
set 108 0 4
set 111 0 5
set 114 0 6
set 108 0 7
set 100 0 8
set 33 0 9
set 10 0 10 ; end the string with an LF character for newline
set 1 0 50 ; set the constant 1 to memory loc 50
set 1 0 10 ; set the first address to 1 at loc 10
set 10 0 11 ; set the counter variable to 10 at loc 11
:lp set 12 0 12 ; prepare the loc 12 with its own address
cpy 2 10 12 ; load the contents of the current address at loc 10 into loc 12
out 12 12 1 ; output the character at the current address to port 1
sub 11 50 11 ; decrement the counter at loc 11
fma 50 50 10 ; increment the current address at loc 10
jmp 1 11 :lp ; jump to the loop start if the counter is over zero
+55
View File
@@ -0,0 +1,55 @@
; Linear regression calculator in MU8A for mu808 VM
; Enter the pairs number by number, end with 0,0 pair
; The program will then output A and B parameters of A + Bx
; linear function and then the correlation coefficient r
; Created by Luxferre in 2025, released into public domain
set 0 0 10 ; x-sum to loc 10
set 0 0 11 ; y-sum to loc 11
set 0 0 12 ; x-square-sum to loc 12
set 0 0 13 ; y-square-sum to loc 13
set 0 0 14 ; xy-sum to loc 14
set 0 0 15 ; n to loc 15
set 1 0 50 ; constant 1 to loc 50
:lp inp 1 2 0 ; loop start; input xi and yi into loc 1 and loc 2
cpy 1 1 3 ; copy x into loc 3
fma 0 3 3 ; save x-squared into loc 3
cpy 1 2 4 ; copy y into loc 4
fma 0 4 4 ; save y-squared into loc y
cpy 1 2 5 ; copy y into loc 5
fma 0 1 5 ; save xy into loc 5
fma 1 50 10 ; update x-sum (Sx) => loc 10
fma 2 50 11 ; update y-sum (Sy) => loc 11
fma 3 50 12 ; update x-square-sum (Sxx) => loc 12
fma 4 50 13 ; update y-square-sum (Syy) => loc 13
fma 5 50 14 ; update xy-sum (Sxy) => loc 14
fma 50 50 15 ; increment n at loc 15
cpy 1 3 6 ; copy x-squared into loc 6
fma 4 50 6 ; add x-squared and y-squared into loc 6
jmp 1 6 :lp ; loop back to the input if the square sum is over zero
sub 15 50 15 ; decrement last n at loc 15 to omit the (0,0) input
cpy 1 15 1 ; copy n to loc 1
fma 0 14 1 ; n * Sxy => loc 1
cpy 1 11 5 ; copy Sy to loc 5
fma 0 10 5 ; Sx * Sy => loc 5
sub 1 5 6 ; n * Sxy - Sx * Sy => loc 6 (to be stored for r calculation)
cpy 1 15 3 ; copy n to loc 3
fma 0 12 3 ; n * Sxx => loc 3
cpy 1 10 4 ; copy Sx to loc 4
fma 0 10 4 ; Sx squared => loc 4
sub 3 4 3 ; n * Sxx - Sx^2 => loc 3 (to be stored for r calculation)
div 6 3 21 ; coefficient B => loc 21
cpy 1 10 1 ; copy Sx to loc 1
fma 0 21 1 ; B * Sx => loc 1
sub 11 1 1 ; Sy - B * Sx => loc 1
div 1 15 20 ; coefficient A => loc 20
cpy 1 11 2 ; copy Sy to loc 2
fma 0 11 2 ; (Sy) ^ 2 => loc 2
cpy 1 15 5 ; n to loc 5
fma 0 13 5 ; n * Syy => loc 5
sub 5 2 2 ; n * Syy - Sy^2 => loc 2
cpy 1 3 1 ; loc 3 => loc 1
fma 0 2 1 ; loc 3 * loc 2 => loc 1
sqr 0 1 1 ; sqrt(loc 1) => loc 1
div 6 1 22 ; correlation coefficient r => loc 22
out 20 22 0 ; output all three resulting numbers
+77
View File
@@ -0,0 +1,77 @@
; Lunar Lander game in MU8A for mu808 VM
; On each turn, the following parameters are displayed in this order:
; altitude (meters), speed (m/s) and remaining fuel (kg)
; Your goal is to apply (or not apply) thrust
; (values that make any sense are 0 to 2000) every 10 seconds of flight
; and get the lunar module to land safely without running out of fuel.
; At the end, the game shows one of the following statuses:
; 4444 is a disaster landing with no survivors,
; 5555 is a crash landing with the crew surviving the impact,
; 6666 is a hard landing with some damage to the pod,
; 7777 is a good landing,
; 8888 is a perfect landing.
; 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 16 2500 53 ; freefall speed delta into loc 53
set 7480 0 54 ; capsule weight (in kg) into loc 54
set 3 4483 55 ; fuel burn rate (3.4483) into loc 55
set 2900 0 56 ; exhaust velocity (m/s) into loc 56
set 1930 0 40 ; starting altitude (m) into loc 40
set 100 0 57 ; store 100 into loc 57
fma 0 57 40 ; multiply this altitude value by 100
set 1609 0 41 ; starting speed (m/s) into loc 41
set 7260 0 42 ; starting fuel (in kg) into loc 42
set 4444 0 30 ; disaster code into loc 30
set 5555 0 31 ; crash landing code into loc 31
set 6666 0 32 ; damage landing code into loc 32
set 7777 0 33 ; good landing code into loc 33
set 8888 0 34 ; perfect landing code into loc 34
set 26 6667 0 36 ; criterion for crash landing into loc 36
set 9 7300 0 37 ; criterion for damage landing into loc 37
set 4 4445 0 38 ; criterion for good landing into loc 38
set 0 4500 0 39 ; criterion for perfect landing into loc 39
:lp out 40 42 0 ; loop start; print altitude, speed and fuel
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
inp 1 1 0 ; prompt for thrust into loc 1
cpy 1 1 2 ; copy thrust into loc 2
fma 0 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
:cnt fma 54 50 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
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
fma 0 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
fma 53 50 41 ; add the freefall speed delta to the current speed
cpy 1 41 3 ; copy the speed value into loc 3
fma 0 52 3 ; multiply speed by time period into loc 3
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
jmp 1 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
:flc jmp 1 40 :al ; do the same for altitude
set 0 0 40 ; set it to zero if negative
: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
out 40 42 0 ; print the final altitude/speed/fuel
sub 41 39 1 ; subtract the perfect speed
jmp 1 1 :good ; skip if > 0
out 34 34 0 ; output the perfect score
jmp 6 0 :end ; go to end
:good sub 41 38 1 ; subtract the good speed
jmp 1 1 :dmg ; skip if > 0
out 33 33 0 ; output the good score
jmp 6 0 :end ; go to end
:dmg sub 41 37 1 ; subtract the damage speed
jmp 1 1 :crsh ; skip if > 0
out 32 32 0 ; output the damage score
jmp 6 0 :end ; go to end
:crsh sub 41 36 1 ; subtract the crash speed
jmp 1 1 :disa ; skip if > 0
out 31 31 0 ; output the crash score
jmp 6 0 :end ; go to end
:disa out 30 30 0 ; output the disaster score
:end nop 0 0 0 ; program end label
+68
View File
@@ -0,0 +1,68 @@
; Bulls and Cows game in MU8A for mu808 VM
; Enter your guesses digit by digit, you have 7 attempts
; After each guess, the game replies with bulls.cows
; (if you have 4.0, you win)
; On victory or after running out of attempts, the game
; displays the target digits and halts
; Created by Luxferre in 2025, released into public domain
set 0 0 60 ; store digits 0 to 9 to locations 60 to 69
set 1 0 61
set 2 0 62
set 3 0 63
set 4 0 64
set 5 0 65
set 6 0 66
set 7 0 67
set 8 0 68
set 9 0 69
set 1 0 50 ; store 1 into loc 50
set 4 0 11 ; store the counter to loc 11
set 60 0 70 ; store the source base address 60 to loc 70
set 80 0 71 ; store the target base address 80 to loc 71
set 10 0 3 ; store the constant 10 to loc 3
:dsl set 9 0 1 ; store the upper boundary to loc 1
rnd 0 1 1 ; store a random digit into loc 1
fma 70 50 1 ; add the source base address to loc 1
set 2 0 2 ; init loc 2 with its own address
cpy 2 1 2 ; read the value at that loc 1 address back into loc 2
sub 2 3 4 ; subtract 10 from the read value into loc 4
jmp 0 4 :dsl ; jump back to digit selection if the value at loc 4 is zero
iat 0 3 1 ; enable indirect addressing to...
cpy 0 0 0 ; ...set the value at the address still at loc 1 to 10
cpy 1 11 1 ; copy the counter into loc 1
fma 71 50 1 ; add the counter and the target base address (result is 81..84 at loc 1)
set 2 0 5 ; set the constant 2 into loc 5
cpy 2 5 1
sub 11 50 11 ; decrement the counter at loc 11
jmp 1 11 :dsl ; jump back to digit selection if the counter is over zero
set 0 1000 51 ; store 0.1 to loc 51
set 7 0 11 ; the number to guess is at loc 81..84; store the attempt counter to loc 11
:prm inp 91 94 0 ; prompt the player to enter the number digit by digit into loc 91 to 94
set 90 0 70 ; store the entered digits base address to loc 70
set 0 0 20 ; init bull/cow counter at loc 20
set 4 0 21 ; init outer loop counter at loc 21
:olp set 4 0 22 ; start of the outer loop; init inner loop counter at loc 22
:ilp cpy 1 21 15 ; start of the inner loop; copy the outer counter
fma 71 50 15 ; shape the address of the target digit in loc 15
cpy 1 22 16 ; copy the inner counter
fma 70 50 16 ; shape the address of the entered digit in loc 16
iat 15 16 50 ; prepare to save the digits difference into loc 1 (1 is stored at loc 50)
sub 0 0 0 ; do it
jmp 5 1 :ei ; jump to the next comparator if the digits don't match
sub 21 22 2 ; save the _indices_ difference into loc 2
jmp 5 2 :cc ; jump to the cow counter if the indices don't match
fma 50 50 20 ; increase the bull counter if they do
jmp 6 0 :ei ; skip the next instruction
:cc fma 51 50 20 ; increase the cow counter if they don't
:ei sub 22 50 22 ; decrease the inner loop counter
jmp 1 22 :ilp ; jump to the start of the inner loop if the inner counter is over zero
sub 21 50 21 ; decrease the outer loop counter
jmp 1 21 :olp ; jump to the start of the outer loop if the outer counter is over zero
out 20 20 0 ; output the match result
set 4 0 7 ; store the constant 4.0 at loc 7
sub 20 7 1 ; store the difference between the result and 4 to loc 1
jmp 0 1 :end ; jump to the last instruction if they match
sub 11 50 11 ; decrement the attempt counter at loc 11
jmp 1 11 :prm ; jump to guess prompt if the counter is over zero
:end out 81 84 0 ; output the target number before halting