Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sporeventexplosion/one-byte-inc
Increment a variable on x86-64 with just 1 byte!
https://github.com/sporeventexplosion/one-byte-inc
assembly x86 x86-64
Last synced: about 2 months ago
JSON representation
Increment a variable on x86-64 with just 1 byte!
- Host: GitHub
- URL: https://github.com/sporeventexplosion/one-byte-inc
- Owner: sporeventexplosion
- License: gpl-3.0
- Created: 2024-11-02T22:18:02.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2024-11-02T22:22:35.000Z (3 months ago)
- Last Synced: 2024-11-10T05:25:13.769Z (3 months ago)
- Topics: assembly, x86, x86-64
- Language: C
- Homepage:
- Size: 44.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 1-Byte INC in 64-bit code!
![Logo](/logo.png)
Are you still mad at AMD for destroying the one-byte encoding of INC when they stomped over the whole row from 40h to 4Fh with their newfangled "REX" prefixes?
Think of the code density!
Be mad no more with `one_byte_inc`!!!As we all know, x86-64 CPUs all support *compatibility mode*, so the instruction decoder still needs to support the 1-byte INC.
If only we can access it in 64-bit code...Well, now you can!!!
## Usage
Simply include `one_byte_inc.h` in your source and link with `-lone_byte_inc`.
In your code, initialize the library using `init_one_byte_inc()`, which returns 0 on success.
-1 is returned on error and errno is set.After that, just use `one_byte_inc()` for all your 1-byte incrementing needs!
## Example
```c
#include
#include "one_byte_inc.h"int main() {
init_one_byte_inc();
printf("%d\n", one_byte_inc(89017)); // prints: 89018
}
```See also the example in `example.c`.
## Building
Run `./build.sh` to generate static and dynamic libraries, as well as the example binary.
## How does it work?
umm... uhh...