Been trying different variations of syntax that I've seen and found that using .DATA vs .data I have unexpected results (for me).
take the following
; cmovtest.asm
bits 32
[SECTION .DATA]
output: db "The largest value is %d",0Ah,0h
values: dd 8, 7, 6, 5, 4, 3, 2, 1, 0, 15, 20
valueLen: equ $-values
[SECTION .TEXT]
extern printf
extern exit
global main
main:
nop
mov ebx, [values] ; ebx = values[0]
mov edi, 1
again:
mov eax, [values + edi * 4]
cmp eax, ebx
cmova ebx, eax
inc edi
cmp edi, valueLen
jne again
push ebx ; push the actual value
push output ; Push address of output
call printf
add esp, 8
push 0
call exit
when run the output is: "The largest value is -529"
where the following gives the expected result
; cmovtest.asm
bits 32
[SECTION .data]
output: db "The largest value is %d",0Ah,0h
values: dd 8, 7, 6, 5, 4, 3, 2, 1, 0, 15, 20
valueLen: equ $-values
[SECTION .data]
extern printf
extern exit
global main
main:
nop
mov ebx, [values] ; ebx = values[0]
mov edi, 1
again:
mov eax, [values + edi * 4]
cmp eax, ebx
cmova ebx, eax
inc edi
cmp edi, valueLen
jne again
push ebx ; push the actual value
push output ; Push address of output
call printf
add esp, 8
push 0
call exit
"The largest value is 20"
So why does using .data give me the expected value when .DATA does not?