Skip to content

Commit 658d814

Browse files
committed
transfer-lamports: Remove one instruction from ASM
1 parent c37ac49 commit 658d814

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ lets the VM assume it worked.
164164
| Rust | 464 |
165165
| Zig | 186 |
166166
| C | 103 |
167-
| Assembly | 23 |
167+
| Assembly | 22 |
168168

169169
This one starts to get interesting since it requires parsing the instruction
170170
input. Since the assembly version knows exactly where to find everything, it can

transfer-lamports/asm/main.s

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
.text
21
.globl entrypoint
32
entrypoint:
43
ldxdw r2, [r1 + 0] # get number of accounts
@@ -8,14 +7,13 @@ entrypoint:
87
ldxdw r2, [r1 + 8 + 8 + 32 + 32] # get source lamports
98
ldxdw r3, [r1 + 8 + 8 + 32 + 32 + 8] # get account data size
109
mov64 r4, r1
11-
add64 r4, 8 + 8 + 32 + 32 + 8 + 8 + 10240 # calculate end of account data
10+
add64 r4, 8 + 8 + 32 + 32 + 8 + 8 + 10240 + 8 # calculate end of account data
1211
add64 r4, r3
1312
mov64 r5, r4 # check how much padding we need to add
1413
and64 r5, 7 # clear high bits
1514
jeq r5, 0, 1 # no low bits set, jump ahead
1615
add64 r4, 8 # add 8 for truncation if needed
1716
and64 r4, -8 # clear low bits
18-
add64 r4, 8 # rent epoch
1917
ldxb r5, [r4 + 0] # get second account
2018
jne r5, 0xff, error # we don't allow duplicates
2119
ldxdw r5, [r4 + 8 + 32 + 32] # get destination lamports

0 commit comments

Comments
 (0)