Balthazarion
Balthazarion

Reputation: 25

Find array length in 8086 assembly

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?

Upvotes: 0

Views: 9890

Answers (2)

Ibrahem M. Nasser
Ibrahem M. Nasser

Reputation: 1

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

Upvotes: 0

rcgldr
rcgldr

Reputation: 28876

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

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

Upvotes: 1

Related Questions