0
嗨我在做汇编8086 DES,我有很多数组,我也需要一些程序,但我不知道如何发送数组到一个过程。我试着用堆栈,但它没有奏效。你能帮我一下吗?我使用的是TASM如何将数组发送到过程
嗨我在做汇编8086 DES,我有很多数组,我也需要一些程序,但我不知道如何发送数组到一个过程。我试着用堆栈,但它没有奏效。你能帮我一下吗?我使用的是TASM如何将数组发送到过程
假设你有一个定义为字的数组:
myArray dw 10, 9, 8, 7, 6, 5, 4, 3, 2, 1
numItems dw 10
你想传递给一个过程:
push myArray ; the address of the array
mov ax, [numItems]
push ax ; the length of the array
call myProc
; if you want the caller to clean up ...
add sp, 4 ; adjust sp to get rid of params
然后MYPROC是:
myProc:
mov bp, sp ; save stack pointer
mov cx, [bp+4] ; cx gets the number of items
mov bx, [bp+6] ; bx gets the address of the array
; at this point, you can address the array through [bx]
mov ax, [bx+0} ; first element of the array
mov ax, [bx+2] ; second element of the array
ret 4 ; cleans up the stack, removing the two words you'd pushed onto it
; or, if you want the caller to clean up ...
ret
好吧,这很有用,谢谢。但如果我有两个不同的数组,我需要从其中一个移动值的另一个,我需要不同的索引,每次我移动一个值?例如,首先移动位置5的值,然后在位置20的值。我该怎么做?我只是发现了这样的东西 – 2012-04-15 21:58:08
@AlvaroFallas:我建议你找一个好的汇编语言教程。汇编语言艺术受到好评。 http://www.planetpdf.com/codecuts/pdfs/aoa.pdf – 2012-04-15 22:11:49
对不起,因为我说我做了这样的事情,以便从不同的位置得到一个值mov ax,byte ptr DS:[[bp + 6 ] +(bx * 2)] bp + 6是我需要bx的数组地址* 2是我的位置。但是,获取错误消息“Ilegal索引模式” – 2012-04-15 22:13:45