assembly

Reverse numbers in a variable [closed]

纵然是瞬间 提交于 2021-02-05 09:27:03
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 13 days ago . Improve this question I have to reverse 20 numbers in a variable (src) and put te result in another variable (dst) in ARM 7 but I can't do it. I have src = 1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,1,2,3,4 and I want that dst = 4,3,2,1,8,7,6,5,4,3,2,1,8,7,6,5,4,3,2,1. Could someone help me please ? Here is

How to count matches using compare + je?

僤鯓⒐⒋嵵緔 提交于 2021-02-05 09:23:09
问题 I am writing a code that counts how many words are in a string. How can I increase a register using je? For example: cmp a[bx+1],00h je inc cx 回答1: je is a conditional jump . Unlike ARM, x86 can't directly predicate another single instruction based on an arbitrary condition. There's no single machine instruction that can do anything like je inc cx or ARM-style inceq cx . Instead you need to build the logic yourself by conditionally branching over other instruction(s). If you want to increase

How to count matches using compare + je?

痞子三分冷 提交于 2021-02-05 09:22:09
问题 I am writing a code that counts how many words are in a string. How can I increase a register using je? For example: cmp a[bx+1],00h je inc cx 回答1: je is a conditional jump . Unlike ARM, x86 can't directly predicate another single instruction based on an arbitrary condition. There's no single machine instruction that can do anything like je inc cx or ARM-style inceq cx . Instead you need to build the logic yourself by conditionally branching over other instruction(s). If you want to increase

Why do my results different following along the tiny asm example?

荒凉一梦 提交于 2021-02-05 09:15:30
问题 I'm reading this page https://www.muppetlabs.com/~breadbox/software/tiny/teensy.html This is one of the example ; tiny.asm BITS 32 GLOBAL _start SECTION .text _start: mov eax, 1 mov ebx, 42 int 0x80 Here we go: $ nasm -f elf tiny.asm $ gcc -Wall -s -nostdlib tiny.o $ ./a.out ; echo $? 42 Ta-da! And the size? $ wc -c a.out 372 a.out However I don't get the same results. I tried nasm -f elf64 and then tried -m32 on gcc (then again on clang). No matter what I try I can not get it to be the tiny

Why do my results different following along the tiny asm example?

梦想的初衷 提交于 2021-02-05 09:15:06
问题 I'm reading this page https://www.muppetlabs.com/~breadbox/software/tiny/teensy.html This is one of the example ; tiny.asm BITS 32 GLOBAL _start SECTION .text _start: mov eax, 1 mov ebx, 42 int 0x80 Here we go: $ nasm -f elf tiny.asm $ gcc -Wall -s -nostdlib tiny.o $ ./a.out ; echo $? 42 Ta-da! And the size? $ wc -c a.out 372 a.out However I don't get the same results. I tried nasm -f elf64 and then tried -m32 on gcc (then again on clang). No matter what I try I can not get it to be the tiny

Why is scanf returning 0.000000 when it is supplied with a double?

久未见 提交于 2021-02-05 09:12:59
问题 I have the following assembly code (written for NASM on Linux): ; This code has been generated by the 7Basic ; compiler <http://launchpad.net/7basic> extern printf extern scanf SECTION .data printf_f: db "%f",10,0 scanf_f: db "%f",0 SECTION .bss v_0 resb 8 SECTION .text global main main: push ebp mov ebp,esp push v_0 ; load the address of the variable push scanf_f ; push the format string call scanf ; call scanf() add esp,8 push dword [v_0+4] ; load the upper-half of the double push dword [v

Why is scanf returning 0.000000 when it is supplied with a double?

不想你离开。 提交于 2021-02-05 09:09:22
问题 I have the following assembly code (written for NASM on Linux): ; This code has been generated by the 7Basic ; compiler <http://launchpad.net/7basic> extern printf extern scanf SECTION .data printf_f: db "%f",10,0 scanf_f: db "%f",0 SECTION .bss v_0 resb 8 SECTION .text global main main: push ebp mov ebp,esp push v_0 ; load the address of the variable push scanf_f ; push the format string call scanf ; call scanf() add esp,8 push dword [v_0+4] ; load the upper-half of the double push dword [v

Why is scanf returning 0.000000 when it is supplied with a double?

我的梦境 提交于 2021-02-05 09:08:52
问题 I have the following assembly code (written for NASM on Linux): ; This code has been generated by the 7Basic ; compiler <http://launchpad.net/7basic> extern printf extern scanf SECTION .data printf_f: db "%f",10,0 scanf_f: db "%f",0 SECTION .bss v_0 resb 8 SECTION .text global main main: push ebp mov ebp,esp push v_0 ; load the address of the variable push scanf_f ; push the format string call scanf ; call scanf() add esp,8 push dword [v_0+4] ; load the upper-half of the double push dword [v

What does it mean that “registers are preserved across function calls”?

自闭症网瘾萝莉.ら 提交于 2021-02-05 09:03:38
问题 From this question, What registers are preserved through a linux x86-64 function call, it says that the following registers are saved across function calls: r12, r13, r14, r15, rbx, rsp, rbp So, I went ahead and did a test with the following: .globl _start _start: mov $5, %r12 mov $5, %r13 mov $5, %r14 mov $5, %r15 call get_array_size mov $60, %eax syscall get_array_size: mov $0, %r12 mov $0, %r13 mov $0, %r14 mov $0, %r15 ret And, I was thinking that after the call get_array_size that my

MMX Register Speed vs Stack for Unsigned Integer Storage

时光怂恿深爱的人放手 提交于 2021-02-05 08:56:49
问题 I am contemplating an implementation of SHA3 in pure assembly. SHA3 has an internal state of 17 64 bit unsigned integers, but because of the transformations it uses, the best case could be achieved if I had 44 such integers available in the registers. Plus one scratch register possibly. In such a case, I would be able to do the entire transform in the registers. But this is unrealistic, and optimisation is possible all the way down to even just a few registers. Still, more is potentially