程序集中的结构体或类(struct or class in assembly)

系统教程 行业动态 更新时间:2024-06-14 16:59:17
程序集中的结构体或类(struct or class in assembly)

我需要类似于C ++中的结构体或类

例如,我需要一个具有数组和两个属性(大小和len)的类以及一些像append和remove一样的函数。

我怎样才能用宏和过程在汇编中实现这一点?

I need something like struct or class in c++

For example I need a class with an array and two attribute (size and len) and some function like append and remove .

How can I implement this in assembly with macros and procedures?

最满意答案

Tasm支持例如。

struc String // note: without 't' at the end size dw 100 len dw 10 data db 0 dup(100) ends String

Gnu汇编程序也有一个.struct指令。

MASM的语法是:

String STRUCT size dw 100 len dw 10 String ENDS

从相同的MASM手册再次使用:

ASSUME eax:PTR String mov ecx, [eax].size, mov edx, [eax].len ASSUME eax:nothing .. or .. mov ecx, (String PTR [eax]).size // One can 'cast' to struct pointer

你也可以直接访问一个局部变量

mov eax, myStruct.len

Tasm supports eg.

struc String // note: without 't' at the end size dw 100 len dw 10 data db 0 dup(100) ends String

Gnu assembler also has a .struct directive.

The syntax for MASM is:

String STRUCT size dw 100 len dw 10 String ENDS

Usage again from the same MASM manual:

ASSUME eax:PTR String mov ecx, [eax].size, mov edx, [eax].len ASSUME eax:nothing .. or .. mov ecx, (String PTR [eax]).size // One can 'cast' to struct pointer

One can also access a local variable directly

mov eax, myStruct.len

更多推荐

本文发布于:2023-04-16 14:39:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/a4458a50f7dd8d9a10dbe91d947077e0.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:结构   程序   struct   class   assembly

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!