2012-11-21 2 views
1

누구든지이 짧은 프로그램의 기능을 설명 할 수 있습니까? 내가 제대로 생각하고 있다면ARM 어셈블리 코드 이해

ORIGIN 0x1000 
one DEFW 13 
two DEFW 29 
three DEFW 0 
ORIGIN 0x1010 
ENTRY 
ADR R0, one 
LDR R1, [R0] 
LDR R2, [R0, #4] 
ADD R1, R2, R1 
STR R1, [R0, #8] 
SWI 2 

, 그것은 '이'에서 '일'을 추가하고 '세'의 결과를 저장합니다. 나 맞아?

+0

+1 멋진 아이콘! –

+1

이 숙제가 있습니까? 왜 그걸 모호하게 했니? 그렇게하면 다른 사람들에게 유용하지 않습니다. – tangrs

답변

7

예.

ORIGIN 0x1000   # Start at address 0x1000 
one DEFW 13   # Allocate 4-bytes of space for a variable called one and set it to 13 
two DEFW 29   # Allocate 4-bytes of space for a variable called two and set it to 29 
three DEFW 0   # Allocate 4-bytes of space for a variable called three and set it to 0 
ORIGIN 0x1010   # Skip ahead to address 0x1010 (this really leaves a 4-byte gap) 
ENTRY     # Mark next instruction as the begining of program 
ADR R0, one   # Load address of one into R0 
LDR R1, [R0]   # Load contents of one (pointed to but R0) into R1 
LDR R2, [R0, #4]  # Load contents of two (pointed to but R0 + 4) into R2 
ADD R1, R2, R1   # R1 = R2 + R1 
STR R1, [R0, #8]  # Store R1 into three (pointed to but R0 + 8) 
SWI 2     # Execute a software interrupt 

또는 'SWI 2'확실하지

three = one + two 

그것은 아마 당신의 플랫폼 특정 뭔가. 프로그램 호출의 일반적인 끝 일 수도 있습니다.

+0

+1 : http://www.ee.ic.ac.uk/pcheung/teaching/ee2_computing/swi.pdf는 'SWI 2'가 어떤 종류의 디버그 스트림 (적어도이 시스템에서) . – Leo

+0

일부 ARM 시스템에서 SWI는 "SoftWare Interrupt"의 약자입니다. –

+0

SWI는 소프트웨어 인터럽트 명령어입니다. @Pete Fordham이 말했듯이 SWI 2는 플랫폼에 달려 있습니다. –