assembly

Print bytes of data label (artificial) array as hex and dec in ARM gdb

╄→尐↘猪︶ㄣ 提交于 2020-01-30 12:11:50
问题 I have got 3 Arrays under the data label (ArrayA, ArrayB, ArrayC) , each having 16 bytes. I've already written the program that goes through it row by row and adds each row of A with each row of B and then saves the result to the same row of array C . I want to add a breakpoint just before the program stops executing and then print the memory from [=ArrayC] up to [=ArrayC] + 15 , byte by byte, once in hex and once in decimal. How is that possible? 回答1: x/16xb &ArrayC for hexadecimal and x

Print bytes of data label (artificial) array as hex and dec in ARM gdb

情到浓时终转凉″ 提交于 2020-01-30 12:11:05
问题 I have got 3 Arrays under the data label (ArrayA, ArrayB, ArrayC) , each having 16 bytes. I've already written the program that goes through it row by row and adds each row of A with each row of B and then saves the result to the same row of array C . I want to add a breakpoint just before the program stops executing and then print the memory from [=ArrayC] up to [=ArrayC] + 15 , byte by byte, once in hex and once in decimal. How is that possible? 回答1: x/16xb &ArrayC for hexadecimal and x

Reading input from keyboard with x64 linux syscalls (assembly)

旧时模样 提交于 2020-01-30 11:51:33
问题 I'm trying to learn how to use linux 64bits syscall in assembly. I was writing some code for reading keyboard and simply print it on screen the pressed keys: i'm using sys_read. The code: section .text global _start _start: ;write startmsg mov rax, 1 mov rdi, 1 mov rsi, startmsg mov rdx, sizestart syscall ;using sys_read mov ax, 0 mov rdi, 0 mov rsi, key mov rdx, 2 syscall ;trying to see if esc is pressed then exit mov rbx, 0x1b cmp rbx, key je _exit _exit: mov rax, 60 mov rdi, 0 syscall

Reading input from keyboard with x64 linux syscalls (assembly)

断了今生、忘了曾经 提交于 2020-01-30 11:50:05
问题 I'm trying to learn how to use linux 64bits syscall in assembly. I was writing some code for reading keyboard and simply print it on screen the pressed keys: i'm using sys_read. The code: section .text global _start _start: ;write startmsg mov rax, 1 mov rdi, 1 mov rsi, startmsg mov rdx, sizestart syscall ;using sys_read mov ax, 0 mov rdi, 0 mov rsi, key mov rdx, 2 syscall ;trying to see if esc is pressed then exit mov rbx, 0x1b cmp rbx, key je _exit _exit: mov rax, 60 mov rdi, 0 syscall

From DOS to Windows 10 assembly [duplicate]

a 夏天 提交于 2020-01-30 11:22:27
问题 This question already has answers here : Converting 16-bit DOS .com assembly for use on 64-bit (1 answer) 16-bit Assembly on 64-bit Windows? (3 answers) How to write hello world in assembler under Windows? (8 answers) Closed 2 years ago . This code will print "Hello, world!" in DOS as a .COM executable: org 100h mov dx,msg mov ah,9 int 21h mov ah,4Ch int 21h msg db 'Hello, world!',0Dh,0Ah,'$' However it will not run on Windows 10 64-bit and all trivial examples of a Helloworld program for x86

How to view machine code?

烈酒焚心 提交于 2020-01-30 10:58:27
问题 I've written a program in assembly (at&t syntax) and I want to see how the machine code looks. This is how I get executable code: as -g -o p1.o p1.s --32 -gstabs ld -o p1 p1.o -m elf_i386 回答1: Assuming that you are on a Linux or BSD platform (based on the fact that you're using as ), you might want to try objdump . objdump -d <binary file> will disassemble the object file, showing you machine code hex bytes on the left and the disassembled matching assembly mnemonics on the right. Here's an

How to view machine code?

半世苍凉 提交于 2020-01-30 10:57:44
问题 I've written a program in assembly (at&t syntax) and I want to see how the machine code looks. This is how I get executable code: as -g -o p1.o p1.s --32 -gstabs ld -o p1 p1.o -m elf_i386 回答1: Assuming that you are on a Linux or BSD platform (based on the fact that you're using as ), you might want to try objdump . objdump -d <binary file> will disassemble the object file, showing you machine code hex bytes on the left and the disassembled matching assembly mnemonics on the right. Here's an

Does it matter where the ret instruction is called in a procedure in x86 assembly

元气小坏坏 提交于 2020-01-30 10:53:37
问题 I am currently learning x86 assembly. Something is not clear to me still however when using the stack for function calls. I understand that the call instruction will involve pushing the return address on the stack and then load the program counter with the address of the function to call. The ret instruction will load this address back to the program counter. My confusion is, does it matter when the ret instruction is called within the procedure/function? Will it always find the correct

Link assembly NASM code to GCC

为君一笑 提交于 2020-01-30 09:05:43
问题 I have a trouble with a compiling assembly code (nasm). On Linux (elf32) it not fails after compilation using g++, but when I tried to build it with i686-w64-mingw32-g++ (for Win32) it failed. My build.sh script: #!/bin/bash nasm -fwin32 wct.asm i686-w64-mingw32-g++ -m32 -O2 -Wall -fno-exceptions -ffloat-store -ffast-math -fno-rounding-math -fno-signaling-nans -fcx-limited-range -fno-math-errno -funsafe-math-optimizations -fassociative-math -freciprocal-math -ffinite-math-only -fno-signed

add 16 bits to 64 bits register [duplicate]

这一生的挚爱 提交于 2020-01-30 08:38:28
问题 This question already has answers here : Issue storing a byte into a register x86-64 assembly (1 answer) Why can't I move directly a byte to a 64 bit register? (2 answers) Closed 2 years ago . Here is what i want to do: add rsi, word [rsi+16] I want to read the unsigned short value which is at rsi+16 adress. And i want to add this value to rsi. Here is the error i get in nasm: s2.asm:62: error: mismatch in operand sizes This is strange. Why nasm and my cpu are not able to add 16 bits to 64