I want to pass an array of bytes (or the pointer to that array) to a function in 8086 assembly.
When I try to PUSH that pointer, it gives me a compilation error. The error is “Wrong parameters”.
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:
of you can do the following: