首页 > 解决方案 > 如何在汇编中使用带有 BYTE 参数的 SIZEOF?

问题描述

编辑:我现在正在尝试使用 Str_length,但是当我调试它时它会引发异常

在这种情况下,我不知道如何使用 SIZEOF。我知道如何正常使用它,但我通常将它与数组而不是字符串一起使用。但我认为数组和字符串的工作方式相同

INCLUDE Irvine32.inc

.data
myKey      BYTE   "efbcdghijklmnopqrstuvwxyza"
message    BYTE   "the contents of this message will be a mystery.",0
dest       DWORD   -1
.code

main PROC
    ;; inside the MAIN procedure
    push   OFFSET myKey
    push   OFFSET message
    push   OFFSET dest
    call   compute
    ;; message now contains the encrypted string
    mov    edx, OFFSET message
    call   WriteString
    ;; should display "uid bpoudout pg uijt ndttehd xjmm fd e nztudsz."
      
    exit
main ENDP

compute PROC
...
    ; prepare for encrypting or decrypting
    mov     eax, [esp+12]
    mov     ecx, SIZEOF [esp+12]
    mov     esi, OFFSET [esp+12]
    mov     edi, OFFSET outString
    mov     edx, [esp+16]
    cld
...
compute ENDP

END main```

标签: assemblyx86masmirvine32

解决方案


推荐阅读