0% found this document useful (0 votes)
2 views10 pages

MC 2

The document discusses code optimization in C compilers, focusing on how compilers translate C code into assembly language while considering processor architecture. It also covers profiling tools for measuring cycle counts and the allocation of registers for local variables to optimize performance. Additionally, it touches on debugging methods and the importance of understanding hardware abstraction in embedded systems.

Uploaded by

priyapoojary1611
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views10 pages

MC 2

The document discusses code optimization in C compilers, focusing on how compilers translate C code into assembly language while considering processor architecture. It also covers profiling tools for measuring cycle counts and the allocation of registers for local variables to optimize performance. Additionally, it touches on debugging methods and the importance of understanding hardware abstraction in embedded systems.

Uploaded by

priyapoojary1611
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Asigomnt-2

Module-3

Lplin code qpimizakon piclt ingf yde aunhng


A:C compilers oaimizo hon
Ophmizing code Eales tine Ç zeduces sOuYCe codt xeadabilky
Therefort its only cwo Lh cotimiiog tunctioos thal are
Luqueotly eeuted tmpoutank tor perfomonte
H( campilex bove to tronslote ouY C tunbon kteyolly
into assembler so Ehat it wovks iot all_posi ble ioputs
’o umte efftcieot C cod we nust be ouoYe of oYeOS wheXe
the (compiley bos to be_conervatvethe toits of the
processor onhitecture the C compilex is mappiog to the
Lets oa speke C Compiler.
Most CommonC CompileYS QIe
OrMCC frOm ANM Develapey Suite Verslan:ADS
y Orm -ef -gc vesion 2-95 l his is the AM toget dor
the nNUC Campilexgcc
Poftliag ood cycle counbng
2A protilex s a too thot measuYeS the paporbon o Kme
mpocessiog ycle spunt oeoch suboukne
Lox
SA cycde counter MAOXUYES Ehe oumber of cydes taleo by a
specitic Toubo
The ARM simulaBo ued bs the ADS L de bugg x is callkd

nokures
HThe ARMalotx paalilex uorks by samplínq the mogrom
counter pe at yequlon tatmuals
bALM inplenentokons do not naumally anloín cyck-coucbog
Lbaxducme SO o eally Mearunes cyde counts ue should
AM dehugger uith AnM_cmulatay Jae con centlgue
the AMulaka to slmulate a xange of difevent AM
lcoes 6 oblain cyule count henchmaske tor a oumber
ad platlom
ahite a C_pucqram that prints the square of integers blu.
0io 9 csiag funcBon explan hou Eo convert this C tenchon
aSsenbls uncBan uith camnand
A: C pragom
Hoclude <sidto.h
vdid pialsquares ()

picksquoes)

uoid pint souares

forint is0i410itt)
int sauaNe =ixi
piaid ( The squaie ol %d is od nisquoe

Asernbls Jonguage pmogiam


"tent
globl piol squanes
Lype piot -squane s Qtuoban
print squoesi
push zlisave base paintex (xhp) o l
mov YQ,1 Mave the ualue of 2 to xôbo

sbing iokov)

.L4i
jmp
may n,3Mave laop counta )do D
mul r,r3_coompute squot0-yl*rd
to r
moy 10x2move addess ol otrnol stioq to yD
add x3.l.Incnomeok.loop tounter

Cmp )lDcompaTe oop counte usith Ip


jlL414 JeLL thon lo. Joop agoin.
pop 11 ies Love bae poínter

Sleps nAsernbly longuoge


Funcbon ProJoque
n osembly ut ned to sel up

Alloote spote lo Joal ariohles

Tunc bon Gody


Dlood the input ongu ment Ciokger) homn the oppmcpríale
gístex Ceg20. on Anm)
Hulkply the ioput by ilcelf to calculate sauore sloxe
the Yesull in the opprapníote Yegit ter
Fune Bon fpiloque
heskore ongsound saved Yegís kexs
Ceon up the stock f1omelstf ud

lckto the sesull Csquot) to the aller lusually via


speíke egitka)
3. Discusg how Tegists oTe alloco ted
progiom toopionizie the
A:The conple otlempts lo allbcole a mocessor
Yegíttrr to eouh.
Use fhe cane Yegfnter for diffeent Joral uoiobles if the ot o
the uorables do not overdaplwlhen thexe
ban ooable egícBers, the comoi ler storesOYe_more Loraluiobles
the extess Vaiables
n the no(esso stoce These
Waiables a1e
Suapped cut uovables since they axe curttenrolledcut pilled or
Spílled Voiables ore clocw to ocecs comparec to fo menoay
alecated o egíttess1o impk ment ofoncbon efhcinlly vaYiables
ce Ded to
* oiooiz the no of
coilled vaiable.
that the mot mparLant ¬freguently
voYiabler ate stad in reqittre aceicd
bloble 3.3 chows the stancbrd Yegister Aamas E
he tollouiog the AM- Thumh poiedae call usage auhen
ubch tuied în code genesatd by C Compilers standaeCATPCS)
Ioble 3:3 Ccornikx eqitlex uage
RegickerAlkanate.
Dumber 2gitter A1PCS

