assembly

NAND logical bitwise operation in ARM

天涯浪子 提交于 2020-11-29 08:33:24
问题 Is there a way to perform a bitwise NAND operation on the bits in two registers in ARM7, either with the existing AND, OR and EOR operations or other instructions? 回答1: Sure; AND the two registers and then EOR the result with all 1's (for the negation). 回答2: and then mvn (move not). From GCC explorer int nand(int a, int b) { return ~(a & b); } nand(int, int): and r0, r0, r1 mvn r0, r0 bx lr 来源: https://stackoverflow.com/questions/21207561/nand-logical-bitwise-operation-in-arm

Linking a program using printf with ld?

浪尽此生 提交于 2020-11-29 08:33:15
问题 I'm getting a undefined reference to _printf when building an assembly program that defines its own _start instead of main , using NASM on x86-64 Ubuntu Build commands: nasm -f elf64 hello.asm ld -s -o hello hello.o hello.o: In function `_start': hello.asm:(.text+0x1a): undefined reference to `_printf' MakeFile:4: recipe for target 'compile' failed make: *** [compile] Error 1 nasm source: extern _printf section .text global _start _start: mov rdi, format ; argument #1 mov rsi, message ;

Linking a program using printf with ld?

喜夏-厌秋 提交于 2020-11-29 08:32:05
问题 I'm getting a undefined reference to _printf when building an assembly program that defines its own _start instead of main , using NASM on x86-64 Ubuntu Build commands: nasm -f elf64 hello.asm ld -s -o hello hello.o hello.o: In function `_start': hello.asm:(.text+0x1a): undefined reference to `_printf' MakeFile:4: recipe for target 'compile' failed make: *** [compile] Error 1 nasm source: extern _printf section .text global _start _start: mov rdi, format ; argument #1 mov rsi, message ;

Why does the x86-64 System V calling convention pass args in registers instead of just the stack?

谁说胖子不能爱 提交于 2020-11-29 03:52:52
问题 Why is it that 32-bit C pushes all function arguments straight onto the stack while 64-bit C puts the first 6 arguments into registers and the rest on the stack? So the 32-bit stack would look like: ... arg2 arg1 return address old %rbp While the 64-bit stack would look like: ... arg8 arg7 return address old %rbp arg6 arg5 arg4 arg3 arg2 arg1 So why does 64-bit C do this? Isn't it much easier to just push everything to the stack instead of put the first 6 arguments in registers just to move

Unsigned integers in assembly

时光怂恿深爱的人放手 提交于 2020-11-28 08:35:29
问题 Brand new to assembly need some help with unsigned arithmetic. Converting from a C program is that means anything. Using: Linux NASM x86 (32 Bit) I want to read in a number from the user. I want this number to be unsigned. When I enter a number above the signed integer limit and use info registers, I notice that my register storing that is negative which means an overflow happened. (Obviously number entered is below max unsigned int) How do I treat this register as unsigned so I can do

Unsigned integers in assembly

陌路散爱 提交于 2020-11-28 08:34:27
问题 Brand new to assembly need some help with unsigned arithmetic. Converting from a C program is that means anything. Using: Linux NASM x86 (32 Bit) I want to read in a number from the user. I want this number to be unsigned. When I enter a number above the signed integer limit and use info registers, I notice that my register storing that is negative which means an overflow happened. (Obviously number entered is below max unsigned int) How do I treat this register as unsigned so I can do

How does comparing the Sign and Overflow Flag determine operand relationships?

不问归期 提交于 2020-11-28 02:22:49
问题 Jump's based on comparing signed integers use the Zero, Sign, and Overflow flag to determine the relationship between operands. After CMP with two signed operands, there are three possible scenario's: ZF = 1 - Destination = Source SF = OF - Destination > Source SF != OF - Destination < Source I'm having trouble understanding scenario 2 and 3. I've worked through the possible combinations and see that they do work - but I still can't figure out why they work. Can anyone explain why a

How does comparing the Sign and Overflow Flag determine operand relationships?

你说的曾经没有我的故事 提交于 2020-11-28 02:21:27
问题 Jump's based on comparing signed integers use the Zero, Sign, and Overflow flag to determine the relationship between operands. After CMP with two signed operands, there are three possible scenario's: ZF = 1 - Destination = Source SF = OF - Destination > Source SF != OF - Destination < Source I'm having trouble understanding scenario 2 and 3. I've worked through the possible combinations and see that they do work - but I still can't figure out why they work. Can anyone explain why a

How does comparing the Sign and Overflow Flag determine operand relationships?

青春壹個敷衍的年華 提交于 2020-11-28 02:20:08
问题 Jump's based on comparing signed integers use the Zero, Sign, and Overflow flag to determine the relationship between operands. After CMP with two signed operands, there are three possible scenario's: ZF = 1 - Destination = Source SF = OF - Destination > Source SF != OF - Destination < Source I'm having trouble understanding scenario 2 and 3. I've worked through the possible combinations and see that they do work - but I still can't figure out why they work. Can anyone explain why a

How does comparing the Sign and Overflow Flag determine operand relationships?

喜你入骨 提交于 2020-11-28 02:19:27
问题 Jump's based on comparing signed integers use the Zero, Sign, and Overflow flag to determine the relationship between operands. After CMP with two signed operands, there are three possible scenario's: ZF = 1 - Destination = Source SF = OF - Destination > Source SF != OF - Destination < Source I'm having trouble understanding scenario 2 and 3. I've worked through the possible combinations and see that they do work - but I still can't figure out why they work. Can anyone explain why a