- Simon816
- Registered Member
-
Member for 12 years, 3 months, and 19 days
Last active Wed, May, 24 2023 19:45:53
- 1 Follower
- 96 Total Posts
- 9 Thanks
-
Jul 11, 2014Simon816 posted a message on The New Minecraft Forum is Now Live!Ahah! It now redirects to http://www.minecraftforum.net/news.rss instead of 404. Thanks whoever did that!Posted in: News
-
Jul 4, 2014Simon816 posted a message on The New Minecraft Forum is Now Live!Aww. I hope it comes back because I'll miss many news posts.Posted in: News
RSS is literally designed for news so it seems odd to be missing that feature. -
Jul 4, 2014Simon816 posted a message on The New Minecraft Forum is Now Live!What is the new RSS URL? I had been wondering why there were no new posts in the last few days but now I find that http://www.minecraftforum.net/rss/writ/1-news/ no longer exists. Is there a button or something that I'm missing?Posted in: News
- To post a comment, please login.
0
[Original README here: https://github.com/simon816/Command-Block-Assembly]
Command Block Assembly
Now with 99% less command blocks
Command Block Assembly is a tool that allows you to write assembly instructions that compile down into Minecraft commands.
With the introduction of Functions in Minecraft 1.12, Command Block Assembly now outputs functions. Functions greatly increase the speed of execution, so Command Block Assembly keeps the usage of command blocks to a minimum.
C Compiler
There is a C compiler that compiles to this assembly language, read more here.
The Assembly Language
It is a simple language with instructions similar to that of x86.
Syntax
Here's a description of the syntax in rough BNF:
What this actually looks like:
Instruction Set
ADD src, dest
Adds src to dest
SUB src, dest
Subtracts src from dest
MUL src, dest
Multiplies dest by src
DIV src, dest
Divides dest by src
MOD src, dest
Performs dest modulo src and puts into dest
MOVLT src, dest
Sets dest equal to src if src is less than dest
MOVGT src, dest
Sets dest equal to src if src is greater than dest
XCHG left, right
Exchanges left with right
MOV src, dest
Copies src to dest
AND src, dest
Performs bitwise AND, result put into dest
OR src, dest
Performs bitwise OR and puts into dest
XOR src, dest
Performs bitwise XOR and puts into dest
NOT ref
Performs bitwise NOT on ref
SHL src, dest
Logical shift dest left by src
SHR src, dest
Logical shift dest right by src
SAR src, dest
Arithmetic shift dest right by src
ROL src, dest
Rotates dest left by src
ROR src, dest
Rotates dest right by src
CMP left, right
Compares left with right (i.e. right - left), result used for jumping
JE label
Jumps to label if the previous CMP's operands were equal
JNE label
Jumps to label if the previous CMP's operands were not equal
JL label
Jumps to label if the previous CMP's right was less than left
JG label
Jumps to label if the previous CMP's right was greater than left
JLE label
Jumps to label if the previous CMP's right was less than or equal to the left
JGE label
Jumps to label if the previous CMP's right was greater than or equal to the left
JMP label
Unconditionally jumps to label
CALL label
Jumps to label, returns back after completion
RET
Return from a subroutine (use with CALL)
PRINT arg1, [...args]
Outputs arguments to chat for all players (@a selector)
CMD bare words
Runs the given command
TEST bare words
Runs the given command, skipping the next line if the command failed
PUSH
Pushes stack register onto the stack, increments stack pointer
POP
Pops stack into stack register, decrements stack pointer
SYNC
Synchronises with the game tick. i.e. wait one tick before continuing
Operand types
There are 2 'types' of referencing:
Constants must be a value reference, and can be used anywhere that accepts value references.
For the instructions above, their accepted types are as follows:
A src can be any value reference.
dest must be a memory location reference.
SWP's left and right must both be memory location references.
CMP's left and right can be any value reference.
A label must be a label reference.
"Bare words" are taken as the literal string value until the end of the line. Note that this means comments are interpreted as part of the bare word.
Constants
As shown in the syntax, constants are defined with "." followed by their name, a space, then the value.
Constants can only be value references, but can be any type of value reference.
There are two predefined constants:
sp (Stack pointer)
The current value of the stack pointer. Should be treated as read-only unless you know what you're doing.
sr (Stack register)
Used to get values to/from the stack.
POP puts the top of the stack into the register, PUSH puts stack register at the top of the stack.
Directives
Directives are a kind of meta-program language that instruct the assembler to perform certain functions.
The following directives are supported:
#include filename.asm
Pulls in code from filename.asm in-place. Has the same effect as copy+pasting all the code from the file into wherever the directive is.
#include_h filename.asm
"Include headers". Does not load any code from the file, but pulls in the symbol table (subroutines, constants).
Useful for using library code already running in the game. (i.e. library was loaded sometime beforehand).
Memory locations
Memory locations can be thought of like locations in RAM, however there are a few things you need to know.
You can't reference locations indirectly (e.g. pointers).
Locations are actually just scoreboard objectives, and are computed at compile-time. They are really only useful for storing temporary data and using as global names (like sp and sr).
It is not possible to dynamically reference scoreboard objectives (or function names, for that matter). So you can't do something like MOV #1, [loc] (move literal 1 to the address stored in loc).
The only way to have truly real memory is using something like hdd_driver (see examples) or a giant lookup table. (Something like if(addr==0) objective_0=buffer else if (addr==1) objective_1=buffer ...)
This is how the stack is implemented, it performs a lookup on the current sp value.
The Assembler
The assembler is invoked by calling main.py.
Command line parameters:
Notes:
If --world-dir is not provided, no functions are written. This can be useful in combination with --debug.
--place-location is where to start laying out command blocks, should they be needed. Defaults to ~1,~,~1
--arg is used to pass values in to a program that get replaced in the output. They are currently only applicable in CMD and TEST instructions. e.g.
Running python main.py test.asm --debug --arg "name=Simon" --arg "date=24/10/2017" produces:
Running a program
In order to run a subroutine (main is a good name for the entry point), you need to run the jump command.
e.g. to run a subroutine named main, use --jump main, this will output the exact command to run.
The first time a program is loaded into a world, the setup command must be ran before any function calls are made.
The setup command is outputted by the assembler.
The assembler also outputs a cleanup function, which performs the opposite operation to setup. If command blocks are placed by the setup command, the cleanup command will remove them. If a relative --place-location was used, the cleanup must be executed from the same location that setup was ran from.
Note: the /execute command is required for the subroutine jump. Don't be tempted to run /function directly.
Examples
Examples can be found in the examples directory.
fib.asm
Prints the fibonacci sequence until the next integer overflows.
hdd_driver.asm
An example of how the assembly code can make use of the world.
The "hard drive" is represented by blocks in the world. An air block represents 0, stone = 1.
In this example, data is stored in a 2D plane on the x and z axis.
A memory location loc is stored at x = loc / MEM_SIZE_X, z = loc % MEM_SIZE_Z
The value is then WORD_SIZE bits in the y axis. i.e. for an 8-bit word, y=0 is the LSB, y=7 is the MSB.
hdd_driver.asm is a library file, and exports the read_mem, write_mem subroutines along with its constants.
The location where the memory region is defined must be passed in to the assembler:
--arg "mem_loc=0 0 0"
mem_test.asm
A simple test of the hdd_driver library. See description at the top of the file.
Issues and nuances
The SYNC instruction (and how it affects CALL and RET)
Command Block Assembly is designed to produce fast and efficient functions, avoiding expensive operations wherever possible.
As such, some features are optimized unless it is not possible.
By default, a CALL instruction will add a /function command to run the subroutine.
This means that once the function finishes, execution continues at the next command.
This behaviour is the anticipated use of CALL, however the implication is that RET has no effect.
Originally, there was going to be an implied return after a subroutine. i.e. always return to caller if CALL is ran.
But the RET instruction is required for SYNC to work, so it was added.
As stated in the instruction description, SYNC effectively "pauses" the current execution until one tick later.
The current calling stack (nested /function calls) will always return to the caller and continue on the next line.
SYNC must nullify the next call so the calling stack returns and the game runs a tick.
However, this is not possible with CALL's guarantee to return to caller.
Therefore, CALL must push the address of the next instruction onto the stack, letting RET pop it off later.
With that, it is now possible to cause an interrupt between CALL and the subsequent RET.
This is how you would expect CALL and RET to function, but doing so is less efficient for the common use-case.
By default, SYNC is disabled. The use of RET prints a warning to stderr saying how it doesn't have any effect. If the program is anticipated to use SYNC, you should defensively use RET anyway. Just keep in mind how the optimization works.
To use SYNC, enable it with --enable-sync.
CMP and jumping
Due to there being no concept of a "status" register, jump instructions don't check flags of any sort.
Instead, they evaluate the most recent CMP instruction.
The assembler keeps a reference to the most recent CMP instruction. If a conditional jump instruction is encountered, it fetches this CMP to decide whether to jump or not.
A more accurate conditional jump could be an instruction that takes 3 arguments e.g: JL left, right, label. However writing out the comparison is clunky when performing a succinct multi-jump like this:
Signed bitwise operations
The bitwise operations (e.g. AND, SHR, ROL) have not been tested for correct handling of negative values. Use with caution.
0
None of the above plugins are made by the spongepowered project, they are independent developers
Each plugin has a post on the sponge forums, you can find all plugins on the Plugins subforum
https://forums.spongepowered.org/c/plugins
Edifice by Zirconium:
https://forums.spongepowered.org/t/house-edifice-create-and-share-structures-api-5-0-0/12465
ChatUI by simon816 (me):
https://forums.spongepowered.org/t/chat-ui-a-ui-toolkit-for-the-vanilla-chat-box/10109
(admittedly this plugin is not fully released yet but it will be soon(tm))
(yes I am part of the sponge developer team but I make independent stuff too)
Project Portals by TrenTech:
https://forums.spongepowered.org/t/project-portals-v0-13-4/10438
0
I heard in #ChickenBones IRC that FMP is kind of abandoned at this point. It may be worth looking in to MCMultiPart https://github.com/amadornes/MCMultiPart
Quote:
0
The wiki is http://projectredwiki.com/wiki/Main_Page
0
That crash is clearly indicating BiblioCraft, there's no reference to Project Red anywhere
0
You haven't provided any crash information. However, it looks like you are trying to use the 'Mechanical' module, but don't have 'Integration', you must have Integration in order to use Mechanical.
3
See this dependency graph
0
It is fine for me, and I don't see how there's a problem with cloudflare's connection to the website.
Try using a proxy, for example http://7.hidemyass.com/ip-1/encoded/Oi8vcHJvamVjdHJlZHdpa2kuY29tL3dpa2kvTWFpbl9QYWdl&f=norefer
It works when I test with a proxy too.
0
Works fine for me http://projectredwiki.com/ I don't know why it would be erroring just for you. You could connect using a proxy instead.
0
There's no such thing as (integer) item IDs anymore, so no.
Why would you need to change it anyway?
0
There's a bunch of issues from other mods but none are (as far as I can see) causing MC to crash.
The very last line states: "Minecraft crashed with exitcode -805306369."
Which according to http://hopper.minecraft.net/help/exit-code/code-805306369/ Java ran out of memory
Looking at your startup arguments, you could try increasing -XX:PermSize to 512M or 1G
0
I can't seem to see what's causing the problem but there is something wrong with MrTJPCore, try re-downloading the latest version from http://projectredwiki.com/wiki/MrTJPCore_version_archive
0
You haven't even got Project Red on the mod list there. Regardless, this is a simple issue: you've installed the dev version of CoFHCore so it obviously won't work. Replace it with a standard release instead.
I've even got a link for you: http://minecraft.curseforge.com/mc-mods/69162-cofhcore/files/2218331
0
I'm just going to show you some posts from MrTJP
[quote=Mr_TJP;/members/Mr_TJP;/forums/mapping-and-modding/minecraft-mods/1290357-forge-multipart-projectred-v4-5-6-57-11-20-2014?comment=3218]
The elusive frame block. Coming Soon (TM).
0
Its correct place is in the 1.7.10 folder. However your Forge Mulitpart is corrupt, delete it and it should auto download. Otherwise, download from http://files.minecraftforge.net/ForgeMultipart/