2016-11-25 1 views
1

ARM 어셈블리에 라벨을 언급하는 방법 한정된.나는 서로 다른 코드 놀고 싶어 때문에 ARM 어셈블리 코드의 레이블을 주석 싶지만 메인 라벨을 주석 경우에도, 컴파일러는 여전히 레이블이 이미 불평

여기 여기에 코드를

.section .data     


.section .init     
.globl  _start     

_start:       
    b  main     

.section .text     
main:        
    mov  sp, #0x8000   
    mov  r1, #1    
    mov  r2, #3    
    sub  r1, r2    
halt$:       
    b halt$      

.section .data     

; STARTING FROM THIS, IT IS SUPPOSED TO BE COMMENTED OUT        
;.section .init    
;.globl  _start    

;_start:       
    ;b  main     

;.section .text    
;main:       
    ;mov  sp, #0x8000   
    ;bl  EnableJTAG   

    ;mov  r1, #0    
    ;mov  r2, #0    
    ;mov  r3, #0 ;i = 0  

;forloop:       
    ;cmp  r3, #100    
    ;bpl  forloopEnd   

    ;tst  r3, #0xAA   
    ;bne  elseif    

있어 오류가

Error: symbol `_start' is already defined  
Error: symbol `main' is already defined  
Error: symbol `halt$' is already defined  

을 받았다 그래서 내가 컴파일러는 주석 레이블을 무시하도록하기 위해 무엇을 할 수 있는가? 덕분에

+0

어떤 어셈블러입니까? 케일? GNU 어셈블러? –

+4

GNU 어셈블러 인 경우';'대신'#'을 사용하십시오. GNU ARM 어셈블러'에서,'성명 분리기는'#은'라인 주석 문자입니다입니다 –

+0

@MichaelPetch : ARM 구문에서'@'선호 주석 문자는 (모든 ARM 어셈블러, 단지 가스에서 작동). '#'이 (예컨대 ADCS R1, R3 '에서, ROR 번호 0x18') 구문의 일부이지만 아직 명백하게 지시 전에 사용될 때 역시 가스 주석 문자로서 작동한다. 그러나'add r1, r2 # foo'는 * Error : garbage after instruction *을줍니다. ';'는 아직도 가스 문 분리 기호이지만, 이것은 여기서 문제입니다. –

답변

2

사실, 난 블록 주석을 사용하여이 문제를 해결/**/

.section .data     


.section .init     
.globl  _start     

_start:       
    b  main     

.section .text     
main:        
    mov  sp, #0x8000   
    mov  r1, #1    
    mov  r2, #3    
    sub  r1, r2    
halt$:       
    b halt$      

.section .data     

/* 
STARTING FROM THIS, IT IS SUPPOSED TO BE COMMENTED OUT        
.section .init    
.globl  _start    
    _start:       
    b  main     

.section .text    
main:       
    mov  sp, #0x8000   
    bl  EnableJTAG   

    mov  r1, #0    
    mov  r2, #0    
    mov  r3, #0 ;i = 

forloop:       
    cmp  r3, #100    
    bpl  forloopEnd   

    tst  r3, #0xAA   
    bne  elseif 
    ... 
*/   
1

GNU의 ARM 어셈블러 사용하는 경우 @ 문자가 한 줄 주석의 시작을 의미한다 :

The presence of a `@' anywhere on a line indicates the start of a comment that extends to the end of that line.

If a `#' appears as the first character of a line then the whole line is treated as a comment, but in this case the line could also be a logical line number directive (see Comments) or a preprocessor control command (see Preprocessing).

을 이

(source)

+0

실제로'#'는 공백이나 레이블 다음에 실제로 작동합니다. 명령문/지시문보다 앞에있는 한, 가스 중 2.25.1. –