Assembly Computer on Scratch! Controls: Space: New Line Down Arrow: Run Assembly Up Arrow: Stop Assembly Left Arrow: Clear Assembly Instructions: MOV <reg>, <reg/mem> - Push arg 2 into argument 1 PUSH <reg/mem> - Push arg 1 onto top of memory stack POP <reg/mem> - Pop top of memory stack into arg 1 INC <reg/mem> - Increment arg 1 by 1 DEC <reg/mem> - Decrement arg 1 by 1 AND <reg/mem> <reg/mem> - AND logic gate OR <reg/mem> <reg/mem> - OR logic gate XOR <reg/mem> <reg/mem> - XOR logic gate NOT <reg/mem> - NOT logic gate HALT - Stop program JMP <reg/mem> - Jump to arg 1 AND <reg/mem> <reg/mem> - Add arg 2 to arg 1 SUB <reg/mem> <reg/mem> - Sub arg 2 from arg 1 MUL <reg/mem> <reg/mem> - Multiply arg 2 by arg 1 DIV <reg/mem> <reg/mem> - Divide arg 2 by arg 1 SYSCALL - Call system command (set EAX before) CMP <reg/mem> <reg/mem> - compare arg1 and arg2 Conditionals ( use CMP before ): <label> = line of code je <label> (jump when equal) jne <label> (jump when not equal) jz <label> (jump when last result was zero) jg <label> (jump when greater than) jge <label> (jump when greater than or equal to) jl <label> (jump when less than) jle <label> (jump when less than or equal to) Registers: EAX EBX ECX EDX EDI ESP ESI EBP EAX Instructions: 1 - Shutdown System 2 - Reset Memory and Registers 3 - Get input : ECX Text, EDX Bytes 4 - Write Output : ECX Text, EDX Bytes 5 - Pixel : EBX x, ECX y, EDX light, EBP r, ESP g, EDI, b 6 - Clear Screen ^ ( all ) Sets EAX to return status, usually 1 To Do: LEA call - subroutine ret - return Example Programs: Hello, World! ---------------------------- MOV EAX 4 MOV ECX "Hello, World!" MOV EDX 13 SYSCALL ---------------------------- Counter ---------------------------- MOV ESP 0 INC ESP MOV EAX 4 MOV ECX ESP MOV EDX 128 SYSCALL JMP 1 ---------------------------- RGB Square: ---------------------------- MOV EAX 5 MOV EBX -240 MOV ECX 180 MOV EDX 100 MOV ESP 0 MOV EDI 0 MOV EAX 5 INC EBX INC EBP SYSCALL CMP EBX 15 JNE 7 MOV EBX -240 MOV EBP 0 INC EDI DEC ECX CMP ECX -75 JNE 7 ----------------------------
I got bored and wanted to make a computer in scratch, but binary logic was far too slow, so i made the next best thing: assembly :) -> Based upon x86-64 ^ Examples in Instructions (scroll down) I would recommend using TurboWarp for more complex programs (https://turbowarp.org/853427716/turbo) Assembly can also be programmed using the functions in the project, same syntax as the project when ran.