assembly

Using variable vs. using number

守給你的承諾、 提交于 2020-03-23 04:10:09
问题 Imagine a function in those versions: int faculty(const unsigned int n) { return n == 1 ? n : n * faculty(n - 1); } int faculty(const unsigned int n) { return n == 1 ? 1 : n * faculty(n - 1); } The only difference is that I return n in the first and 1 in the second one, depending on n . The result is the same but is there any other difference you could be aware of while ignoring the significance? I know there is a high chance the compiler will make the same assembly instructions out of it,

Problem with BIOS INT 13H (Read Sectors From Drive)

让人想犯罪 __ 提交于 2020-03-22 06:25:43
问题 Description: In my efforts to create a simple standalone program I have written a simple boot loader in the first sector. Its purpose is to load the program into memory. For this purpose I am using INT 13h with AH=2. The code is: disk_load: push dx ; Store DX on stack so later we can recall how many sectors were requested to be read, ; even if it is altered in the meantime. mov ah, 0x02 ; BIOS read sector. mov al, dh ; Read DH sectors. mov ch, 0x00 ; Select cylinder 0. mov dh, 0x00 ; Select

Is there an advantage of specifying “-mfpu=neon-vfpv3” over “-mfpu=neon” for ARMs with separate pipelines?

十年热恋 提交于 2020-03-21 19:29:12
问题 My Zynq-7000 ARM Cortex-A9 Processor has both the NEON and the VFPv3 extension and the Zynq-7000-TRM says that the processor is configured to have "Independent pipelines for VFPv3 and advanced SIMD instructions" . So far I compiled my programs with Linaro GCC 6.3-2017.05 and the -mfpu=neon option, to make use of SIMD instructions. But in the case that the compiler also has non-SIMD operations to be issued, will it make a difference to use -mfpu=neon-vfpv3 ? Will GCC's instruction selection

Is there an advantage of specifying “-mfpu=neon-vfpv3” over “-mfpu=neon” for ARMs with separate pipelines?

三世轮回 提交于 2020-03-21 19:25:47
问题 My Zynq-7000 ARM Cortex-A9 Processor has both the NEON and the VFPv3 extension and the Zynq-7000-TRM says that the processor is configured to have "Independent pipelines for VFPv3 and advanced SIMD instructions" . So far I compiled my programs with Linaro GCC 6.3-2017.05 and the -mfpu=neon option, to make use of SIMD instructions. But in the case that the compiler also has non-SIMD operations to be issued, will it make a difference to use -mfpu=neon-vfpv3 ? Will GCC's instruction selection

Is there an advantage of specifying “-mfpu=neon-vfpv3” over “-mfpu=neon” for ARMs with separate pipelines?

六眼飞鱼酱① 提交于 2020-03-21 19:24:12
问题 My Zynq-7000 ARM Cortex-A9 Processor has both the NEON and the VFPv3 extension and the Zynq-7000-TRM says that the processor is configured to have "Independent pipelines for VFPv3 and advanced SIMD instructions" . So far I compiled my programs with Linaro GCC 6.3-2017.05 and the -mfpu=neon option, to make use of SIMD instructions. But in the case that the compiler also has non-SIMD operations to be issued, will it make a difference to use -mfpu=neon-vfpv3 ? Will GCC's instruction selection

Iterate over strings in assembly (NASM)

风流意气都作罢 提交于 2020-03-20 19:35:32
问题 I am trying to count the length of the string argv[1] in NASM assembly language. I think I'm on the right track. I have moved the address of argv[1] to register eax and now I want to move through it byte by byte and compare to the null string terminator. Everytime I run the code it segfaults on the null comparison. Am I not getting the memory indexing correct? *Disclaimer: This is a small part of a large homework assignment. segment .bss N: resd 1 ;counter for size of argv[1] segment .text

Iterate over strings in assembly (NASM)

拈花ヽ惹草 提交于 2020-03-20 19:32:46
问题 I am trying to count the length of the string argv[1] in NASM assembly language. I think I'm on the right track. I have moved the address of argv[1] to register eax and now I want to move through it byte by byte and compare to the null string terminator. Everytime I run the code it segfaults on the null comparison. Am I not getting the memory indexing correct? *Disclaimer: This is a small part of a large homework assignment. segment .bss N: resd 1 ;counter for size of argv[1] segment .text

What does gdb 'x' command do?

一笑奈何 提交于 2020-03-17 06:57:38
问题 I am reading a book about hacking and it has a chapter about assembly. Following is my tiny program written in C. #include <stdio.h> int main(int argc, char const *argv[]) { int i; for (i = 0; i < 10; i++) { puts("Hello World!"); } return 0; } And the following is gdb test: (gdb) break main Breakpoint 1 at 0x40050f: file main.c, line 7. (gdb) run Breakpoint 1, main (argc=1, argv=0x7fffffffe708) at main.c:7 7 for (i = 0; i < 10; i++) { (gdb) disassemble main Dump of assembler code for function

How exactly does linking work?

北慕城南 提交于 2020-03-17 05:00:25
问题 The way I understand the compilation process: 1) Preprocessing: All of your macros are replaced with their actual values, all comments are removed, etc. Replaces your #include statements with the literal text of the files you've included. 2) Compilation: Won't drill down too deep here, but the result is an assembly file for whatever architecture you are on. 3) Assembly: Takes the assembly file and converts it into binary instructions, i.e., machine code. 4) Linking: This is where I'm confused

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/9/libstdc++.a when searching for -lstdc++ /usr/bin/ld: cannot find -lstdc++

会有一股神秘感。 提交于 2020-03-16 07:34:24
问题 why am i getting this error? g++ -m32 func.o test.o -o prgram /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/9/libstdc++.so when searching for -lstdc++ /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/9/libstdc++.a when searching for -lstdc++ /usr/bin/ld: cannot find -lstdc++ collect2: error: ld returned 1 exit status my code is as follows: #include<stdio.h> 2 3 4 extern "C" int calcsum(int a, int b, int c); 5 6 int main(int argc,char* argv[]) 7 { 8 int a =