워드 배열에서 가장 큰 값을 반환하는 프로 시저를 작성하려고했습니다. 로컬 변수를 here으로 표시된 규칙에 따라 할당했습니다. 하지만 지역 변수에 값을 이동하려고 할 때 그것이 나에게이 오류 제공 : 어떤 도움을 크게 감상 할 수Nasm 어셈블리. 값을 스택의 로컬 변수로 옮길 수 없습니다.
greatest:
push ebp
mov ebp, esp
;allocate local variables here
sub esp, 4
;push stuff
push esi
mov ecx, [ebp+12] ;size of the array
mov eax, [ebp+8] ;offset of the array
mov esi, 0 ;counter for accessing elements
mov ebp-4, eax ;error here
l1:
push ecx
mov ecx, [eax + 2*esi] ;get the variable
cmp [ecx], [ebp-4] ;compare values
jb if_2
mov ebp-4, ecx ;error here
if_2:
inc esi
pop ecx
loop l1
mov eax, [ebp-4]
pop esi
mov esp, ebp
pop ebp
ret
:
'cmp [ecx], [ebp-4]'mem과 mem를 비교할 수 없습니다 –
@Alexander Zhak하지만 레지스트리에 있습니다. 컴파일러는 신경 쓰지 않는 것 같습니다. 나는 주어진 링크에서 MASM이 사용되고 'mov ebp-4, eax'가 잘 작동한다는 것을 알고 싶다. NASM에서는 그렇게 보이지 않습니다. 메모리 및 값 주소 지정을위한 구문과 관련이 있습니다. –
MASM은'mov ebp-4, eax'를 모으기를 거부합니다. "* 오류 A2032 : 레지스터 * 사용이 잘못되었습니다." – rkhb