yasm

Find which assembly instruction caused an Illegal Instruction error without debugging

送分小仙女□ 提交于 2019-11-28 21:05:27
问题 While running a program I've written in assembly, I get Illegal instruction error. Is there a way to know which instruction is causing the error, without debugging that is, because the machine I'm running on does not have a debugger or any developement system. In other words, I compile in one machine and run on another. I cannot test my program on the machine I'm compiling because they don't support SSE4.2. The machine I'm running the program on does support SSE4.2 instructions nevertheless.

Can't call C standard library function on 64-bit Linux from assembly (yasm) code

痴心易碎 提交于 2019-11-28 12:20:00
I have a function foo written in assembly and compiled with yasm and GCC on Linux (Ubuntu) 64-bit. It simply prints a message to stdout using puts() , here is how it looks: bits 64 extern puts global foo section .data message: db 'foo() called', 0 section .text foo: push rbp mov rbp, rsp lea rdi, [rel message] call puts pop rbp ret It is called by a C program compiled with GCC: extern void foo(); int main() { foo(); return 0; } Build commands: yasm -f elf64 foo_64_unix.asm gcc -c foo_main.c -o foo_main.o gcc foo_64_unix.o foo_main.o -o foo ./foo Here is the problem: When running the program it

yasm movsx, movsxd invalid size for operand 2

牧云@^-^@ 提交于 2019-11-28 09:28:52
问题 I am trying to assemble the code below using yasm. I have put 'here' comments where yasm reports the error "error: invalid size for operand 2". Why is this error happening ? segment .data a db 25 b dw 0xffff c dd 3456 d dq -14 segment .bss res resq 1 segment .text global _start _start: movsx rax, [a] ; here movsx rbx, [b] ; here movsxd rcx, [c] ; here mov rdx, [d] add rcx, rdx add rbx, rcx add rax, rbx mov [res], rax ret 回答1: For most instructions, the width of the register operand implies

How to generate a nasm compilable assembly code from c source code on Linux?

寵の児 提交于 2019-11-28 03:24:28
Test platform is 32 bit Linux. Basically, I know gcc can be used to generate both Intel and At&T style assembly code, but it seems that you can not directly use nasm/tasm to compile the Intel style assembly code gcc generated. I am conducting a project analysis asm code on both windows and Linux platform, so I am thinking if they can be both compiled by platform independent assembler like nasm\yasm, I could have a much easier time... So my question is how to generate a nasm compilable assembly code from c source code on Linux? Babken Vardanyan I find it's a better approach to disassemble the

What are the sizes of tword, oword and yword operands?

江枫思渺然 提交于 2019-11-27 12:07:20
What are the sizes of tword , oword and yword operands, as used in the NASM / YASM manual ? And on a related note, is there a trick or underlying idea to these names? Is there a way by which bigger word sizes are given logical names? I know that while word sizes may differ between systems, a NASM word is 2 bytes, dword is double that (4 bytes), qword is a quad word (8 bytes), but... is tword a triple word (6 bytes)? And for oword and yword I can't even think of a plausible meaning. Note that it is probably an easy question, but I couldn't find an answer. In the NASM and YASM manuals these

How to generate a nasm compilable assembly code from c source code on Linux?

自作多情 提交于 2019-11-27 00:02:27
问题 Test platform is 32 bit Linux. Basically, I know gcc can be used to generate both Intel and At&T style assembly code, but it seems that you can not directly use nasm/tasm to compile the Intel style assembly code gcc generated. I am conducting a project analysis asm code on both windows and Linux platform, so I am thinking if they can be both compiled by platform independent assembler like nasm\yasm, I could have a much easier time... So my question is how to generate a nasm compilable

Can't call C standard library function on 64-bit Linux from assembly (yasm) code

强颜欢笑 提交于 2019-11-26 23:29:13
问题 I have a function foo written in assembly and compiled with yasm and GCC on Linux (Ubuntu) 64-bit. It simply prints a message to stdout using puts() , here is how it looks: bits 64 extern puts global foo section .data message: db 'foo() called', 0 section .text foo: push rbp mov rbp, rsp lea rdi, [rel message] call puts pop rbp ret It is called by a C program compiled with GCC: extern void foo(); int main() { foo(); return 0; } Build commands: yasm -f elf64 foo_64_unix.asm gcc -c foo_main.c

What are the sizes of tword, oword and yword operands?

二次信任 提交于 2019-11-26 15:52:02
问题 What are the sizes of tword , oword and yword operands, as used in the NASM/YASM manual? And on a related note, is there a trick or underlying idea to these names? Is there a way by which bigger word sizes are given logical names? I know that while word sizes may differ between systems, a NASM word is 2 bytes, dword is double that (4 bytes), qword is a quad word (8 bytes), but... is tword a triple word (6 bytes)? And for oword and yword I can't even think of a plausible meaning. Note that it

Basic use of immediates vs. square brackets in YASM/NASM x86 assembly

陌路散爱 提交于 2019-11-26 09:43:20
问题 Suppose I have the following declared: section .bss buffer resb 1 And these instructions follow in section .text : mov al, 5 ; mov-immediate mov [buffer], al ; store mov bl, [buffer] ; load mov cl, buffer ; mov-immediate? Am I correct in understanding that bl will contain the value 5, and cl will contain the memory address of the variable buffer ? I am confused about the differences between moving an immediate into a register, moving a register into an immediate (what goes in, the data or the