Skip to content

Enable the use of put and get when writing to the device index.#11

Open
gregwinn wants to merge 3 commits intoawilliamson:masterfrom
gregwinn:master
Open

Enable the use of put and get when writing to the device index.#11
gregwinn wants to merge 3 commits intoawilliamson:masterfrom
gregwinn:master

Conversation

@gregwinn
Copy link
Copy Markdown

This PR adds syntax highlighting and support for the put and get instructions, which are essential for working with the device base (db) storage in IC10.

Overview

The put and get instructions allow reading from and writing to the device base's internal storage, providing a way to:

  • Create device name mappings for batch operations
  • Store temporary values when register space is limited
  • Implement pseudo-stack functionality for complex programs
  • Preserve state across function calls

Syntax

put db # Write source value to db at index
get db # Read value from db at index into dest

Usage Examples

Example 1: Device Name Table for Batch Operations

define HASH_OF_DEVICE 123456789
alias CurrentDeviceIndex r0
alias CurrentDevice r1
init:
  # Store device name hashes in indices 0-7
  put db 0 HASH("IC00")
  put db 1 HASH("IC01")
  move CurrentDeviceIndex 0
main:
  yield
  # Retrieve device hash from storage
  get CurrentDevice db CurrentDeviceIndex
  # Use retrieved hash for batch operations
  sbn HASH_OF_DEVICE CurrentDevice On 1
  j main

Example 2: Temporary Value Storage

# Store register value for later use
put db 100 calcResult

# Store literal value
put db 101 1234

# Retrieve stored values
get r15 db 100      # r15 now contains the value that was in calcResult
get calcResult db 101  # calcResult now contains 1234

Storage Indices

  • Indices 0-7: Reserved for device name hash mappings used with batch commands
  • Indices 8+: Available for general purpose storage
  • Common practice: Use indices 100+ for temporary storage to clearly separate from device mappings

Use Cases

  1. Function Call Preservation: Save return addresses or register values across nested function calls
  2. Extended Storage: Overcome the 16-register limitation by using db as additional memory
  3. Device Management: Dynamically reference devices without hardcoding to d0-d5 pins
  4. State Machines: Store state information that persists across yield cycles

This addition improves IC10 language support by recognizing these commonly used but previously unsupported instructions.

@awilliamson awilliamson requested a review from Copilot June 20, 2025 18:59
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for the new IC10 language instructions "put" and "get" by updating the syntax highlighting file, updating the package version, and documenting the changes in the CHANGELOG.

  • Added "put" and "get" keywords to the ic10.tmLanguage.json regex
  • Updated package.json to version "0.4.1" to reflect the new features
  • Documented the changes in CHANGELOG.md

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
syntaxes/ic10.tmLanguage.json Updated regex to include the "put" and "get" keywords for syntax support
package.json Downgraded the version from "0.7.4" to "0.4.1" – review versioning semantics
CHANGELOG.md Added entry for version "0.4.1" documenting the new syntax support

"description": "IC10 MIPS-like Language Support for Stationeers - Featuring completions, hover information, signature help, goto definition, diagnostics, and more.",
"publisher": "AshleyWilliamson",
"version": "0.7.4",
"version": "0.4.1",
Copy link

Copilot AI Jun 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package version was decreased from 0.7.4 to 0.4.1, which may conflict with semantic versioning conventions. Consider revising the version to reflect an increment for the new feature additions.

Suggested change
"version": "0.4.1",
"version": "0.8.0",

Copilot uses AI. Check for mistakes.
@sbularca
Copy link
Copy Markdown

sbularca commented Oct 23, 2025

I was preparing to add support for more keywords and in order to work we need an update for the ic10lsp language server as well. I did a pull request there and hopefully we can get this going. If you want to test the new release, here is the exe. Add it to c:\Users\.....\.vscode\extensions\ashleywilliamson.ic10-language-support-0.7.4\bin\

@sbularca
Copy link
Copy Markdown

sbularca commented Oct 23, 2025

Also, here is the full list of current keywords, if you want to update the json

l|s|ls|lr|sb|lb|alias|move|add|sub|sdse|sdns|slt|sgt|sle|sge|seq|sne|sap|sna|and|or|xor|nor|mul|div|mod|j|bltz|bgez|blez|bgtz|bdse|bdns|beq|bne|bap|bna|jal|brdse|brdns|bltzal|bgezal|blezal|bgtzal|beqal|bneal|jr|bdseal|bdnsal|brltz|brgez|brlez|brgtz|breq|brne|brap|brna|sqrt|round|trunc|ceil|floor|max|min|abs|log|exp|rand|yield|label|peek|push|pop|hcf|select|blt|bgt|ble|bge|brlt|brgt|brle|brge|bltal|bgtal|bleal|bgeal|bapal|bnaal|beqz|bnez|bapz|bnaz|breqz|brnez|brapz|brnaz|beqzal|bnezal|bapzal|bnazal|sltz|sgtz|slez|sgez|seqz|snez|sapz|snaz|define|sleep|sin|asin|tan|atan|cos|acos|atan2|get|getd|put|putd|bnan|brnan|lbn|lbns|lbs|not|sbn|sbs|sla|sll|sra|srl|snan|snanz|ss|bdnvl|bdnvs

@sbularca
Copy link
Copy Markdown

Check your package version number, it does not seem correct to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants