Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add memory allocation opcode. #18

Merged
merged 1 commit into from
Dec 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions opcodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
- [CFS: Shrink call frame](#cfs-shrink-call-frame)
- [LB: Load byte](#lb-load-byte)
- [LW: Load word](#lw-load-word)
- [MALLOC: Allocate memory](#malloc-allocate-memory)
- [SB: Store byte](#sb-store-byte)
- [SW: Store word](#sw-store-word)
- [Contract Opcodes](#contract-opcodes)
Expand Down Expand Up @@ -413,6 +414,16 @@ All these opcodes advance the program counter `$pc` by `4` after performing thei
| Encoding | `00010110 rd rs i i` |
| Notes | |

### MALLOC: Allocate memory

| | |
| ----------- | ---------------------------------------------------------- |
| Description | Allocate a number of bytes from the heap. |
| Operation | ```alloc MEM[$hp - $rs, $rs];```<br>```$hp = $hp - $rs;``` |
| Syntax | `malloc $rs` |
| Encoding | `00000000 rs - - -` |
| Notes | Does not initialize memory. |

### SB: Store byte

| | |
Expand Down