将各种参数从 C 传递给汇编程序 [英] Passing various parameters from C to Assembler

查看:69
本文介绍了将各种参数从 C 传递给汇编程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须编写一个汇编子程序 dswap(int, double*, int, double*, int) 它从 C 程序调用并由 NASM 汇编.我的任务是根据其他三个 int 参数操作两个给定的向量 (double*).现在我被困在找出如何在我的汇编代码中访问这些参数以及如何从向量中访问特定元素.你能指点我一些文档/例子吗?

I have to write an assembler subroutine dswap(int, double*, int, double*, int) which is called from a C program and assembled by NASM. My task is to manipulate the two given vectors (double*) based on the other three int parameters. Right now I am stuck to find out how exactly these parameters can be accessed in my assembler code and how to access specific elements from the vectors. Can you point me to some documentation/examples for this?

推荐答案

您想查看堆栈帧",如果您使用的是 x86,请查看微编码指令进入"和离开"的内容做,但不要使用它们.相反,使用编码输出的等效项来设置堆栈帧,以便您可以访问自己传递的参数.

You want to look at "stack frames", and in case you're using x86, look at what the micro-coded instructions "enter" and "leave" do, but don't use them. Instead, use the coded out equivalent, to set up stack frame such that you can access your own passed arguments.

考虑到,在 C 中,参数处理是这样完成的,您可以将许多参数传递给函数/子例程,但只能返回一个.

Consider that, in C, parameter handling is done such that you can pass many arguments to a function/subroutine, but only one can be returned.

这篇关于将各种参数从 C 传递给汇编程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