Comments (1)
Thank you for a wonderful question!
jl
jumps if: SF <> OFjs
jumps if: SF = 1neg
changes CF (if operand = 0, CF = 0) , OF, SF, ZF, AF, and PF.
Usually, js
will do the trick except for one case: if rax
is equal to the smallest signed integer. It is because the range of 64-bit integers is asymmetric: -2^64 ... 2^64 - 1. When rax
is the smallest negative integer, its 2 complement (computed by neg
) is the same and as the result we get stuck in a loop. Let's study these two examples:
Normal case: rax = -10
label: ; rax = -10
neg rax ; rax = 10, CF, PF, AF set
js label ; OK, no jump
Corner case: rax = -2^64 = 0x80 00 00 00 00 00 00 00
label: ; rax = -2^64
neg rax ; rax = -2^64, CF, PF, SF, OF are set
js label ; `rax` is still negative and won't change its sign.
Now we are stuck performing neg
(which has no effect) and js
till the end of the world.
However, notice, that both SF and OF are set in this case. This is the exact situation when jl
will prevent us from being stuck in a loop.
from low-level-programming.
Related Issues (20)
- Debian Virtual Machine: git clone: could not resolve host github.com HOT 2
- Question / Answers: Combined HOT 1
- Question 44 typo HOT 2
- SSH into VM not working HOT 2
- typo in errata HOT 2
- error when run on Mac HOT 1
- VirtualBox display resolution HOT 3
- Q34 HOT 1
- Q39 HOT 1
- Q70 HOT 1
- Assignment: Dictionary
- Section 1.3.1 HOT 2
- Docker setup HOT 3
- Missing answers to questions HOT 1
- There is no need in having `pyc` files present in the repository
- Python scripts compatibility
- Virtual Machine
- Question 22 HOT 2
- Nasm can't create output file
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from low-level-programming.