arm assembler
play

ARM Assembler Data Movement Beginning Programs p. 1/10 Memory - PowerPoint PPT Presentation

Systems Architecture ARM Assembler Data Movement Beginning Programs p. 1/10 Memory Access Load Register from memory cc : MAR op2 LDR cc R d , op2 cc : MBR M(MAR) cc : R d MBR


  1. Systems Architecture ARM Assembler Data Movement Beginning Programs – p. 1/10

  2. Memory Access Load Register from memory • � cc � : MAR ← � op2 � LDR � cc � R d , � op2 � � cc � : MBR ← M(MAR) � cc � : R d ← MBR Store Register in memory • � cc � : MAR ← � op2 � STR � cc � R s , � op2 � � cc � : MBR ← R s � cc � : M(MAR) ← MBR Memory Reference must be 32-bit word aligned • otherwise a Data Abort Exception will occur use the ALIGN directive to force alignment Beginning Programs – p. 2/10

  3. Load / Store Byte Load Register with unsigned Byte from memory • � cc � : MAR ← � op2 � LDR � cc � B R d , � op2 � � cc � : MBR ← M(MAR) � cc � : R d (7:0) ← MBR � cc � : R d (31:8) ← 0 Load Register with Signed Byte from memory • � cc � : MAR ← � op2 � LDR � cc � SB R d , � op2 � � cc � : MBR ← M(MAR) � cc � : R d (7:0) ← MBR � cc � : R d (31:8) ← R d (7) Store Register in a Byte of memory • � cc � : MAR ← � op2 � STR � cc � B R s , � op2 � � cc � : MBR ← R s � cc � : M(MAR) ← R s (7:0) Beginning Programs – p. 3/10

  4. Load / Store Halfword Does not work in the ARMulator • • An ARM word is 32-bits, so a Halfword is 16-bits • Memory Reference must be Halfword aligned • Load Register with unsigned Halfword from memory � cc � : MAR ← � op2 � LDR � cc � H R d , � op2 � � cc � : MBR ← M(MAR) � cc � : R d (15:0) ← MBR � cc � : R d (31:16) ← 0 • Load Register with Signed Halfword from memory � cc � : MAR ← � op2 � LDR � cc � SH R d , � op2 � � cc � : MBR ← M(MAR) � cc � : R d (15:0) ← MBR � cc � : R d (31:16) ← R d (15) • Store Register in a Halfword of memory � cc � : MAR ← � op2 � STR � cc � H R s , � op2 � � cc � : MBR ← R s � cc � : M(MAR) ← MBR(15:0) Beginning Programs – p. 4/10

  5. Program: move16.s 1. ; 16bit data transfer 2. 3. TTL move16 – 16-bit data transfer 4. AREA Program, CODE, READONLY 5. ENTRY 6. 7. Main 8. LDRB R1, Value ; Load value 9. STR R1, Result ; Sore it again 10. SWI &11 ; exit() 11. 12. Value DCW &C123 ; Source value to be moved 13. ALIGN ; Alling next word 14. Result DCW 0 ; Reserve space for result 15. 16. END Beginning Programs – p. 5/10

  6. Program: move16.s 1. ; 16bit data transfer 2. 3. TTL move16 – 16-bit data transfer 4. AREA Program, CODE, READONLY 5. ENTRY 6. 7. Main 8. LDRB R1, Value ; Load value 9. STR R1, Result ; Sore it again 10. SWI &11 ; exit() 11. 12. Value DCW &C123 ; Source value to be moved 13. ALIGN ; Alling next word 14. Result DCW 0 ; Reserve space for result 15. 16. END Define Program Title TTL Beginning Programs – p. 5/10

  7. Program: move16.s 1. ; 16bit data transfer 2. 3. TTL move16 – 16-bit data transfer 4. AREA Program, CODE, READONLY 5. ENTRY 6. 7. Main 8. LDRB R1, Value ; Load value 9. STR R1, Result ; Sore it again 10. SWI &11 ; exit() 11. 12. Value DCW &C123 ; Source value to be moved 13. ALIGN ; Alling next word 14. Result DCW 0 ; Reserve space for result 15. 16. END AREA Label Program Area Code or Data space; Read Only or Read / Write Beginning Programs – p. 5/10

  8. Program: move16.s 1. ; 16bit data transfer 2. 3. TTL move16 – 16-bit data transfer 4. AREA Program, CODE, READONLY 5. ENTRY 6. 7. Main 8. LDRB R1, Value ; Load value 9. STR R1, Result ; Sore it again 10. SWI &11 ; exit() 11. 12. Value DCW &C123 ; Source value to be moved 13. ALIGN ; Alling next word 14. Result DCW 0 ; Reserve space for result 15. 16. END ENTRY Define Program Entry Point Beginning Programs – p. 5/10

  9. Program: move16.s 1. ; 16bit data transfer 2. 3. TTL move16 – 16-bit data transfer 4. AREA Program, CODE, READONLY 5. ENTRY 6. 7. Main 8. LDRB R1, Value ; Load value 9. STR R1, Result ; Sore it again 10. SWI &11 ; exit() 11. 12. Value DCW &C123 ; Source value to be moved 13. ALIGN ; Alling next word 14. Result DCW 0 ; Reserve space for result 15. 16. END Main Label the memory address Debug will place breakpoint at Main Beginning Programs – p. 5/10

  10. Program: move16.s 1. ; 16bit data transfer 2. 3. TTL move16 – 16-bit data transfer 4. AREA Program, CODE, READONLY 5. ENTRY 6. 7. Main 8. LDRB R1, Value ; Load value 9. STR R1, Result ; Sore it again 10. SWI &11 ; exit() 11. 12. Value DCW &C123 ; Source value to be moved 13. ALIGN ; Alling next word 14. Result DCW 0 ; Reserve space for result 15. 16. END SWI Software Interrupt — Call the Operating System exit() Beginning Programs – p. 5/10

  11. Program: move16.s 1. ; 16bit data transfer 2. 3. TTL move16 – 16-bit data transfer 4. AREA Program, CODE, READONLY 5. ENTRY 6. 7. Main 8. LDRB R1, Value ; Load value 9. STR R1, Result ; Sore it again 10. SWI &11 ; exit() 11. 12. Value DCW &C123 ; Source value to be moved 13. ALIGN ; Alling next word 14. Result DCW 0 ; Reserve space for result 15. 16. END & Define a Hexadecimal value Beginning Programs – p. 5/10

  12. Program: move16.s 1. ; 16bit data transfer 2. 3. TTL move16 – 16-bit data transfer 4. AREA Program, CODE, READONLY 5. ENTRY 6. 7. Main 8. LDRB R1, Value ; Load value 9. STR R1, Result ; Sore it again 10. SWI &11 ; exit() 11. 12. Value DCW &C123 ; Source value to be moved 13. ALIGN ; Alling next word 14. Result DCW 0 ; Reserve space for result 15. 16. END DCW Define a 16-bit data value Beginning Programs – p. 5/10

  13. Program: move16.s 1. ; 16bit data transfer 2. 3. TTL move16 – 16-bit data transfer 4. AREA Program, CODE, READONLY 5. ENTRY 6. 7. Main 8. LDRB R1, Value ; Load value 9. STR R1, Result ; Sore it again 10. SWI &11 ; exit() 11. 12. Value DCW &C123 ; Source value to be moved 13. ALIGN ; Alling next word 14. Result DCW 0 ; Reserve space for result 15. 16. END ALIGN Align data item on 32-bit word boundary Beginning Programs – p. 5/10

  14. Program: move16.s 1. ; 16bit data transfer 2. 3. TTL move16 – 16-bit data transfer 4. AREA Program, CODE, READONLY 5. ENTRY 6. 7. Main 8. LDRB R1, Value ; Load value 9. STR R1, Result ; Sore it again 10. SWI &11 ; exit() 11. 12. Value DCW &C123 ; Source value to be moved 13. ALIGN ; Alling next word 14. Result DCW 0 ; Reserve space for result 15. 16. END END End of program source Beginning Programs – p. 5/10

  15. Program: move16.s 1. ; 16bit data transfer 2. 3. TTL move16 – 16-bit data transfer 4. AREA Program, CODE, READONLY 5. ENTRY 6. 7. Main 8. LDRB R1, Value ; Load value 9. STR R1, Result ; Sore it again 10. SWI &11 ; exit() 11. 12. Value DCW &C123 ; Source value to be moved 13. ALIGN ; Alling next word 14. Result DCW 0 ; Reserve space for result 15. 16. END Assembler can only find syntax errors Bug You have to find the logical errors Beginning Programs – p. 5/10

  16. Data Movement MOV Move Data • MOVS Move Data and Set Zero and Negative flags MOV � cc � Move Data if � cc � � cc � : ALU ← � op1 � MOV � cc �� S � R d , � op1 � • � cc � : R d ← ALU � S �� cc � : CPSR ← ALU(Flags) Move and Negate Data • � cc � : ALU ← � op1 � MVN � cc �� S � R d , � op1 � � cc � : R d ← ALU � S �� cc � : CPSR ← ALU(Flags) R d is the destination (must be a register) • � op1 � is the source • Beginning Programs – p. 6/10

  17. Program: invert.s 1. ; Find the one’s compliment (inverse) of a number 2. 3. TTL invert.s – one’s complement 4. AREA Program, CODE, READONLY 5. ENTRY 6. 7. Main 8. LDR R1, Value ; Load number to be processed 9. MVN R1, R1 ; Invert (not) the value 10. STR R1, Result ; Store the result 11. SWI &11 ; exit() 12. 13. Value DCD &C123 ; Value to be complemented 14. Result DCD 0 ; Reserve space for result 15. 16. END Beginning Programs – p. 7/10

  18. Program: invert.s 1. ; Find the one’s compliment (inverse) of a number 2. 3. TTL invert.s – one’s complement 4. AREA Program, CODE, READONLY 5. ENTRY 6. 7. Main 8. LDR R1, Value ; Load number to be processed 9. MVN R1, R1 ; Invert (not) the value 10. STR R1, Result ; Store the result 11. SWI &11 ; exit() 12. 13. Value DCD &C123 ; Value to be complemented 14. Result DCD 0 ; Reserve space for result 15. 16. END Labels Used to access memory directly Beginning Programs – p. 7/10

  19. Program: invert.s 1. ; Find the one’s compliment (inverse) of a number 2. 3. TTL invert.s – one’s complement 4. AREA Program, CODE, READONLY 5. ENTRY 6. 7. Main 8. LDR R1, Value ; Load number to be processed 9. MVN R1, R1 ; Invert (not) the value 10. STR R1, Result ; Store the result 11. SWI &11 ; exit() 12. 13. Value DCD &C123 ; Value to be complemented 14. Result DCD 0 ; Reserve space for result 15. 16. END DCD Used to define (and initialise) memory values No need for ALIGN as DCD defines 32-bit values Beginning Programs – p. 7/10

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend