x86 Assembly: INC and DEC instruction and overflow flag

In x86 assembly, the overflow flag is set when an add or sub operation on a signed integer overflows, and the carry flag is set when an operation on an unsigned integer overflows. However, when it comes to the inc and dec instructions, the situation seems to be somewhat different. According to this website, the inc instruction does not affect the carry flag at all. But I can't find any i

x86汇编:INC和DEC指令和溢出标志

在x86汇编中,当有符号整数的add或sub操作溢出时溢出标志置位,并且当对无符号整数的操作溢出时设置进位标志。 但是,当涉及到inc和dec指示时,情况似乎有所不同。 根据这个网站, inc指令根本不影响进位标志。 但是我无法找到有关inc和dec如何影响溢出标志的信息。 难道inc或dec时的整数溢出时置溢出标志? 这种行为对于有符号整数和无符号整数都是一样的吗? ============================= 编辑 ==================

sse4.S results in Segmentation Fault

i'm writing a small tool written in c and met on a segmentation fault which i don't know currently how to resolve. Running in GDB gives me the following hint: Program received signal SIGSEGV, Segmentation fault. __strlen_sse42 () at ../sysdeps/x86_64/multiarch/strlen-sse4.S:32 ../sysdeps/x86_64/multiarch/strlen-sse4.S: File or Directory not found in ../sysdeps/x86_6

sse4.S导致分段错误

我正在写一个用c编写的小工具,并遇到了一个我现在不知道如何解决的分段错误。 在GDB中运行给了我下面的提示: Program received signal SIGSEGV, Segmentation fault. __strlen_sse42 () at ../sysdeps/x86_64/multiarch/strlen-sse4.S:32 ../sysdeps/x86_64/multiarch/strlen-sse4.S: File or Directory not found in ../sysdeps/x86_64/multiarch/strlen-sse4.S (gdb) bt 0 __strlen_sse42 ()

itoa implementation crashing?

I am trying to implement atoi in assembly (the netwide assembler). I have verified that my approach is valid by inspecting the register values with a debugger. The problem is that the application will crash when it is about to exit. I am afraid my program is corrupting the stack somehow. I am linking against the GCC stdlib to allow the use of the printf function. I noticed it mutated the reg

itoa实施崩溃?

我正在尝试在汇编中实现atoi(网络汇编程序)。 我已通过使用调试器检查寄存器值验证了我的方法是有效的。 问题是应用程序即将退出时会崩溃。 恐怕我的程序不知何故破坏了堆栈。 我链接到GCC stdlib以允许使用printf函数。 我注意到它突变了引起意外行为的寄存器(对我没有认识到的值进行了广泛的迭代),但是我通过将EAX的值存储在EBX中(未由printf修改),然后在函数调用后恢复该值来解决此问题。 这就是为什么我已经能

Is gcc's

In C, the compiler will lay out members of a struct in the order in which they're declared, with possible padding bytes inserted between members, or after the last member, to ensure that each member is aligned properly. gcc provides a language extension, __attribute__((packed)) , which tells the compiler not to insert padding, allowing struct members to be misaligned. For example, if the s

是gcc的

在C语言中,编译器会按照声明的顺序排列结构体的成员,在成员之间插入可能的填充字节,或在最后一个成员之后插入,以确保每个成员都正确对齐。 gcc提供了一个语言扩展, __attribute__((packed)) ,它告诉编译器不要插入填充,从而允许struct成员未对齐。 例如,如果系统通常要求所有int对象具有4字节对齐方式,则__attribute__((packed))会导致int结构成员以奇数偏移方式分配。 引用gcc文档: 'packed'属性指定

Mapping an IEnumerable property with CSVHelper

I have a class of User , which can have several contact numbers. I am using CsvHelper to generate a report on the users, which will create a CSV file of the User's name and contact details. Each contact number should be displayed in its own column, with the contact number's type as the column header. Below I have my ContactNumber and User classes, as well as a UserMap class that shoul

使用CSVHelper映射IEnumerable属性

我有一类User ,可以有多个联系号码。 我正在使用CsvHelper为用户生成报告,这将创建用户名和联系人详细信息的CSV文件。 每个联系号码应显示在其自己的列中,联系号码的类型作为列标题。 在下面我有我的ContactNumber和User类,以及一个UserMap类,它应该相应地格式化我的CSV文件: public class ContactNumber { public string ContactType { get; set; } public string Number { get; set; } } public class User

