访问结构的成员并将其与常量进行比较
Accessing a member of a struct and comparing it with a constant
我有一个未初始化的结构:
struc my_struct1
.a resd
.b resb
.c resd
.d resb
endstruc
然后填充数据:
mov rax, 123
;.........
mov rdi, [my_struct1]
;.........
syscall
我如何比较其中一个字段的值?在 C 中,我将通过以下方式执行此操作:
if (my_struct1.c == SOME_CONSTANT) {
//......
}
你可以像在 c 中一样做这件事,不是吗?只需在 mystruct 中找到该字段的地址,然后使用您的常量执行 cmp 并检查您需要的任何标志。
cmp [mystruct1+4], YOUR_CONSTANT
jz .jump_somewhere_if_fields_are_equal
您可以在此处阅读有关如何正确使用结构的完整说明,http://mcs.uwsuper.edu/sb/224/Intro/struct_nasm.html
我有一个未初始化的结构:
struc my_struct1
.a resd
.b resb
.c resd
.d resb
endstruc
然后填充数据:
mov rax, 123
;.........
mov rdi, [my_struct1]
;.........
syscall
我如何比较其中一个字段的值?在 C 中,我将通过以下方式执行此操作:
if (my_struct1.c == SOME_CONSTANT) {
//......
}
你可以像在 c 中一样做这件事,不是吗?只需在 mystruct 中找到该字段的地址,然后使用您的常量执行 cmp 并检查您需要的任何标志。
cmp [mystruct1+4], YOUR_CONSTANT
jz .jump_somewhere_if_fields_are_equal
您可以在此处阅读有关如何正确使用结构的完整说明,http://mcs.uwsuper.edu/sb/224/Intro/struct_nasm.html