어셈블리 코드를 작성하는 방법을 배우려하고 있으며 http://gnu.mirrors.pair.com/savannah/savannah//pgubook/ProgrammingGroundUp-0-8.pdf을 사용하여 작업하고 있습니다. 그것은 훌륭한 리소스이고 Macho64 형식으로 내 Mac 용 64 비트 코드를 작성하려고합니다.상대 주소 지정 오류 - Mac 10.10
절대 및 상대 주소 지정과 관련된 문제가 발생했습니다.
이
내 코드입니다 :DEFAULT REL
;PURPOSE: This program finds the maximum number of a set of data items
;
;VARIABLES: The registers have the following uses
;
; rbx - Holds the index of the data item being examined
; rdi - Largest data item found
; rax - Current data item
;
; The following memory locations are used:
;
; data_items - contains the item data. A 0 is used to terminate the data
;
global _main
section .data
data_items: dw 3,67,34,222,45,75,54,34,44,33,22,11,66,0
;These are the data items
section .text
_main:
mov rdi, 0 ;move 0 into index register
mov rax, [data_items+rbx*4] ;load the first data byte
mov rdi, rax ;since this is the first item, eax is biggest
start_loop: ;start loop
cmp 0, rax ;check to see if we've hit the end
je loop_exit
inc rdi
mov rax, [data_items+rbx*4]
cmp rdi, rax
jle start_loop
mov rdi,rax
jmp start_loop
loop_exit:
mov rax, 0x2000001 ;1 is the exit() syscall
syscall
이들은 내가 오류 메시지입니다 : 누군가가 나를 도울 수 있다면
Samuels-MBP:Starting sam$ make
src/maximum.s:26: error: Mach-O 64-bit format does not support 32-bit absolute addresses
src/maximum.s:30: error: invalid combination of opcode and operands
src/maximum.s:33: error: Mach-O 64-bit format does not support 32-bit absolute addresses
그래서 궁금했다. 상대 주소 지정 (Relative Addressing)을 찾았지만 단순한 언어로 잘못된 것을 설명하는 것을 찾을 수 없습니다.
cmp 문구가 잘못되었다는 것을 알고 있지만 그 문제를 해결할 수 있다고 생각합니다.
정말 고마워요. 그게 정확히 답이었습니다. –
@LordWindy, 30 행의 오류로'cmp 0, rax'를'cmp rax, 0'으로 변경하십시오. –