【Solidity Yul Assembly】4.3 | What We Didn't Cover

  • 0xE
  • 发布于 2024-09-11 17:35
  • 阅读 1087

在这最后一节,我们将看一些 Yul 中相对较少使用的指令。

虽然在之前的课中我们已经涵盖了 Yul 的大部分常用指令,但这次我们会简要介绍那些使用频率较低的指令,为本系列课程画上句号。

指令 描述
sdiv(x, y) x / y, for signed numbers in two’s complement, 0 if y == 0
smod(x, y) x % y, for signed numbers in two’s complement, 0 if y == 0
slt(x, y) 1 if x < y, 0 otherwise, for signed numbers in two’s complement
sgt(x, y) 1 if x > y, 0 otherwise, for signed numbers in two’s complement
sar(x, y) signed arithmetic shift right y by x bits
signextend(i, x) sign extend from (i*8+7)th bit counting from least significant
addmod(x, y, m) (x + y) % m with arbitrary precision arithmetic, 0 if m == 0
mulmod(x, y, m) (x * y) % m with arbitrary precision arithmetic, 0 if m == 0
byte(n, x) nth byte of x, where the most significant byte is the 0th byte
stop() stop execution, identical to return(0, 0)
invalid() end execution with invalid instruction

1. sdiv(x, y)

  • 执行有符号整数除法,适用于二进制补码形式的有符号数。
  • y == 0,结果返...

剩余50%的内容订阅专栏后可查看

点赞 0
收藏 0
分享

0 条评论

请先 登录 后评论
0xE
0xE
0x59f6...a17e
17年进入币圈,Web3 开发者。刨根问底探链上真相,品味坎坷悟 Web3 人生。有工作机会可加v:__0xE__