汇编中的结构或类 [英] struct or class in assembly
本文介绍了汇编中的结构或类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要c ++中的struct或class之类的东西
I need something like struct or class in c++
例如,我需要一个带有数组和两个属性(大小和len)的类以及一些诸如append和remove之类的函数.
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手册:
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
这篇关于汇编中的结构或类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文