1 / 23

Wat gaan we doen?

Wat gaan we doen?. herhaling ARM assembler instructies nieuwe ARM assembler instructie variaties Assembler directives LCD library voor het bordje Oefeningen. Herhaling. LDR R0, =value @ load fixed value MOV R0, R1 @ reg-reg copy LDR R0, [ R1 ] @ read from memory

Download Presentation

Wat gaan we doen?

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Wat gaan we doen? • herhaling ARM assembler instructies • nieuwe ARM assembler instructie variaties • Assembler directives • LCD library voor het bordje • Oefeningen Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  2. Herhaling LDR R0, =value @ load fixed value MOV R0, R1 @ reg-reg copy LDR R0, [ R1 ] @ read from memory STR R0, [ R1 ] @ write to memory ADD R0, R1, R2 @ R0 = R1 + R2 ADD R0, R1, #15 @ R0 = R1 + 15 B label @ spring naar label BL subroutine @ spring naar subroutine Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  3. Herhaling ADD R0, R1, R2 @ tel op ADDS R0, R1, R2 @ en zet status ADDEQ R0, R1, R2 @ doe alleen als ‘EQ’ ADDSEQ R0, R1, R2 @ combinatie Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  4. Herhaling STMFD SP!, { R1-R9, R12 } @ bewaar op de stack LDMFD SP!, { R1-R9, R12 } @ herstel vanaf de stack STMFD SP!, { R1-R3, LR } @ subroutine start LDMFD SP!, { R1-R3, PC } @ subroutine end Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  5. Nieuw Variaties op LDR R0, [ R1 ]: LDR R0, [ R1 ] @ word (32 bit) LDRH R0, [ R1 ] @ half-word (16 bit) LDRB R0, [ R1 ] @ byte (8 bit) - H of B komt achteraan, dus: LDREQB - Let op de alignment van het geheugen adres! - Kan ook met STR Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  6. Nieuw @directives: .word 123, 0x15 .hword 12 .byte 0 • Reserveert plaats voor 4, 2 of 1 byte • Je moet een waarde opgeven, die wordt in het geheugen geplaatst • Kan in een keer meerdere plaatsen reserveren • Je kan een label gebruiken Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  7. Nieuw .ascii ”hello world” .asciz ”hello world” • Reserveert plaats voor de characters (1 byte per character) en plaatst de characters in het geheugen • ASCIZ plakt er nog een ‘\0’ achteraan • Je kan een label gebruiken Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  8. Nieuw .skip 300 • Maakt ruimte voor 300 bytes • De waarde van die bytes is (in principe) onbepaald Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  9. Nieuw .align 2 .align 4 • HWORDs moeten op 2-byte aligined adressen geplaatst worden • WORDs en instructies moeten op 4-byte aligned adressen geplaatst worden Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  10. het bordje • sluit een bordje aan (parallel + USB) • installeer de files uit flip.zip • in een lege directory • let op: geen spaties in de pathname  • dubbel-klik op de .ppr file • build • start debugger Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  11. het bordje zet onder file > target settings: • Target = Remote/TCP • Hostname = 127.0.0.1 • Port = 8888 (als je netjes afsluit blijft zou dit moeten blijven staan) Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  12. het bordje Als je dit krijgt moet je onder control panel > system > hardware > device manager (select view > show hidden devices) > non plug-and-pray devices > MAC_MOT > driver instellen op status = started, type = automatic Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  13. het bordje Als je dit krijgt heb je debugger/loader niet afgesloten Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  14. het bordje Voor als het even echt niet meer werkt: • als je de debugger hebt afgesloten moeten al die DOS schermen ook weg zijn (evt met de hand sluiten) • De editor sluiten en weer opstarten • de USB en Paralelle kabels er even uithalen om het bordje te resetten, USB eerst weer aansluiten, dan parallel. • PC uitzetten en weer aanzetten Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  15. LCD LCD aansturen • file hello.zip • uitpakken naar lege directory (geen spaties in de pathname…) • run ‘as is’ geeft een “H” op het display Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  16. LCD library main delay library Chip startup code Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  17. LCD Library Subroutines: LCD_INIT eenmalig aanroepen LCD_CLEAR maakt het display leeg, cursor naar eerste positie LCD_PUTCHAR print het char in R0; schuift de cursor naar volgende LCD positie Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  18. Wait Library Subroutines: Wait_uS wacht het aantal microseconden dat in R0 staat Wait_mS wacht het aantal milliseconden dat in R0 staat Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  19. .global main main: @ save registers stmfd sp!, { lr } @ gebruik de LCD bl LCD_INIT bl LCD_CLEAR ldrb r0, =’H’ bl LCD_PUTCHAR @ etc etc klaar: @ return ldmfd sp!, { pc } Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  20. WAIT_mS: @ save registers stmfd sp!, { r0-r1, lr } mov r1, r0 ldr r0, =1000 @ wait wait_ms_loop: bl WAIT_uS adds r1, r1, #-1 bne wait_ms_loop @ save registers and return ldmfd sp!, { r0-r1, pc } Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  21. WAIT_uS: @ save registers stmfd sp!, { r0-r1, lr } @ outer loop is inner loop + 1 + 3 = 11 instructions wait_us_outer_loop: @ full inner loop is 1 instruction + jump = 4 clocks @ total: 1 (ldr) + 1 x 4 (loop) + 2 (loop without jump) = 7 ldr r1, =1 wait_us_inner_loop: adds r1, r1, #-1 bne wait_us_inner_loop adds r0, r0, #-1 bne wait_us_outer_loop @ save registers and return ldmfd sp!, { r0-r1, pc } Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  22. Doen 1 Het LCD moet laten zien: “Hello world”, afgewisseld met “Ha die wereld” (een text 1 seconde laten zien, dan de andere tekst, etc) Doe dit ‘belgisch’, door voor ieder character ldrb r0, =’x’ bl LCD_PUTCHAR op te nemen in het programma. Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  23. Doen 2 Schrijf een subroutine LCD_PUTASCIZ. Deze subroutine krijgt van zijn aanroeper in R0 het adres van een string (reeks characters, afgesloten met een ‘\0’). De subroutine print alle characters in de string (tot aan de ‘\0’). De subroutine heeft geen uitvoer parameters. De subroutine mag dus geen registers wijzigen, ook R0 niet. Herschrijf nu de vorige opdracht, gebruik makend van je subroutine. Plaats de te printen strings in het geheugen dmv .ASCIZ directives. Vergeet niet te alignen. Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

More Related