我想将字节数组(或指向该数组的指针)传递给 8086 程序集中的函数。
当我尝试指向PUSH
该指针时,它给了我一个编译错误。错误是“错误的参数”。
org 100h
JMP Start
Donnee DB 0ABh,0CDh,0EFh
;; Principal program ;;
Start:
PUSH Donnee
CALL CalculeCRC
POP CRC
ret
The PUSH opcode expects a DWORD value, either in memory or a register. In your case, you're trying to push an array of three bytes. I think, technically speaking, this is valid code, but the assembler recognizes that it's not really want you intended. (It might be interested to see if the code will assemble if you added another element to your array of bytes, but that's beside the point).
In any case, what you are trying to do is not what you want to happen. You want to push the pointer to the array onto the stack before you call your function, you ARE NOT trying to push the entire array onto the stack. Even if the assembler let you this would be very bad because it would be a waste of memory. In order to do what you want to do, you'll need to get the address of your array and push that onto the stack. You can use LEA to get the "effective address" of the array:
lea eax, Donnee
push eax
of you can do the following:
push OFFSET Donnee
我当然不是 8086 方面的专家,但我会阅读 PUSH 指令,看看它真的可以达到你的预期。
从一个非常快速的检查来看,我认为它需要一个寄存器,所以你需要先将地址加载到寄存器中,然后推送寄存器。
也许是这样的:
lea ax, Donnee
push ax
这里可能存在标点符号和/或参数排序错误;我手边没有 8086 汇编器。