通过堆栈在汇编和 C 函数之间传递 8 字节值

问题描述

我尝试将 fasm 代码中的三个参数传递给 c 函数

push ebx
push eax
push esi
push edx
call _kernel_main

void kernel_main(uint8 boot_disk_id,void *memory_map,uint64 first_file_sector_number)

我的期望:

  • boot_disk_id 获取edx 数据,低字节
  • memory_map 获取 esi 数据,
  • first_file_sector_number 获取 8 字节值,eax - 高 4 字节,ebx- 低 4 字节

enter image description here

假设 ebx 包含 0x0 并且 eax 包含 0x2 所以 first_file_sector_number 将获得值 0x2,

当我像这样改变位置 ebx 和 eax 时:

push eax
push ebx
push esi
push edx
call _kernel_main

我希望 first_file_sector_number 将包含 00000000 00000000 00000000 00000010 00000000 00000000 00000000 00000000 00000000 00x200000000000000 但它包含0x0

你能告诉我我错在哪里吗。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)