以下代码
int main() {
int arr[120];
return arr[0];
}
Run Code Online (Sandbox Code Playgroud)
编译成这样:
sub rsp, 360
mov eax, DWORD PTR [rsp-480]
add rsp, 360
ret
Run Code Online (Sandbox Code Playgroud)
知道整数是 4 个字节,数组的大小为 120,数组应该占用 480 个字节,但从 ESP 中只减去了 360 个字节......这是为什么?
我正在使用 GAS 汇编器为 linux x86_64 编写一个 hello world 程序,这是我的 AT&T 语法代码。
#.intel_syntax noprefix
.section .data
msg:
.ascii "hello world\n"
.section .text
.globl _start
_start:
movq $1, %rax
movq $1, %rdi
movq $msg, %rsi
movq $12, %rdx
syscall
movq $60, %rax
movq $0, %rdi
syscall
Run Code Online (Sandbox Code Playgroud)
这有效并打印“hello world”。这是英特尔语法:
.intel_syntax noprefix
.section .data
msg:
.ascii "hello world\n"
.section .text
.globl _start
_start:
mov rax, 1
mov rdi, 1
mov rsi, msg
mov rdx, 12
syscall
mov rax, 60
mov rdi, 0
syscall
Run Code Online (Sandbox Code Playgroud)
这编译并运行良好,但不打印“hello …
我想知道,64 位操作系统和基于 x64 的处理器是否意味着字大小(即处理器和物理内存之间的内存传输大小)是 64 位?如果操作系统是 32 位且处理器为 x64 呢?那么基于 x86 的处理器呢?这两个规范(XX 位操作系统和基于 xXX 的处理器)与硬件中的实际字长有什么关系?
在 llvm pass 模块中编写一些内联程序集后,我收到此错误:
<inline asm>:1:2: error: unkown use of instruction mnemonic without a size suffix
test %rsi, $1
^
Run Code Online (Sandbox Code Playgroud)
我的理解是这个错误意味着我正在尝试使用指令不支持的操作数大小,或者大小不明确。我仔细阅读了 Intel x86_64 软件开发手册,我相当确定我明确指定了“REX.W + F7 /0 id”或“TEST r/m64,imm32”操作。我需要更明确地说我想要 REX 版本吗?如何?
我是汇编的新手,试图了解以下函数的 objdump:
int nothing(int num) {
return num;
}
Run Code Online (Sandbox Code Playgroud)
这是结果(linux,x86-64,gcc 8):
push rbp
mov rbp,rsp
mov DWORD PTR [rbp-0x4],edi
mov eax,DWORD PTR [rbp-0x4]
pop rbp
ret
Run Code Online (Sandbox Code Playgroud)
我的问题是: 1.edi从哪里来?阅读一些介绍文档,我的印象是[rbp-0x4]将包含num. 2. 从上面可以看出,edi 显然包含了这个论点。但是,它[rbp-0x4]扮演什么角色呢?为什么不只是mov eax, edi?
谢谢!
我尝试在 pycharm 中安装 pyaudio,然后
我收到这个错误
Run Code Online (Sandbox Code Playgroud)error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe' failed with exit status 2
我使用了pip install pyaudio命令。
复制评论:
PyAudio?0.2.11?cp37?cp37m?win_amd64.whl 尝试使用此命令安装它
pip install PyAudio?0.2.11?cp37?cp37m?win_amd64
Run Code Online (Sandbox Code Playgroud)但它不起作用并出现此错误
ERROR: Could not find a version that satisfies the requirement PyAudio-0.2.11-cp37-cp37m-win_amd64 (from versions: none)
ERROR: No matching distribution found for PyAudio-0.2.11-cp37-cp37m-win_amd64
Run Code Online (Sandbox Code Playgroud) NASM 可以在 64 位系统(Windows 7)上分配多少内存?fasm 似乎只能分配大约 1.5 GB 的内存,所以我正在寻找更强大的汇编程序。
到目前为止,我有一个程序,它所做的只是尝试创建一个,D2D1Factory但我收到错误消息E_NOINTERFACE,我认为我是正确的,IID_ID2D1Factory并且我已经在多个地方多次检查过。有人可以告诉我为什么它失败和/或如何修复它。
我的代码
include externals.asm
include wincons.asm
include vtable.asm
.data
include variables.asm
;include pic.asm
include riid.asm
.code
start proc frame
DB 48h
push rbx
.pushreg rbx
push r13
.pushreg r13
push rbp
.pushreg rbp
sub rsp, 80
.allocstack 80
lea rbp, [rsp + 80]
.setframe rbp, 80
.endprolog
mov rcx, D2D1_FACTORY_TYPE_SINGLE_THREADED
lea rdx, IID_ID2D1Factory
mov r8, D2D1_DEBUG_LEVEL_NONE
lea r9, ID2D1Factory
call __imp_D2D1CreateFactory
drawscreen:
jnc drawscreen
xor rcx, rcx
call __imp_ExitProcess
mov rsp, rbp
pop rbp …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 NASM 中运行一个简单的 Hello world 程序。我想在不使用 C-Libraries 的情况下打印到控制台,直接与 WinAPI 接口。
我正在使用 Visual Studio 提供的 LINK.EXE 进行链接。
到目前为止,这是我的代码:
section .data
message: db 'Hello world!',10 ; 'Hello world!' plus a linefeed character
messageLen: db $-message ; Length of the 'Hello world!' string
global _start
extern GetStdHandle
extern WriteConsoleW
extern ExitProcess
section .text
_start:
; DWORD bytes;
mov rbp, rsp
sub rsp, byte 8
; hStdOut = GetStdHandle(STD_OUTPUT_HANDLE)
mov ecx, -11
call GetStdHandle
; WriteFile(hstdOut, message, length(message), &bytes, 0);
mov rcx, rax
mov …Run Code Online (Sandbox Code Playgroud) 在了解我的应用程序(I/O 密集型)的分析结果时,我面临copy_user_enhanced_fast_string成为最热门的区域之一。在用户空间和内核空间之间复制时调用它。x86 上的实现如下所示:
ENTRY(copy_user_enhanced_fast_string)
ASM_STAC
cmpl $64,%edx
jb .L_copy_short_string /* less then 64 bytes, avoid the costly 'rep' */
movl %edx,%ecx
1: rep
movsb
xorl %eax,%eax
ASM_CLAC
ret
.section .fixup,"ax"
12: movl %ecx,%edx /* ecx is zerorest also */
jmp .Lcopy_user_handle_tail
.previous
_ASM_EXTABLE_UA(1b, 12b)
ENDPROC(copy_user_enhanced_fast_string)
Run Code Online (Sandbox Code Playgroud)
为什么不vmovaps/vmovups用于那个?不是已经证明 AVX 在复制可用的地方没有性能优势吗?