Professional Documents
Culture Documents
StudyguideSet#01
February15,2017
Disclaimer:ThecontentsofthisdocumentisastudyguideforTheUniversityofTexasatAustin
EE445MSpring2017,EmbeddedandrealTimeSystems.
Reference:http://users.ece.utexas.edu/~valvano/arm
RTOS
Real Time Operating System
CopyrightHilgadMontelo.Allrightsreserved.
ME445M:EmbeddedandRealTimeSystems
StudyguideSet#01
RTOSPreparation
1) Writeanassemblysubroutinethatselectsbit8.Theinputtothesubroutineisa32bitnumberinR0.The
outputinR0is0iftheinputbit8is0,andtheoutputis1iftheinputbit8is1.
Answer:
CopyrightHilgadMontelo.Allrightsreserved.
ME445M:EmbeddedandRealTimeSystems
StudyguideSet#01
5) Considerthefollowingoperationsequence(inregular32bitARMassembly):
LDR R1,=-168
ASRS R2,R1,#2
CMP R1, R2
Markwhichofthefollowingbrancheswillbetakenafterexecutingtheabovesequence:
Answer:
6) Considerthefollowingassemblyprogram:
Answer:
WhatisthevalueinregisterR1attheendofexecution?
Answer:
Big: 0xFFFF8765
Little: 0x00004321
7) GiventhefollowingARMassemblyprogram:
AREA DATA
0x20000000 00000000 res DCD 0
AREA CODE
0x000005D0 B500 f PUSH {LR}
0x000005D2 2801 CMP R0,#0x01
0x000005D4 D007 BEQ done
0x000005D6 B401 PUSH {R0}
0x000005D8 F1A00001 SUB R0, R0, #1
0x000005DC F7FFFFF8 BL f
0x000005E0 BC02 POP {R1}
0x000005E2 FB00F001 MUL R0, R0, R1
0x000005E6 F85DEB04 done POP {LR}
0x000005EA 4770 BX LR
0x000005EC F04F0002 Start MOV R0,#2
0x000005F0 F7FFFFEE BL f
0x000005F4 4900 LDR R1,=res
0x000005F6 6008 STR R0,[R1]
CopyrightHilgadMontelo.Allrightsreserved.
ME445M:EmbeddedandRealTimeSystems
StudyguideSet#01
AssumethestackpointerSPisinitializedto0x2001.0000.Showthecontentsofthestackandindicatethe
locationofthestackpointerrightafterthepointwhenthestatementataddressfhasjustbeenexecutedfor
thesecondtime.
Answer:
8) Writetheassemblycodetocreatea16bitsignedvariablecalledNum.Includethedetailsthatwillplacethe
variableinRAM.
Answer:
AREA data
Num SPACE 2
9) Considerthefollowing8bitaddition(assumeregistersare8bitswide,andassumetheconditioncodebits
aresetinawaysimilartotheCortexM4).Whataretheconditioncodebits?
Load 0x88 into R1
Load 0xC8 into R2
Adds R3 = R1+R2 ; setting the condition codes
Answer:
N Z V C
0 0 1 1
10) WriteasubroutineinCorassemblycalledSOS_DetectorthatfirstreadsPB7ninetimesveryquickly.Ifthe
nineconsecutiveinputsmatchthepattern"000111000",thenreturna1,otherwisereturna0.SOS_Detector
mustbeAAPCScompliant.
Answer:
SubroutineinC Subroutine inassembly
int32_t SOS_Detector(void) SOS_Detector
{ MOV R0,#0
uint32_t i,data=0; LDR R1,=GPIO_PORTB_DATA_R
for(i=0; i<9; i++){ MOV R2,#9
data = (data<<1)|( loop LDR R3,[R1] ; PORTB
GPIO_PORTB_DATA_R&0x80); AND R3,#0x80 ; PB7
} LSL R0,#1
if(data == (0x38<<7)){ ORR R0,R0,R3 ;combine bits
return 1; SUBS R2,#1
} BNE loop ;9 times
return 0; CMP R0,#(0x38<<7)
} BEQ yes
no MOV R0,#0
B done
yes MOV R0,#1
done BX LR
CopyrightHilgadMontelo.Allrightsreserved.