i need explain for that

bits 16


arr db 0x5,0x1,0x3,0x2,0x7,0x3,0x6,0x4,0x9,0x5
arr_e equ $

i dont know how to make look up table in emu8086 and i dont know whats meaning of bits 16
and "arr" is a file on pc or it's a normal word in a code
in the code we meet
mov si, arr
mov di, arr+2
so if any 1 can explain for me ,it will be great

MrMicro - The first question (bits 16) is a bit difficult to explain given the limited context of the code snippet. It's probably a declaration of a variable that defines the number of bits for some operation somewhere else in the code. Other than that, it remains a mystery. The other parts are rather more simple. The "arr db ..." line is simply defining a sequence of bytes (a byte array) in memory with the specified values. The "arr_e equ $" is the definition of another variable which is initialized with the value "$". $ is usually the current address value, so this is generating a pointer to the first available memory address after the end of "arr". It will probably be used to test that the value used to index the table does not point past the end of the array. Such a technique is more general and less error prone than counting the elements and setting up a predefined value for the maximum index since the address of the end of the array will automatically adjust when more elements are added to the array or if the size of each element is changed.

Later on, you have an instruction (mov si, arr) which loads the address of arr into the source index (i.e., si now points to the byte containing "0x5"). You can then use si to index into this array using something like mov al,[si+3]. This would load 0x2 into al. You can also index based on si using another register. This is how the lookup table works. You put the index of the value to look up in another register, say bx, and then "mov al,[si+bx]" to get the indexed value into al. Keep in mind that the table (here called "arr") can represent anything. It could for example be an array of pointers to strings or complex structures. Virtually anything that you can come up with that can be represented in binary fashion is fair game.

The next line, "mov di, arr+2" is really a mystery when taken out of context. This is putting the address of the 3rd byte of the array into di. For what purpose is unknown.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.