Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
a.out
a.mcfunction
mcasm
6 changes: 6 additions & 0 deletions src/DataPack/mc-asm/data/mcasm/functions/add.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# add.mcfunction
# __arg1 integer A
# __arg2 integer B
# returns A + B
scoreboard players operation __ret Internal = __arg1 Internal
scoreboard players operation __ret Internal += __arg2 Internal
6 changes: 6 additions & 0 deletions src/DataPack/mc-asm/data/mcasm/functions/ass.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# ass.mcfunction
# __arg1 integer A
# returns A
#
# this function exists for generalization in the complier.
scoreboard players operation __ret Internal = __arg1 Internal
6 changes: 6 additions & 0 deletions src/DataPack/mc-asm/data/mcasm/functions/div.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# div.mcfunction
# __arg1 integer A
# __arg2 integer B
# returns A / B
scoreboard players operation __ret Internal = __arg1 Internal
scoreboard players operation __ret Internal /= __arg2 Internal
6 changes: 6 additions & 0 deletions src/DataPack/mc-asm/data/mcasm/functions/eq.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# eq.mcfunction
# __arg1 integer A
# __arg2 integer B
# returns A == B
scoreboard players set __ret Internal 0
execute if score __arg1 Internal = __arg2 Internal run scoreboard players set __ret Internal 1
6 changes: 6 additions & 0 deletions src/DataPack/mc-asm/data/mcasm/functions/ge.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# ge.mcfunction
# __arg1 integer A
# __arg2 integer B
# returns A >= B
scoreboard players set __ret Internal 0
execute if score __arg1 Internal >= __arg2 Internal run scoreboard players set __ret Internal 1
6 changes: 6 additions & 0 deletions src/DataPack/mc-asm/data/mcasm/functions/gt.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# gt.mcfunction
# __arg1 integer A
# __arg2 integer B
# returns A > B
scoreboard players set __ret Internal 0
execute if score __arg1 Internal > __arg2 Internal run scoreboard players set __ret Internal 1
7 changes: 7 additions & 0 deletions src/DataPack/mc-asm/data/mcasm/functions/jif.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# jif.mcfunction
# __arg1 condition value
# __arg2 __pc value
# returns nothing
#
# change __pc to the given value, if condition is NOT zero.
execute unless score __arg1 Internal matches 0 run scoreboard players operation __pc Internal = __arg2 Internal
6 changes: 6 additions & 0 deletions src/DataPack/mc-asm/data/mcasm/functions/jmp.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# jmp.mcfunction
# __arg1 __pc value
# returns nothing
#
# change __pc to the given value
scoreboard players operation __pc Internal = __arg1 Internal
6 changes: 6 additions & 0 deletions src/DataPack/mc-asm/data/mcasm/functions/le.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# le.mcfunction
# __arg1 integer A
# __arg2 integer B
# returns A <= B
scoreboard players set __ret Internal 0
execute if score __arg1 Internal <= __arg2 Internal run scoreboard players set __ret Internal 1
15 changes: 15 additions & 0 deletions src/DataPack/mc-asm/data/mcasm/functions/load.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
tellraw @a {"text": "MC-ASM Loaded!", "color": "blue"}

scoreboard objectives add Internal dummy
scoreboard objectives add Variables dummy

scoreboard players reset * Internal
scoreboard players reset * Variables

scoreboard objectives setdisplay sidebar Internal

scoreboard players add __arg1 Internal 0
scoreboard players add __arg2 Internal 0
scoreboard players add __arg3 Internal 0
scoreboard players add __ret Internal 0
scoreboard players add __pc Internal 1
6 changes: 6 additions & 0 deletions src/DataPack/mc-asm/data/mcasm/functions/lt.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# lt.mcfunction
# __arg1 integer A
# __arg2 integer B
# returns A < B
scoreboard players set __ret Internal 0
execute if score __arg1 Internal < __arg2 Internal run scoreboard players set __ret Internal 1
6 changes: 6 additions & 0 deletions src/DataPack/mc-asm/data/mcasm/functions/mod.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# mod.mcfunction
# __arg1 integer A
# __arg2 integer B
# returns A % B
scoreboard players operation __ret Internal = __arg1 Internal
scoreboard players operation __ret Internal %= __arg2 Internal
6 changes: 6 additions & 0 deletions src/DataPack/mc-asm/data/mcasm/functions/mul.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# mul.mcfunction
# __arg1 integer A
# __arg2 integer B
# returns A * B
scoreboard players operation __ret Internal = __arg1 Internal
scoreboard players operation __ret Internal *= __arg2 Internal
6 changes: 6 additions & 0 deletions src/DataPack/mc-asm/data/mcasm/functions/ne.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# ne.mcfunction
# __arg1 integer A
# __arg2 integer B
# returns A != B
scoreboard players set __ret Internal 1
execute if score __arg1 Internal = __arg2 Internal run scoreboard players set __ret Internal 0
6 changes: 6 additions & 0 deletions src/DataPack/mc-asm/data/mcasm/functions/sub.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# sub.mcfunction
# __arg1 integer A
# __arg2 integer B
# returns A - B
scoreboard players operation __ret Internal = __arg1 Internal
scoreboard players operation __ret Internal -= __arg2 Internal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tellraw @a ["",{"text":"*********************\n__arg1 = "},{"score":{"name":"__arg1","objective":"Internal"}},{"text":"\n__arg2 = "},{"score":{"name":"__arg2","objective":"Internal"}},{"text":"\n__ret \u0020= "},{"score":{"name":"__ret","objective":"Internal"}}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# test_cases.mcfunction
# testing/test_function.mcfunction will be ran with the following arguments.
# this is meant to be only used while testing.

scoreboard players set __arg1 Internal 0
scoreboard players set __arg2 Internal 0
function mcasm:testing/test_function
function mcasm:testing/print_internals

scoreboard players set __arg1 Internal 10
scoreboard players set __arg2 Internal 0
function mcasm:testing/test_function
function mcasm:testing/print_internals

scoreboard players set __arg1 Internal 0
scoreboard players set __arg2 Internal 10
function mcasm:testing/test_function
function mcasm:testing/print_internals

scoreboard players set __arg1 Internal 10
scoreboard players set __arg2 Internal 20
function mcasm:testing/test_function
function mcasm:testing/print_internals

scoreboard players set __arg1 Internal 10
scoreboard players set __arg2 Internal -20
function mcasm:testing/test_function
function mcasm:testing/print_internals

scoreboard players set __arg1 Internal -100
scoreboard players set __arg2 Internal -10
function mcasm:testing/test_function
function mcasm:testing/print_internals

scoreboard players set __arg1 Internal -10
scoreboard players set __arg2 Internal -10
function mcasm:testing/test_function
function mcasm:testing/print_internals

scoreboard players set __arg1 Internal 30
scoreboard players set __arg2 Internal 30
function mcasm:testing/test_function
function mcasm:testing/print_internals
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# test_function.mcfunction
# the desired function to be tested in testing/test_cases.mcfunction.
# this is meant to be only used while testing.
function mcasm:ass
Empty file.
5 changes: 5 additions & 0 deletions src/DataPack/mc-asm/data/minecraft/tags/functions/load.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"mcasm:load"
]
}
5 changes: 5 additions & 0 deletions src/DataPack/mc-asm/data/minecraft/tags/functions/tick.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"mcasm:tick"
]
}
6 changes: 6 additions & 0 deletions src/DataPack/mc-asm/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"pack": {
"pack_format": 8,
"description": "MC-ASM Subroutines, by Gunwoo Kim, Charles Hong"
}
}