Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 1  herhaling: geindexeerd, CMP, stack  operand2.

Similar presentations


Presentation on theme: "Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 1  herhaling: geindexeerd, CMP, stack  operand2."— Presentation transcript:

1 Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 1  herhaling: geindexeerd, CMP, stack  operand2  geheugen indeling, pseudo-operaties  oefeningen: LCD, hoofdletters

2 Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 2 LDR R0, [ R1 ]: LDR R0, [ R1 ], #4 LDR R0, [ R1, #4 ] LDR R0, [ R1, #4 ] !

3 Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 3 LDR R0, [ R1 ] R0 R R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 = SP R14 = LR R14 = PC registers ……. FFFF FFFB FFFF FFFC FFFF FFFD FFFF FFFE FFFF geheugen

4 Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 4 LDR R0, [ R1 ], #4 R0 R R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 = SP R14 = LR R14 = PC registers ……. FFFF FFFB FFFF FFFC FFFF FFFD FFFF FFFE FFFF geheugen

5 Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 5 LDR R0, [ R1, #4 ] R0 R R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 = SP R14 = LR R14 = PC registers ……. FFFF FFFB FFFF FFFC FFFF FFFD FFFF FFFE FFFF geheugen

6 Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 6 LDR R0, [ R1, #4 ] ! R0 R R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 = SP R14 = LR R14 = PC registers ……. FFFF FFFB FFFF FFFC FFFF FFFD FFFF FFFE FFFF geheugen

7 Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 7 CMP R1, R2 CMP R1, #15 CMN R1, R2 CMN R1, #10

8 Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 8 CMP R1, R2 R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 = SP R14 = LR R15 = PC registers ……. FFFF FFFB FFFF FFFC FFFF FFFD FFFF FFFE FFFF geheugen - flags

9 Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 9 CMN R1, #15 R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 = SP R14 = LR R15 = PC registers ……. FFFF FFFB FFFF FFFC FFFF FFFD FFFF FFFE FFFF geheugen + flags

10 Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 10 STMFD SP!, { R1-R9, R12 } LDMFD SP!, { R1-R9, R12 }

11 Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 11 Stack A stack is an area of memory which grows as new data is “pushed” onto the “top” of it, and shrinks as data is “popped” off the top. stack pointer used to point the current “top” of the stack. empty ascending / empty decending / full ascending / full decenuing SP PUSH {1,2,3} POP 1 2 Result of pop = 3 SP

12 Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 12 Stack Operation Traditionally, a stack grows down in memory, with the last “pushed” value at the lowest address. The ARM also supports ascending stacks, where the stack structure grows up through memory. The value of the stack pointer can either: –Point to the last occupied address (Full stack) and so needs pre-decrementing (ie before the push) –Point to the next occupied address (Empty stack) and so needs post-decrementing (ie after the push) The stack type to be used is given by the postfix to the instruction: –STMFD / LDMFD : Full Descending stack –STMFA / LDMFA : Full Ascending stack. –STMED / LDMED : Empty Descending stack –STMEA / LDMEA : Empty Ascending stack Note: ARM Compiler will always use a Full descending stack.

13 Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 13 Block Data Transfer instructie code The Load and Store Multiple instructions (LDM / STM) allow betweeen 1 and 16 registers to be transferred to or from memory. The transferred registers can be either: –Any subset of the current bank of registers (default). ^ –Any subset of the user mode bank of registers when in a priviledged mode (postfix instruction with a ‘^’). Cond P U S W L Rn Register list Condition field Base register Load/Store bit 0 = Store to memory 1 = Load from memory Write- back bit 0 = no write-back 1 = write address into base PSR and force user bit 0 = don’t load PSR or force user mode 1 = load PSR or force user mode Up/Down bit 0 = Down; subtract offset from base 1 = Up ; add offset to base Pre/Post indexing bit 0 = Post; add offset after transfer, 1 = Pre ; add offset before transfer Each bit corresponds to a particular register. For example: Bit 0 set causes r0 to be transferred. Bit 0 unset causes r0 not to be transferred. At least one register must be transferred as the list cannot be empty.

14 Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 14 Operand2: MOV R0, R1 ADD R0, R1, #2 SUBC R0, R1, R2, LSL #5 ADDS R1, R2, R3, ASR R4

15 Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 15

16 Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 16 Wat zit er in het geheugen van een programma: Code (text) Globale data met initiele waarde (data) Globale data zonder initiele waarde (bss) Stack (evt lokale data) Heap

17 Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 17

18 Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 18 Wat zit in een “image”  Code (text)  Globale data met initiele waarde (data) Globale data zonder initiele waarde (bss) Stack Heap

19 Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 19 Wat kan/moet in ROM (read-only)  Code (text)  Globale data met initiele waarde (data)  maar wel copieren naar RAM! Globale data zonder initiele waarde (bss) Stack Heap

20 Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 20 Code voor een ROMmable image  C zorgt zelf wel voor de juiste verdeling  Assembler: code moet in.text geinitialiseerde schrijfbare data moet in.data ongeinitialiseerde data hoort in.bss

21 Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 21. global main getal_1 :.word 11 getal_2 :.word 22 getal_3 :.word 33 som :.word hier komt uw code: done: b done

22 Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 22. global main.data.align getal_1 :.word 11 getal_2 :.word 22 getal_3 :.word 33.bss.align som :.skip 4.text.align hier komt uw code: done: b done

23 Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 23 Text vastleggen (data segment).data hello:.asciz ”Hello!”.text ldr r1, =hello

24 Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 24 Text vastleggen (text segment).text hello:.asciz ”Hello!”.align ldr r1, =hello

25 Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 25 Schrijf een (nette!) subroutine LCD_PUTASCIZ die de 0-terminated string waar R0 naar wijst naar het LCD schrijft. Maak gebruik van een geindexeerde instructie (en natuurlijk van LCD_PUTCHAR). Demonstreer dit, maak natuurlijk gebruik van.asciz.

26 Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 26 Schrijf een (nette!) subroutine UPCHAR die het ASCII character in R0, als dit een kleine letter is, omzet naar een hoofdletter. Demonstreer deze subroutine door een variatie op LCD_PUTASCIZ te maken (bv LCD_PUTASCIZ_UPCHAR).

27 Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 27 Tips:  ASCII lezen: byte-wise  flags beinvloeden: S erachter  vergelijken: CMP (geen S nodig)  Wat is de ASCII waarde van kleine letter a? Geen idee, ik gebruik gewoon ’a’…


Download ppt "Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 1  herhaling: geindexeerd, CMP, stack  operand2."

Similar presentations


Ads by Google