Hi ,I am new in Assembly and I am trying to print the first element of array
putint is macros include in Cs266
.386
.model flat
include Cs266.inc
.data
Arr DW 1,2,5,9,12
.code
main:
mov AX,[Arr]
putint AX
ret
end
Hi ,I am new in Assembly and I am trying to print the first element of array
putint is macros include in Cs266
.386
.model flat
include Cs266.inc
.data
Arr DW 1,2,5,9,12
.code
main:
mov AX,[Arr]
putint AX
ret
end
mov edi, offset Arr
mov ax, word ptr [edi +2 *0]
1st line you are moving the address of Arr into edi
2nd line you are moving the 1st value in the array to ax. since your array are WORDS we use +2 if they were DWORDS you would use + 4, the *0 is the first array element, * 1 is the second, * 2 is the 3rd etc...
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.