AnQumenk segiskers Thee bald the Bgt toun tuna koo


a axquMents on a funcBon call ¬th. yetun ualwe on a
funtBon ye kurnA funt bon mo OLpt thae nqiu tecs &
uIe them a genorol scrath xegítket uithin the tunt bons
Gbeoeral uonioble iegíler Th funcbon mutprzenve lhecalk
valuss of thee xegítters
Y6

v6 sh Genetal vaiahle egirter The tuntbo0. muat plere tho cal


values &f hi aegit tex ouept ouhen canpliogfa Tod-anike
pabon independeoce(nlaPI) Then 19 holds be slob bate
oddress Thít i tbe addrecs of the ead -write data
lcGenaal oyiahle ngittex. The dunction must pyeseve the ollee
valueof thi regisLrY xtept wbern campilioquithstokkinit
checliog- hen ylD holds the ctack limitaddress
vlpGeneral voíoble Tegístey The foncboo mukpreexve the callee
valus of thi regitter eLiept uhen.orpiling cuång ofraroe
poiot Oaly old vexcions of armCC uçe a kome pointty
Ageneral saatch yeqicter for fncbon con corupt IE is
uefalao scralch yegístey fo funcBon Veneexs oY alhey
ottapoduxe call yequiemeols
I3
be slack poialex . poialing lo the fall deiendiog ordex
he iok Yegictey
.Oo atunBoo co) thir hold the
aetuxo addye<c
LThe pxaq1am (ountex
Ih theory the C compilex can asíqn l4 voriables to
xegíttexs uithoul spilloqe In machce some compilers ure a
6xed vegislexs such at Y) to tor iotermediate saatcb
lcking do not acigo voxiables lo (hic xegltter Alko
comple e1pxestian Yequixe ntermecate uoling Yeqicloyst o
eualuate Thexefoxewe thoulo Ly lo limit the iotexna loop
lof fonib00s to uing al mat )local variabler
the_cDmpiler does OPed to suop oul variobles theo
lat chaates wbich voyiabler to suop Cut bared on
lof fequentq
Suoemary
eltient hegictey Alloa5o0
fun kon to n The (ompler shauld be able to
allocate there to AM Yegíc tex
goide the compilex. a to cuhith vaIOblec are
opaxlont by ensuing these uoiobles OYe CLIed ustbio
the iogcrmot loop
aulemakially
changethe made couses
Q ERLephco
tbat mcdes tua coly the
modes agocialed Exepbons Pgune
modes
Aborl)SUC Undelned)(146)
(F10)( Entepbons
Uhdefnec
AbortPdeteh
JRO
F10
hbort ato
Reset
macdesLQuociated
euepbon an
shaat tque Relaus state Aarm ko
aoLestaY AnM fhe otrurs extephoo
Lchanging
rp
the When
manually
by entered heCon mader pooestor ALM The
mode períhc eoter
o sore the otuTexLepbco HAbenewex
an
Moduk-4
set the cp to the ALuBon mode
"sels pe ka the address of the estepkon handle
Eploia thmucne etubomn Alou & ploio sd hat ed Boct
A EinmuoE 2IPLuon flow'
DowoTe: 1t ie on iotezBate blu tbe hardao the
Loppltaoro lopera tiog. syckern eve) saftwoNE
1E sides in the RoME PIeLutes wbenpowr
opplied o the ernbrdded bonduo systerr
T1 Tenda orbveofter soiboliuo bon to ruppast baie
system opeation
The choice ct uhih fsmuoe to ne tot o porbulox
ALM- based syten depend upan the specibc opplfo Boo
Cae od the maio puspote of hurnauoe s to paouide
clable oethonison la ood EEboct an cperabog Ssysten
Abstxockos of Esmasate Exeuu Ban flow
he have 0 commco erubBon {lou to belp onderg tond the
Lea tunes of difteet fmuoXE îonpleoentoboolable 4-7 its
the batic FumuaTe PeLuboo low
stoge FeotuTes
St up torget plotform Progtom thr horduoYt systern gisters
PlotBom idenbßabon
Ofogpostics
Debug inter foce
Cornnord Soe intpre trr
Ab; boct the honduore Hovdwoe Absbocbion doger
Deite diver
Lood o boolcble inoge Bassc Rrog sys lern
Relirqísh control Altrr the pe to point ioto thr pew imoge
Toble Kmuore euban flou

The Byst stoge is lo set up tazget plttorm Tt oludes


dollotog tkagei
Plotlotn 1denkhua Kani
an dileest
lte conomon fo the some exetukoble to_opeYate
Lores &plotfons
Ia that ase krowoTE ho to idenBty_E diucoVex
ate the
tare platBorn it in opevabng
is notmally eognlaed hy veodircq XegisteOin
opocesior S.uhich bolds bolh the _paoLRSOY Lepe & the
manutactuxex DoMe

pagposthes
Dlagposbcs solluot mo vidhs a ueul woy for quck ly
identityiog batic bovduot maltun boos
Debug capabilikyu provice d in the toM of a module or
mooitox that provides sodluoe ouáttone to dehugging
cade running on a haxduote tonget
Debug Talezfate
Debug capobílity iu prouided in the tom of a module
or monilor Lhat provicdes sotkuoe ascukonte tor de buggiog
ccde xunoioq on a hoduore Lorqet
Interocve Melhod (CLI):
Iale coo send tbe omnands through o coomand
iotespaker (CL1) (io ns -132)
Adedicabhd harl k debugger (Cvio LAN 4Cc/s)
"Tbe CLÍ i commooly ovailable on the tmot advantecd
fixouoYL 1onple cnen.toboot
ollous uto change the cpero bog syskecn to be
booled bu_allbsing the delaulLconfiqusaboos lho ugh
Lypiog camnonds ata command (mompt
The setood staqe i Abstac the Hocluone:
Hordaore Ahchat boo Loyex CHAL) i, osolluwore daypy bat
bide the undealyíng hoscluone by providing a set of
de Had pnocq1araníaqiotafaea
AAL col lauo that communkats cuith epecikc
basdauote po[phexal i alla deice diuey
Drice díser (mcshdr a stotdoad plutun (asaTAtcA

rok all peratogsylern nogec.qpluatern imcytssd


to beccked iclo QAn

fimpltyecule ditcily hem BOM


In smal.devius shich ialude lo:t. foMispe toh.
Liorm kling syutem CF£),uhih cllut mlbgie nHuthle ircges
o.beslond

urll os the tbenet harduoTE to soad the icye_ s the

Tb ianth staqe ilo ehinqush corkJ:


Delinguihic cclrd onon AnM syikero mo upcoke4
the veto batle Ç mdityins Lhe pL
L Updobo the yls tohleioualunz medilyirg certuoz

-speialind cperobng sytten tarcks


Arokog syulen akuy pict oddnsL
for iDu1 0STe
Bnguithin cctaol Hquin Lhet a ilodnd
npláio the enitoASDEDL thut tbe kezpel uil) te usiCa io
Lia etonple n teld ny inalude the srncunt ot ouailatla
HMu hing ud
Aller eicaucbing absl.the tmaahuoe Irdpenchat louili)
ranain onbu This Jogr Lpcus thscugh a sWLrrecharim
oslondnd appliaboniakatau ta spate haaducu deuiaL
Red Hot RedBaot
Rad Boot iua Aumuont konl delapacd by hed Hak
IE ís on. apen souzLE liceDse cuíth na Yoyalhes or up
ont teet
ledBoot u desigoed ta ezecute an dilteuent CPUs 4)
IL pravides both dehug capability through aNu
Debuqex GDA) a cuell.as boalJacd ex
The DecdBoat oftuone Cove l bauecd on HAL
RedGoat supports theyz maio feakuts
JCocntnunuaboni coofqusaboo u ouer sezial ox Eibesnek Ea.
exiaX-Madexo.ncAo rad ik Uled lo coomouokote cuith tbe
GNU Debuggas6 )(aR6)-for EtberntIcei und
of oelaak skondaxcuch a boakp.teark.,6 ttp
JFlash toM.memory macagetot n paauidu osetof. ALing
ysten xobnes thak co0 douolocad «updale6.exaue
ioges io flash OM-Ia oddiboolhe imoges ca0.eithe
be compmeSLed aL uncamptesLed
)full cpa
orxa bng syslem
sur Lbm suppeat -suppaks tbe londiog
boabnq of Embedded Linuz.hed Ha alas..&.many oLhr
populor cperabng sylerms- For Lmbedded Licux.Rec Boet.
Suppotks the ahiliky la detoe poamebers thakaxt paued
diuckly Lo the keroel.cpan bocbing

You might also like