Discuss Scratch
- Discussion Forums
- » Show and Tell
- » Korona
- CaptainPeter
-
Scratcher
40 posts
Korona
Korona is an assembly-like language in Scratch made by @CaptainPeter.
Project link: https://scratch.mit.edu/projects/1090299377/
Sample code:
Project link: https://scratch.mit.edu/projects/1090299377/
Sample code:
set 1 10
add 1 5
; @1 is 15 now
- CaptainPeter
-
Scratcher
40 posts
Korona
Korona v1.0 (Initial Release)
Features:
State:
Program_Counter (default: 1)
The index in the scripts that the instruction is running
Security_Level (default: 100)
The security level of the process running, only processes can write to memory addresses that have a lower or equal security level
* Note: the “call” instruction pushes all of the state to the stack, including id->address mappings created by the “adr” instruction
Commands:
Memory Instructions:
Stack Instructions:
Jump Instructions:
Security Instructions:
Address Instructions
Display Instructions:
Loading Instructions:
* Note: All operations on memory only run if the memory security is less than or equal to Security_Level.
Features:
- Mathematical operations on memory
- A stack (call, return)
- Jumping and jumping if (equals, less than, greater than)
- Securing memory for processes
- Named instruction indexes for easier readability
- Displaying text
- Loading font data for the display to use
State:
Program_Counter (default: 1)
The index in the scripts that the instruction is running
Security_Level (default: 100)
The security level of the process running, only processes can write to memory addresses that have a lower or equal security level
* Note: the “call” instruction pushes all of the state to the stack, including id->address mappings created by the “adr” instruction
Commands:
Memory Instructions:
- clr(memoryIndex): sets memoryIndex to a blank value
- set(memoryIndex, value): sets memoryIndex to value
- cat(memoryIndex, value): appends value to memoryIndex
- add/sub/mul/div/mod(memoryIndex, value): sets memoryIndex to memoryIndexvalue
- inv(memoryIndex): inverts memoryIndex
- abs(memoryIndex): sets memoryIndex to abs(memoryIndex)
- flr(memoryIndex) sets memoryIndex to floor(memoryIndex)
- ceil(memoryIndex) sets memoryIndex to ceiling(memoryIndex)
- sqrt(memoryIndex) sets memoryIndex to sqrt(memoryIndex)
- sin(memoryIndex) sets memoryIndex to sin(memoryIndex)
- cos(memoryIndex) sets memoryIndex to cos(memoryIndex)
- tan(memoryIndex) sets memoryIndex to tan(memoryIndex)
- asin(memoryIndex) sets memoryIndex to asin(memoryIndex)
- acos(memoryIndex) sets memoryIndex to acos(memoryIndex)
- atan(memoryIndex) sets memoryIndex to atan(memoryIndex)
- ln(memoryIndex) sets memoryIndex to ln(memoryIndex)
- log(memoryIndex) sets memoryIndex to log(memoryIndex)
- epow(memoryIndex) sets memoryIndex to e^memoryIndex
- tenpow(memoryIndex) sets memoryIndex to 10^memoryIndex
- rnd(memoryIndex) sets memoryIndex to round(memoryIndex)
- rand(value, value, memoryIndex) sets memoryIndex to random(value, value)
- mal(id): finds a memory address with security 0 and maps id to this address
- free(id): sets the security of id->address to 0 and removes the mapping of id->address
Stack Instructions:
- call(instructionIndex, securityLevel): pushes STATE to the stack, sets Security_Level to securityLevel, and jumps to instructionIndex
- ret(): pops the last item in the stack
Jump Instructions:
- jump(instructionIndex): sets Program_Counter to instructionIndex
- je/jl/jg(value, value, instructionIndex): if valuevalue, sets Program_Counter to instructionIndex
- jne/jnl/jng(value, value, instructionIndex): if not valuevalue, sets Program_Counter to instructionIndex
Security Instructions:
- sec(memoryIndex, securityLevel): sets the security level of memoryIndex to securityLevel
- rel(memoryIndex): sets the security level of memoryIndex to 0
- lvl(securityLevel): sets Security_Level to securityLevel if securityLevel is less than Security_Level
Address Instructions
- adr(id): maps id->instructionIndex, given the current Program_Counter as instructionIndex
Display Instructions:
- txt(text, x, y, size, weight, color): adds the draw request to the display queue
- clear(): adds a request to the display queue to clear the screen
- flush(): handles all requests in the display queue
- mtxt(text, size, weight, memoryIndex): sets memoryIndex to the width of the text
Loading Instructions:
- load(type , resource): loads resource into Korona.
* Note: All operations on memory only run if the memory security is less than or equal to Security_Level.
- CaptainEterk
-
Scratcher
2 posts
Korona
Korona v1.0.5
Features:
Dynamic Jumping
The “jump” command can now jump to a dynamic location. When it is called, the command finds the location with the value of “> address_name skip (optional)”
The “skip” keyword prevents the code from being executed without the “jump” or “call” instruction. When it is run, it will skip to the value that has “< address_name”
Example (not skipping):
Example (skipping):
Commands:
Memory Instructions
Display Instructions
Script Instructions
Features:
- Substring operations on memory
- Dynamic jumping
- Displaying rectangles (rect)
- Runtime script modification
Dynamic Jumping
The “jump” command can now jump to a dynamic location. When it is called, the command finds the location with the value of “> address_name skip (optional)”
The “skip” keyword prevents the code from being executed without the “jump” or “call” instruction. When it is run, it will skip to the value that has “< address_name”
Example (not skipping):
> address_name
flush
< address_name
call #address_name
Example (skipping):
> address_name skip
; Code here
< address_name
call #address_name
Commands:
Memory Instructions
- str(memoryIndex, value, start, end=length(value) ): sets memoryIndex to a substring of value given start and end.
Display Instructions
- rect(x, y, width, height, smoothness, color): Draws a rectangle centered at (x, y) given width, height, smoothness, and color.
Script Instructions
- script(instructionIndex, value): sets the instruction at instructionIndex to value
- CaptainPeter
-
Scratcher
40 posts
Korona
Korona v1.1
Features:
Commands:
Script Instructions:
Music Instructions:
* This changed a command
Features:
- Music
- Inserting scripts
Commands:
Script Instructions:
- *script(instructionIndex, value): inserts the instruction at instructionIndex to value
Music Instructions:
- note(note, beats): plays “note” for the given number of beats.
- ins(instrumentIndex): sets the instrument to “instrumentIndex.” (e.g. 1 -> piano, 2 -> electric piano)
- tmp(tempo): sets the tempo to “tempo”
* This changed a command
- Discussion Forums
- » Show and Tell
-
» Korona