assembly

ARM assembly cannot use immediate values and ADDS/ADCS together

坚强是说给别人听的谎言 提交于 2021-02-07 12:52:26
问题 I am currently trying to speed up some of my C functions on a Cortex-M0 (Freescale KL25Z) using assembly. I get a problem with this minimal test program: @.syntax unified .cpu cortex-m0 .text .global test .code 16 test: mov r0, #0 adds r0, r0, #1 bx lr When I try to assemble my .s file to a .o file, I get this error $ arm-none-eabi-as test.s -o test.o test.s: Assembler messages: test.s:8: Error: instruction not supported in Thumb16 mode -- `adds r0,r0,#1' The error message doesn't make sense

Why does GCC on x86-64 insert a NOP inside of a function?

我的未来我决定 提交于 2021-02-07 12:29:19
问题 Given the following C function: void go(char *data) { char name[64]; strcpy(name, data); } GCC 5 and 6 on x86-64 compile (plain gcc -c -g -o followed by objdump ) this to: 0000000000000000 <go>: 0: 55 push %rbp 1: 48 89 e5 mov %rsp,%rbp 4: 48 83 ec 50 sub $0x50,%rsp 8: 48 89 7d b8 mov %rdi,-0x48(%rbp) c: 48 8b 55 b8 mov -0x48(%rbp),%rdx 10: 48 8d 45 c0 lea -0x40(%rbp),%rax 14: 48 89 d6 mov %rdx,%rsi 17: 48 89 c7 mov %rax,%rdi 1a: e8 00 00 00 00 callq 1f <go+0x1f> 1f: 90 nop 20: c9 leaveq 21:

Passing parameters and return values for a subroutine in assembly

為{幸葍}努か 提交于 2021-02-07 12:19:31
问题 I am working with ARM assembly, where I have to write one subroutine for which I am following the ARM calling convention(this will have to be integrated with some separate higher level implementation somewhere else ) for passing parameters and return values. Now here is something I am not sure in general when working with assembly. So from the convention if I understand well the arguments are passed in order starting from registers r0 - r4 and then for other arguments stacks are used. Return

What does 1: mean in assembly language?

↘锁芯ラ 提交于 2021-02-07 09:30:50
问题 I was reading the source code of RISC-V test pattern. And there is a macro define in riscv-test.h, I want to know what does 1: means in this code: #define RVTEST_CODE_BEGIN \ .section .text.init; \ .align 6; \ .weak stvec_handler; \ .weak mtvec_handler; \ .globl _start; \ _start: \ /* reset vector */ \ j reset_vector; \ .align 2; \ trap_vector: \ /* test whether the test came from pass/fail */ \ csrr t5, mcause; \ li t6, CAUSE_USER_ECALL; \ beq t5, t6, write_tohost; \ li t6, CAUSE_SUPERVISOR

How does assembly code actually get interpreted at the basic level?

旧时模样 提交于 2021-02-07 08:13:43
问题 I am really into understanding programming from the bottom up. So, I have learned the internal construction of a tiny 64kb computer, because I'm super interested in understanding computers from the transistor level. I understand transistors, the creation of multiplexers, decoders, creation of ALU, etc. I get that for LC3, which is what I learned, opcodes like 0001 011 011 100001 etc will mean that the 0001 will get decoded as an Add instruction etc. Yet, I am confused as to how we can write

MinGW's ld cannot perform PE operations on non PE output file

喜你入骨 提交于 2021-02-07 08:08:44
问题 I know there are some other similar questions about this out there, be it StackOverflow or not. I've researched a lot for this, and still didn't find a single solution. I'm doing an operative system as a side project. I've been doing all in Assembly, but now I wanna join C code. To test, I made this assembly code file (called test.asm): [BITS 32] GLOBAL _a SECTION .text _a: jmp $ Then I made this C file (called main.c): extern void a(void); int main(void) { a(); } To link, I used this file

How does assembly code actually get interpreted at the basic level?

为君一笑 提交于 2021-02-07 08:08:11
问题 I am really into understanding programming from the bottom up. So, I have learned the internal construction of a tiny 64kb computer, because I'm super interested in understanding computers from the transistor level. I understand transistors, the creation of multiplexers, decoders, creation of ALU, etc. I get that for LC3, which is what I learned, opcodes like 0001 011 011 100001 etc will mean that the 0001 will get decoded as an Add instruction etc. Yet, I am confused as to how we can write

MinGW's ld cannot perform PE operations on non PE output file

喜你入骨 提交于 2021-02-07 08:06:17
问题 I know there are some other similar questions about this out there, be it StackOverflow or not. I've researched a lot for this, and still didn't find a single solution. I'm doing an operative system as a side project. I've been doing all in Assembly, but now I wanna join C code. To test, I made this assembly code file (called test.asm): [BITS 32] GLOBAL _a SECTION .text _a: jmp $ Then I made this C file (called main.c): extern void a(void); int main(void) { a(); } To link, I used this file

Differences between call, push+ret and push+jump in assembly

丶灬走出姿态 提交于 2021-02-07 06:52:47
问题 I have a trace instruction and want to extract function calls and returns. I found that except call instruction, push + jmp and push + ret can be used for function call? At first I want to be sure is that correct? and if yes what are the differences between them? Also if push + ret is kind of call so what would be the end or return of a function? Seeing only ret without push instruction before it? 回答1: Yes, you are correct. When a call is issued, the return address pushed onto the stack is

Differences between call, push+ret and push+jump in assembly

我的梦境 提交于 2021-02-07 06:52:42
问题 I have a trace instruction and want to extract function calls and returns. I found that except call instruction, push + jmp and push + ret can be used for function call? At first I want to be sure is that correct? and if yes what are the differences between them? Also if push + ret is kind of call so what would be the end or return of a function? Seeing only ret without push instruction before it? 回答1: Yes, you are correct. When a call is issued, the return address pushed onto the stack is