程序集中的结构体或类(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 StringGnu汇编程序也有一个.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.lenTasm supports eg.
struc String // note: without 't' at the end size dw 100 len dw 10 data db 0 dup(100) ends StringGnu assembler also has a .struct directive.
The syntax for MASM is:
String STRUCT size dw 100 len dw 10 String ENDSUsage 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 pointerOne can also access a local variable directly
mov eax, myStruct.len更多推荐
发布评论