0 ratings0% found this document useful (0 votes) 3 views10 pagesMicrocontroller Module 3 Notes
This is microcontroller module 3 handwritten notes including questions with answers according to vtu evaluation
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
Modlute-3
@ Peverop an AP © Pinel tle Surn of Fivsk
Jo iusteger mur 6CrS
+> AprEA Some, CoDE> PEAD ONLY
EntTey
START
Mov Fe, +I
Mov R,, 410
Mov R>,40
LooP
ADD Pz,” Ro
ADD @0,Ro,#!
CMP Ro,k:
BLE Loop
Srop 8 STEP
END
Digege ty commer Por tabilr
Facecl lies evhrting c paogsams. Hew 62>
These TEesues Be iti gat ec!
—= (Cwmon Pobtabitity TeGues
el chaxactosmDatoTYPe
* On may precessess, chas 19 Figned
- on AeM, char 78 often ungigned
yariable uiay behave
* Loope uBing 2 char Bint Pa
dikferewty % may
loops
mi eigat ion?
* Eepiici ty
* Peeler w+ Por
use Signed chas or wrf&igned cha:
Loop Cousste ’S
Sone adder gygiernS use I6 bit integers
Apm uSeg 32 bit integer
frithmetic aul © :
oli For omparigon AsQ@Gult maymitigation:
- uSe Pitad- width type? Such oS int8_t, int G-t,
fut 32+t , Wnt B2+t
* Some psocesSorg alow
* Akm abticuatuso up to ARMuSTE
alignmeut
ACGULe POPE?
mitigation:
* @nguse PSoper date alignment
* Avoid uu8ahe poiuter laSting
4. Encianpesg=T83ue8
» Sy8teu may be little -
© Phoqrau? thet CcaBk poiutess Mey
dik PeCAently
enchan o4 big - endian
Beuave
mitigation :
+ use enclian - inclepen cleut Code
+ missing oA iucossece Pauction prototypes
may couse ‘correct parareteter Passing
Mitigation:
* Tuctude appropriase heacles F/leS
* vse ANSIC Puuctlon PAactetypes
6. BikaaPololeyimapstemestoction,
+ Bit-Field Layout clepeudS
architectuse
on Compiler aud
Mitigation:
+ Aucid Bit -RieldI& sh portable APPS
ee ee
eualigned! Uenore anes gy
@eean
eee
@
@
@
«
@
=
7
4
e-
«
@
o
«
~
e
e
e
e
e
e
e
iy7. bnumevation Size yasreHOr’
+ DiPPebeut Compilere allocate AFP §i20e8 Fo
Cnum
Mitigation =
+ uge explicit ate ger types
+ Avoid enumS du externally viPibe Strsuduc,
Q. BRU” ABSCMb
+ ABSerbLy @de is processes Sependaud
mitigation:
s Minimiz@ tullew a S¥erbl y
4. “
© Harclvexe ACIP ECD 4egube volatile
cloclarations
Mitigation:
use volatile dint StotuS
Q@) Srplaw code optimization, Profiling & cycle
Counting.
> geslemmayptimizadion ~ Tt 1S ww process oF ‘ompaor
a phogtam 9 thay *t Cxecutee Fagsies, Con fumes
leg? meuory aud geuCrates eeRicieut machine
code. The Compiler tauglatee © cock) ieee :
obheubty danguage aud oppliee optimizotion
Cchniques te tus ph oue pesfosucuce
_' Tt if the pasoce sf of analyring 9
progsau. t icleut ify Psoquetty executed
Puuctiong wd pes fos mauce bottleuech &
cycle = @uuding. — Tt wrcaSusee LHe nL PES
of psoces%es clock cycles feqiuned te exeue
iu Ptau ct jong
Importance
© Determ ine Execution Speed
* Weel tn pKeal-time embeckled Sy8temsauite a € phogsam that phiwtG tts Square
Puuction sith Command.
J
3 Keture TiS
3
Gnverting
Square MoL 41,405 Ho
OP udegers btwn Ot0 9 uSiug Puuctions &
Convert tas Cfiurctre to ou a 88ers bly
# include <[Link]>
ut Square Cink i);
tut = "man (voiel)
ink fs
for (i205 '<105 ith
© paint? ('Squate oP pd i87d\r" i, Square Ci))5
47
jnt Square Girt #1)
it into afSermbly fuuction
peed [-text], CODE, READONLY
ExPorRrT Squate 5
int Gquase (int i)
Mov Xo; Hx! a re. and
Mov pec, ds . saluyn Ho
—€—€ @epreeeee eG e GM GBBGGA AAA AAA ABA AeM Maa QO© eegigter attocation 1 optimize he psogs
9: am
5g A Compiler optimization
=>
RegiPter allocation
processes segistors 45
technique the oBign’
Freq uesctiy uSedd variables
+ Regitere are mugh Fadler Lan memory.
+ Acce8Sing cata Psom 8egi8tCrS sequses a
fewer cyclee thar axeRing da Psormn PAM
_ ~RagiSiey Allocation Phocess
\ Compiler poleuti Pie? Prequeitty
i, Jmportaus variables oC placeel Lu CPO
£@9 181273
ii, Legg Psequer
on who Stack
WW. vasiableg Stored du meniory
Spied variables.
uted vyariabCS
tly USeel variable VE Store!
we called
Allocation 44 Compiler optimiza
DigusSs Regi8te*
Tustsate corith eyvauple
— REFER @. Ne 5 Por Regifter Atlocest?
Evoun ple pleated Meg tos
Int Suse Cint a, int b)
é : ADD 40, 40:41
Lut C5
ae Mov pc, Ly
Aeturn C3
4(*) Progsaus of a cate paces Gntaining 64 words
aud write dle Gmpiler output (ALP) fos Ie
oboe Fuuction.
> #incelude <&tdio.h>
tut matn Cy
é unsigned int clato [64)5
un Sigaed tut Sum 70,
un Signed wut checkSum;
fat 15
printP CGuter 64 words :\9"D5
By G70; '*643 itt)
Sean (*7-u" & dato fi])>
Por (470534645 it+)
Sum = Gum+t cox&li);
chechSum = ~ Sum;
printl ("checkSum = Lule’) check Sur) 5
poturn 05
ALP
movsit Rato 3 Sumzo
Mov Rito 5 iz0
he Roe 3], 4 5 doad next word
ADD Ro, Po, R2 5 Gumt = aor
ADD Ri, Pit! Site -
cmP R14 64 Stompare ual 6Y
al — 3 Aepear until 64
ced S
mv N pu, Ro See
EERE ER®
i
BERKEL EEOREE
ids Concept of pointer aliaSing uit,
Cxam ple.
>» Two Sat al fo olia® when they
Point de Ll Same ah ite
fo one potter »/# ull affect ws value
ou goad PAsorm db other pointer - Ina
Punetion, ty Compiler ’
;uers Car
Pxau ple:
Tue Following fuwctior
two - Lue values by 2 &tep cu out
void timers - Pat 4 hime
aut * §tep)
tinuer — "! .
pao tod 5
052,82) 3 Big 1% FOP
913.5 91195 ge
[v0.4] 3 x bauer t° 78
ipe Ho, (%s#eODS Ho? * HuvarD
LDR. #9, [sty 40) a= % Step
ADD 210,970,429 5 Het ro
STR A% (54,5409 3 x dimer 9°
Mev Pe, A438The Compiler doad& Fsom Step twice
OSuatey a Comptles optimizatior Called SF
Common SubexpsesSion Climation coouwle ce
Bick cin So that * Step was only «
@
aus the Vette
oJ OCCUué ence.
4 use Ws
valuiatede teould Orce,
sHeuSed fos Ly econ
However, Mu Compiler
hese. The Pein
Deere
optimization
aud Step might
CeeE
@) Deserite te process of a Function Call dnc
se Ca Standard! CAPcS)/
dune cau Stanolard CATPCS)
CA ge ae
values Are
cot
—> The Akm Proce cls
Alm - Thusnwb paoce
AlePhiues how Functioe
pasted and | how eet
obtained oluring Punctio?
aes
Proces& *
piset fo
arguments on5 passe
ogiSters: Asgueent 0
= fag uusent d
jutege> 7 pitter
+ The be dy tprodgh Ae”
r4
tl oe? Asigquusent &
t3
13. As g LED
+ Tha Bunction hav mose Ahan foe
a 4g. phe Hemainir asgumen
yquiuents , I fog. coneting Stak
ane puaced on Puy
- Th asoum eds VE Stored KP
ie Stack o jocations
aScending meus ory
7S peSsed
The Acturn value ok thw Function
bach through SMegi8ter 7° :
FeecerereeeeeeReeEEEengsJ lata types Such ag Long
arguments ae passed
gecittive megiElOrs
Fos dtwo- woh
attire and double,
par of con
UuGing @
«Bich due - word peotusen Valued a6 seglivre!
Absrough %? and 74
link Regi8te” cr)
; qr call, gi
onal ‘8 a Stare addres. Cpabling Grae!
dp neturr ap we calling a Action{ ah °°”
excastion
Spa6 [Arguments |
I |
Set | argument?)
| Retam val]
Passing
Dig: ATPc asgument
How ase Function calle bandled
ePFicientty in c?
, eFPicl in ARM
—> Function callS Are ciently
ATPE conventioe,
paoce 8for8 ugiong dhe ‘
2eE memory acce&8eS by Pasting
ve
°
ath ich
minina
ParounsterS thaough HagiS ters.
ex:
by tes- V7 C
Char * qJueue —
char * @- Start,
char * Q@- endl,
Chay * -pt7,
Chay+ data,
Unsigned int N)
SISOS SHHFFFFFECELEOCELESCCCCECCCCeEiii
ui.
The Pi8t our parameters (G- tart, G-end
Q-ptr, data) we passed Lh*0ugh e,r).72,
(w) i& passed
2
rT?
The Fifth parameter
thsougn tne Stack because oO” pwr
arguusent Aagi 8t27S ae we ifable
gould °”
the sunk Fegifter (ir) +8
tw erack before auderiog Dts Pasact”
byte than8Fer operation® use
OPP: cien E iu8tsuction g'
PAore
. pRB - Load byte
* STRB- Stove byte to amenory
Conditional exeacti'on (move) anoicls
unece&garey b4anch tu Kb ALI?
Jg impdeumeted uSing
loop contho!
+ 8UB3 - Decseusent counter
1 becomes
* BE - Repeat Loop ureti
ZOHe
Fue Rind queue poued
though O98 tov vo,
overhead.
ley LG HELUrned!
wt eolcing memory