在8086汇编中查找数组长度

时间:2021-12-26 03:18:10

Is there an easy way to find an array length in 8086 assembly language, or is this something that should be known ahead of time?

是否有一种简单的方法可以在8086汇编语言中找到数组长度,或者这是应该提前知道的事情?

2 个解决方案

#1


1  

If the array is defined locally, you can use LENGTHOF (number of elements), or SIZEOF (number of bytes):

如果数组是在本地定义的,则可以使用LENGTHOF(元素数)或SIZEOF(字节数):

str     db      'example string',0dh,0ah,00h
; ...
        lea     ebx,str
        mov     ecx,sizeof str

#2


0  

.data
  arr dw 3h,1h,2h 
  count = ($-arr)
.code
mov ax,count      ;will contain the length , here is 6

#1


1  

If the array is defined locally, you can use LENGTHOF (number of elements), or SIZEOF (number of bytes):

如果数组是在本地定义的,则可以使用LENGTHOF(元素数)或SIZEOF(字节数):

str     db      'example string',0dh,0ah,00h
; ...
        lea     ebx,str
        mov     ecx,sizeof str

#2


0  

.data
  arr dw 3h,1h,2h 
  count = ($-arr)
.code
mov ax,count      ;will contain the length , here is 6