当前位置:网站首页>Arithmetic and logical operations
Arithmetic and logical operations
2022-04-23 05:26:00 【What’smean】
Write it at the front
Pictured here x86-64 Some integer and logical operations of . Most of these instructions have various variants with operands of different sizes .eg:ADD It consists of four addition instructions : addb、addw、addl and addq, They are byte addition 、 Word addition 、 Double word addition and four word addition ;lea Command variant ( Sort by size ):leaw 、leal、leaq, They are word addition 、 Double word addition and four word addition .

These operations are divided into four groups : Load valid address 、 Unitary operation 、 Binary operation and shift . One of the unary operations has an operand , Binary operations have two operands .
Load valid address leaq
leaq S,D
leaq: In form, it reads data from memory to register , In fact, the valid address is written to the destination operand .
eg:
c Language
long scale(long x,long y,long z){
long t = x +4* y + 12*Z;
return t;}
Compile time , The arithmetic operation of this function takes three leaq Instructions implement :
long scale(long x, long y,long z)
x in %rdi, y in %rsi,z in %rdx
scale:
leaq (%rdi,%rsi,4),%rax //x+4*y
leaq (%rdx, %rdx,2),%rdx //z +2*z =3*z
leaq (%rax,%rdx,4), %rax //(x+4*y)+4*(3*z)=x +4*y +12*z
ret
Unary and binary operations
Unitary operation

A unary operation has only one operand , This operand even if the source operand is the destination operand , The operand can be a register , It can also be a memory location .
eg:decq (%rsp) // Make stack top 8 Byte element -1 Be similar to C In language --
incq (%rsp) // Make stack top 8 Byte element +1 Be similar to C In language ++
Binary operation

Binary operations have two operands , The second operand is both the source operand and the destination operand . This grammar is similar to C Assignment operators in languages , for example x-=y.
The first operand source operand can be an immediate number 、 Register or memory location .
The operand of the second operand can be a register or a memory location . Be careful , When the second operand is a memory address , The processor must read the value from memory , Perform the operation , Then write the result back to memory .
Shift operation

Shift operation , The first item first gives the amount of shift , Then the second term gives the number to be shifted ; It is divided into arithmetic shift and logical shift .
The first shift can be an immediate number , Or put it in a single byte register %cl in .( notes : Only this specific register is allowed as an operand ).
The shift left command has two names :SAL and SHL. The effect is the same , Fill in... On the right 0.
The shift right command is different ,SAR Perform arithmetic shift ( Fill in the sign bit ), and SHR Perform logical shift ( Fill in the 0).
The destination operand of the shift operation can be a register or a memory location .
Learn from 《 Deep understanding of computer systems 》
版权声明
本文为[What’smean]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220544124856.html
边栏推荐
- If I am PM's performance, movie VR ticket purchase display
- Asynchronous iterator & asynchronous generator & asynchronous context manager
- Three 之 three.js (webgl)旋转属性函数的简单整理,以及基于此实现绕轴旋转的简单案例
- egg中的多进程模型--egg文档搬运工
- To understand Devops, you must read these ten books!
- How to set the initial value of El input number to null
- 狼叔来找翻译人员了--plato--持续翻译中.....
- JSON.
- 2021-11-01
- Source code analysis of how to use jump table in redis
猜你喜欢

selenium預先加載cookie的必要性

JS array common methods

Necessity of selenium preloading cookies

Quick app bottom navigation bar

Requirements for SQL server to retrieve SQL and user information

Blender programmed terrain production

(十一)vscode代码格式化配置

Low code and no code considerations

Laravel routing job

Solution of how to log in with mobile phone verification code in wireless network
随机推荐
Use of uniapp native plug-ins
Kanban Quick Start Guide
Vscode settings JSON configuration
what is wifi6?
Use of ES6 array
Traversal array, object parent-child communication props / $emit
Log introduction and building web application
Redis in node -- ioredis
史上最强egg框架的error处理机制
Uniapp hot update with progress bar
Study notes: unity customsrp-13-colorgrading
String class understanding - final is immutable
Why can't V-IF and V-for be used together
egg中的cors和proxy(づ ̄3 ̄)づ╭~踩坑填坑的过程~ToT~
Laravel routing job
Study notes: unity customsrp-11-post processing --- bloom
Project manager's thinking mode worth trying: project success equation
Laravel [view]
Camera imaging + homography transformation + camera calibration + stereo correction
4 most common automated test challenges and Countermeasures