assembly

Unexpected exec permission from mmap when assembly files included in the project

烂漫一生 提交于 2020-01-30 14:11:58
问题 I am banging my head into the wall with this. In my project, when I'm allocating memory with mmap the mapping ( /proc/self/maps ) shows that it is an readable and executable region despite I requested only readable memory. After looking into strace (which was looking good) and other debugging, I was able to identify the only thing that seems to avoid this strange problem: removing assembly files from the project and leaving only pure C. (what?!) So here is my strange example, I am working on

Error C2432 illegal reference to 16-bit data in 'second operand' of __asm

两盒软妹~` 提交于 2020-01-30 13:11:50
问题 In Visual Studio, I get this error when I compile my __asm in C. Does anybody know what is wrong with this code? I tried everything, but nothing works. I am trying to implement the bubble sort in assembly. unsigned short i = 0; unsigned short j = 0; unsigned short max = short(N-2); unsigned short tab[5]; tab[0] = 54; tab[1] = 123; tab[2] = 342; tab[3] = 5436; tab[4] = 1234; unsigned short a = 0; __asm { loop1: inc i mov j, 0 mov si, tab loop2: mov ax, [si] // <- Error C2432 on this line mov a

Big endian and Little endian representations

人走茶凉 提交于 2020-01-30 13:09:29
问题 If I write the following section .data align 4 X: db 1 Y: dw 5 Z: db 0x11 section .text add dword [X], 0xAA000101 I'm trying to understand the differences between the big endian and the little endian representations, and I don't understand what will be the value of each variable for each representation? Will they be the same? 回答1: Have a look at these pictures: This is the list of endiannesses for all architectures/instruction sets 回答2: In a big-endian configuration, the most significant byte

Port MARS MIPS code to work on eight bit CPU simulator ( sms32v50 )

谁都会走 提交于 2020-01-30 13:08:28
问题 How can i change my code to make it work on sms32v50? .data #storing data startmsg: .asciiz "Pick a number between 1 and 100.\n\n" guessmsg: .asciiz "Enter your guess\n" tooHigh: .asciiz "Your guess is too high.\n\n" tooLow: .asciiz "Your guess is too low.\n\n" wingame: .asciiz "You have guessed the number. Well done!\n\n" .text #start of program start: jal random add $t0, $zero, $a0 # store random number $a0 in $t0 li $v0, 4 # print string la $a0, startmsg syscall ###########################

what is the difference beetwen dw and db with dup in assembly

岁酱吖の 提交于 2020-01-30 12:29:28
问题 I want to know what is the difference between this code and this code in assembly language: a db 2 dup (1fh) b dw 1fh,1fh and I think that the second code is better and I don't know why they make number first. 回答1: The 2nd line is equivalent to db 1fh, 0, 1fh, 0 , because each arg to DW is a word-sized integer. (And x86 is little-endian) The 1st line is equivalent to db 1fh, 1fh . To do that with DW, use dw 1f1fh . For a very short constant, that's maybe clearer. For anything more than 2

what is the difference beetwen dw and db with dup in assembly

若如初见. 提交于 2020-01-30 12:29:06
问题 I want to know what is the difference between this code and this code in assembly language: a db 2 dup (1fh) b dw 1fh,1fh and I think that the second code is better and I don't know why they make number first. 回答1: The 2nd line is equivalent to db 1fh, 0, 1fh, 0 , because each arg to DW is a word-sized integer. (And x86 is little-endian) The 1st line is equivalent to db 1fh, 1fh . To do that with DW, use dw 1f1fh . For a very short constant, that's maybe clearer. For anything more than 2

How to solve “illegal instruction” for vfmadd213ps?

限于喜欢 提交于 2020-01-30 12:26:09
问题 I have tried AVX intrinsics. But it caused "Unhandled exception at 0x00E01555 in test.exe: 0xC000001D: Illegal Instruction." I used Visual studio 2015. And the exception error is caused at "vfmadd213ps ymm2,ymm1,ymm0" instruction. I have tried set "/arch:AVX" and "/arch:AVX2", but still error caused. Below is my code. #include <immintrin.h> int main(int argc, char *argv[]) { float a[8] = { 0 }; float b[8] = { 0 }; float c[8] = { 0 }; __m256 _a = _mm256_loadu_ps(a); __m256 _b = _mm256_loadu_ps

why is segmention fault while printing?

我的梦境 提交于 2020-01-30 12:21:26
问题 This is my x86 assembly code: section .data output db '%d',10,0 section .text global main extern printf main : xor ecx,ecx xor eax,eax mov eax,1 mov ecx,5 lable1: push ecx push eax cmp eax,0 jg print pop eax pop ecx inc eax loop lable1 ret print: push eax push output call printf add esp,8 ret This program should print all numbers between 1 to 5. Why am I getting a segmentation fault after printing '1'? 回答1: print ends with a ret instruction, which implies that it is something that you should

Add 2 numbers and print the result using Assembly x86

霸气de小男生 提交于 2020-01-30 12:13:45
问题 I'm a novice Assembly x86 Learner, and i want to add two numbers (5+5) and print the result on the screen. here is my code: global _start section .text _start: mov eax, 5 mov ebx, 5 add eax, ebx push eax mov eax, 4 ; call the write syscall mov ebx, 1 ; STDOUT pop ecx ; Result mov edx, 0x1 int 0x80 ; Exit mov eax, 0x1 xor ebx, ebx int 0x80 Correct me please 回答1: Another approach to convert an unsigned integer to a string and write it: section .text global _start _start: mov eax, 1234567890 mov

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

不问归期 提交于 2020-01-30 12:12:46
问题 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