You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In MASM, use the `word("...")` syntax to define named storage slot constants. The `word()` function hashes the slot name to produce a `Word`, and you extract the slot ID using `[0..2]` slice notation:
The `set_map_item` procedure now takes slot IDs and returns only old values:
48
78
@@ -52,14 +82,16 @@ The `set_map_item` procedure now takes slot IDs and returns only old values:
52
82
- # Returns: [OLD_MAP_ROOT, OLD_VALUE, ...]
53
83
54
84
+ # After
55
-
+ exec.account::set_map_item
85
+
+ exec.native_account::set_map_item
56
86
+ # Returns: [OLD_VALUE, ...]
57
87
```
58
88
59
89
:::info Good to know
60
90
The return value change means you may need to update stack manipulation after calling `set_map_item`.
61
91
:::
62
92
93
+
For details on the `word("...")` syntax, see the [MASM Changes](06-masm-changes.md#named-storage-slots) migration page. For the full list of storage procedures, see the [Protocol Library Reference](../../design/miden-base/protocol_library.md).
Copy file name to clipboardExpand all lines: versioned_docs/version-0.13/builder/migration/06-masm-changes.md
+43-9Lines changed: 43 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -80,6 +80,37 @@ sed -i 's/use\./use /g' *.masm
80
80
81
81
---
82
82
83
+
## Named Storage Slots
84
+
85
+
:::warning Breaking Change
86
+
Storage access is now name-based, not index-based. Use `word("...")` to derive slot IDs from names.
87
+
:::
88
+
89
+
In v0.13, account storage slots are identified by name rather than numeric index. In MASM, the `word("...")` syntax computes a deterministic slot ID from a slot name string:
- Define slot constants using `word("slot_name")` instead of integer indices
106
+
- The `word()` function hashes the name string to produce a `Word` (4 field elements)
107
+
- Use `[0..2]` slice notation to extract the slot ID (first 2 elements) for kernel procedures like `get_item` and `set_item`
108
+
- Slot names should follow the `project::component::slot` naming convention to avoid collisions
109
+
110
+
For more details on storage slot naming conventions, see [Account Storage](../../design/miden-base/account/storage.md). For the full list of storage procedures, see the [Protocol Library Reference](../../design/miden-base/protocol_library.md).
Copy file name to clipboardExpand all lines: versioned_docs/version-0.13/design/miden-vm/user_docs/assembly/code_organization.md
+17Lines changed: 17 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -270,6 +270,23 @@ begin
270
270
end
271
271
```
272
272
273
+
#### Word constants from strings
274
+
275
+
A word constant can also be derived from a string using the `word("...")` syntax. This computes a deterministic `Word` by hashing the provided string with Blake3 and mapping the result to four field elements:
push.MY_IDENTIFIER # pushes all 4 elements of the derived word
282
+
push.MY_IDENTIFIER[0..2] # pushes only the first 2 elements (slice notation)
283
+
end
284
+
```
285
+
286
+
The `word("...")` constructor can be combined with [slice notation](#constant-slices) just like array-based word constants. This is commonly used for named storage slot IDs in Miden account programs.
287
+
288
+
Similarly, the `event("...")` syntax derives a single field element from a string, for use with `emit` instructions.
289
+
273
290
### Types
274
291
275
292
Miden Assembly supports types for the purpose of specifying the _type signature_ of a procedure. This is used by other tooling in the Miden toolchain to bind against procedures written in Miden Assembly from higher-level languages, e.g. Rust. The type system is low-level and structural, but some conveniences are provided in Miden Assembly to improve ergonomics and aid in the construction of future static analyses.
0 commit comments