assembly

How to calculate parity of a 32bits number in assembly?

五迷三道 提交于 2021-02-08 12:16:21
问题 I need to calculate the parity of a 32 bits number and return it. To do this I must use XOR, SHR,SETP(or similar) and movzx. Somebody have an idea ? 回答1: Many ways to do this, of course. If you decide to use the hardware parity flag, keep in mind that it only checks the low 8 bits. A solution using this approach might be to process your 32 bit input as four 8 bit values, and use XOR on the partial results: p(31:0) = p(31:24) ^ p(23:16) ^ p(15:8) ^ p(7:0) To get the 8 bit units, you can use

X86 Fibonacci program

情到浓时终转凉″ 提交于 2021-02-08 12:04:29
问题 My assignment is to write a program that calculates first seven values of fibonacci number sequence. the formula given is: Fib(1) = 1, Fib(2) = 1, Fib(n) = Fib(n-1) + Fib(n-2) I believe that is a function but I do not understand how to incorporate it into code. I need to place the values in EAX register. I am using MASM not that makes any difference. Any hints? 回答1: I suspect that this is an academic assignment so I'm only going to partially answer the question. The fibonacci sequence is

Assembly big numbers calculator

*爱你&永不变心* 提交于 2021-02-08 11:33:53
问题 I've been given an assingment to make a calculator in 8086 assembly that will add, substract, multiply and divide big decimal numbers. These numbers can be 30 digits long at most. I've used 3 arrays to house these numbers (num1, num2, result). I'm stuck at the addition, because every time I run the program, it displays that the result array is empty (it shows a plus sign and 60 zeroes) can you tell what is wrong with my code? ADDER: MOV BP, offset num1 MOV SI, offset num2 MOV DI, offset

pcmpestri character units and countdown - x86-64 asm

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-08 11:12:14
问题 I’m trying to write a minimal loop around pcmpestri in x86-64 asm (actually in-line asm embedded in Dlang using the GDC compiler). There are a couple of things that I don’t understand I you are using pcmpestri with two pointers to strings, are the lengths of the strings in rax and rdx ? If so, what are the units? count in bytes always, or count in chars where 1 count = 2 bytes for uwords ? Does pcmpestri check for short strings? ie len str1 or str2 < 16 bytes or 8 uwords if uwords Does

How do you make a 8 byte call in x64 assembly? [duplicate]

对着背影说爱祢 提交于 2021-02-08 10:57:20
问题 This question already has answers here : Handling calls to (potentially) far away ahead-of-time compiled functions from JITed code (1 answer) How to execute a call instruction with a 64-bit absolute address? (1 answer) Call an absolute pointer in x86 machine code (2 answers) Closed 8 months ago . I am trying to hook a function in a process that is 64 bit, the relative jump is over 4 bytes so I can't do it via normal methods. Is there any way to jump 8 bytes relative or absolute? Cheers if any

How do you make a 8 byte call in x64 assembly? [duplicate]

a 夏天 提交于 2021-02-08 10:52:10
问题 This question already has answers here : Handling calls to (potentially) far away ahead-of-time compiled functions from JITed code (1 answer) How to execute a call instruction with a 64-bit absolute address? (1 answer) Call an absolute pointer in x86 machine code (2 answers) Closed 8 months ago . I am trying to hook a function in a process that is 64 bit, the relative jump is over 4 bytes so I can't do it via normal methods. Is there any way to jump 8 bytes relative or absolute? Cheers if any

How can I make Linux system calls from a C/C++ application, without using assembly, and in a cpu-independent manner? [closed]

孤人 提交于 2021-02-08 10:30:52
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . Improve this question I am looking to write a program that will need to do low level work with processes (ie. using the fork system call, among others). This program is to be written in C++ and is to run only on Linux. Ideally, it will be portable across CPU architectures (ie. x86, x86

How can I make Linux system calls from a C/C++ application, without using assembly, and in a cpu-independent manner? [closed]

有些话、适合烂在心里 提交于 2021-02-08 10:23:08
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . Improve this question I am looking to write a program that will need to do low level work with processes (ie. using the fork system call, among others). This program is to be written in C++ and is to run only on Linux. Ideally, it will be portable across CPU architectures (ie. x86, x86

Is there a good reason why GCC would generate jump to jump just over one cheap instruction?

左心房为你撑大大i 提交于 2021-02-08 10:16:27
问题 I was benchmarking some counting in a loop code. g++ was used with -O2 code and I noticed that it has some perf problems when some condition is true in 50% of the cases. I assumed that may mean that code does unnecessary jumps(since clang produces faster code so it is not some fundamental limitation). What I find in this asm output funny is that code jumps over one simple add. => 0x42b46b <benchmark_many_ints()+1659>: movslq (%rdx),%rax 0x42b46e <benchmark_many_ints()+1662>: mov %rax,%rcx

Is there a good reason why GCC would generate jump to jump just over one cheap instruction?

怎甘沉沦 提交于 2021-02-08 10:15:16
问题 I was benchmarking some counting in a loop code. g++ was used with -O2 code and I noticed that it has some perf problems when some condition is true in 50% of the cases. I assumed that may mean that code does unnecessary jumps(since clang produces faster code so it is not some fundamental limitation). What I find in this asm output funny is that code jumps over one simple add. => 0x42b46b <benchmark_many_ints()+1659>: movslq (%rdx),%rax 0x42b46e <benchmark_many_ints()+1662>: mov %rax,%rcx