Round of floating values

This question already has an answer here: Why not use Double or Float to represent currency? 14 answers You shouldn't be using binary floating point to handle monetary amounts. There are many issues having to do with rounding and the inexact nature of floating point. For example, you won't be able to exactly represent 0.1 as a float . Use fixed-point arithmetic instead.

一轮浮动值

这个问题在这里已经有了答案: 为什么不使用Double或Float来表示货币? 14个答案 您不应该使用二进制浮点来处理货币金额。 关于舍入和浮点的不精确性质有很多问题。 例如,你将无法精确地将0.1表示为float 。 改为使用定点算术。

How to round up the result of integer division?

I'm thinking in particular of how to display pagination controls, when using a language such as C# or Java. If I have x items which I want to display in chunks of y per page, how many pages will be needed? Found an elegant solution: int pageCount = (records + recordsPerPage - 1) / recordsPerPage; Source: Number Conversion, Roland Backhouse, 2001 Converting to floating point and back s

如何整数除法的结果?

当我使用诸如C#或Java之类的语言时,我特别想到如何显示分页控件。 如果我有x个项目,我想以每个页面y的大块显示,那么需要多少页面? 找到一个优雅的解决方 int pageCount = (records + recordsPerPage - 1) / recordsPerPage; 来源:数字转换,Roland Backhouse,2001 转换为浮点和后退看起来像是在CPU级别上浪费大量时间。 伊恩尼尔森的解决方案: int pageCount = (records + recordsPerPage - 1) / recordsPerPa

What is the difference between the

I'm writing a toy operating system (so I cannot use any library, including the standard one), compiled with gcc, and I want to use atomics for some of the synchronization code. After some search, I found that gcc has two sets of builtins for atomic operations, __sync_* and __atomic_*, but there is no information as to the difference between the two. What is the difference between these two

之间有什么区别

我正在写一个玩具操作系统(所以我不能使用任何库,包括标准库),使用gcc编译,我想用一些同步代码的原子。 经过一番搜索之后,我发现gcc有两套用于原子操作的内建函数__sync_ *和__atomic_ *,但没有关于两者之间差异的信息。 除了后者之外,这两者之间还有什么区别?有内存排序的参数吗? 是__sync_版本相当于__atomic_版本与顺序排序? 是__sync_版本弃用__atomic_一个吗? 免责声明:我以前没有使用过这些原语。 以

fast integer square root approximation

I am currently searching for a very fast integer square root approximation, where floor(sqrt(x)) <= veryFastIntegerSquareRoot(x) <= x The square root routine is used for calculating prime numbers, which get considerably faster if only values below or equals sqrt(x) are checked for being a divisor of x . What I am currently having is this function from Wikipedia, adjusted a small bit to

快整数平方根近似

我目前正在寻找一个非常快的整数平方根逼近,其中floor(sqrt(x)) <= veryFastIntegerSquareRoot(x) <= x 平方根例程用于计算素数,如果只检查低于或等于sqrt(x)是否为x的除数,则该常数会显着加快。 我目前拥有的是维基百科的这个功能,调整了一点点以使用64位整数。 因为我没有其他功能可以与之比较(或者更确切地说,功能对于我的目的来说太精确了,而且可能需要更多时间,而不是比实际结果更高)。 Loopfree /

the usage of the long double

The functions purpose is to calculate the square root of a number using the Newton-Raphson method. I included a printf routine in the while loop so I can see the value of root 2 get closer and closer to the actual value. I originally used float to define epsilon but as I increased the value of epsilon, the value of the return results seem to be cut-off after a certain number of digits. So I de

长双的用法

函数的目的是用牛顿 - 拉夫森法计算一个数的平方根。 我在while循环中包含了printf例程,所以我可以看到 root 2的值越来越接近实际值。 我最初使用float来定义epsilon,但是当我增加了epsilon的值时,返回结果的值似乎在一定数量的数字后被截断。 所以我决定把所有的变量都切换成长整倍数,程序显示的是负值结果。 我如何解决它? //Function to calculate the absolute value of a number #include <stdio.h> long