Memory Segments.docx

Embed Size (px)

Citation preview

  • 7/25/2019 Memory Segments.docx

    1/3

    Camille C. Malaza COEN 3114

    BSCpE 3-2 Engr. Rolito Laceda Mahaga!

    MEMORY MODEL

    Small

    "#e the #mall model $or a%erage #ize application#.

    &he code and data #egment# are di$$erent and don't o%erlap( #o !o ha%e )4* o$ code and )4* o$

    data and #tac+. Near pointer# are al,a!# #ed.

    Medium

    &he medim model i# e#t $or large program# that don't +eep mch data in memor!.

    ar pointer# are #ed $or code t not $or data. /# a re#lt( data pl# #tac+ are limited to )4*( t

    code can occp! p to 1MB.

    So( there !o ha%e it. 0n the medim model !o #e $ar pointer# to acce## code the code ha# $ar

    call and $ar retrn in#trction# and maniplate# ,ith $ar $nction pointer# and !o can ha%e

    mltiple #egment#. &he #tandard 1)-it OS .EE $ile $ormat #pport# mltiple #egment#. 0n the

    #mall model all pointer# are near and #o !o can't and don't change the de$alt code #egment in

    the program.

    MEMORY VARIABLE

    / variablei# a named o5ect that re#ide# in R/M memor! and i# capale o$ eing e6amined and

    modi$ied. / %ariale i# #ed to hold in$ormation critical to the operation o$ the emedded #!#tem.

    / constant i# a named o5ect that re#ide# in memor! #all! in ROM and i# onl! capale o$eing e6amined. /# ,e #a, in the la#t chapter a literali# the direct #peci$ication o$ a nmer

    character or #tring. &he di$$erence et,een a literal and a con#tant i# that con#tant# are gi%en

    name# #o that the! can e acce##ed more than once. or e6ample

    #hort M!7ariale8 9: %ariale allo,# read9,rite acce## :9con#t #hort M!Con#tant;de$ine $i$t!

  • 7/25/2019 Memory Segments.docx

    2/3

    MEMORY SEGMENTS

    / #egmented memor! model di%ide# the #!#tem memor! into grop# o$ independent #egment#

    re$erenced ! pointer# located in the #egment regi#ter#. Each #egment i# #ed to contain a#peci$ic t!pe o$ data. One #egment i# #ed to contain in#trction code#( another #egment #tore#

    the data element#( and a third #egment +eep# the program #tac+.

    0n the light o$ the ao%e di#c##ion( ,e can #peci$! %ario# memor! #egment# a#

    Data segment- it i# repre#ented ! .data#ection and the .bss. &he .data #ection i# #ed to

    declare the memor! region( ,here data element# are #tored $or the program. &hi# #ection cannote e6panded a$ter the data element# are declared( and it remain# #tatic throghot the program.

    &he .## #ection i# al#o a #tatic memor! #ection that contain# $$er# $or data to e declared later

    in the program. &hi# $$er memor! i# zero-$illed.

    Code segment- it i# repre#ented ! .tet#ection. &hi# de$ine# an area in memor! that

    #tore# the in#trction code#. &hi# i# al#o a $i6ed area.

    Sta!"- thi# #egment contain# data %ale# pa##ed to $nction# and procedre# ,ithin the

    program.

    INTERR#$TS

    0nterrpt# can e a #car! and #e$l ,a! to ma+e !or program reall! di$$iclt to deg.

    0nterrpt# are triggered ! hard,are e%ent#( either an 09O pin changing #tate or a timer timing otand #o $orth. 0$ enaled ,hich ! de$alt the! aren;t( an interrpt ca#e# the proce##or to #top

    ,hate%er it i# doing and 5mp to a #peci$ic rotine in the microcontroller called an interrpt

    handler.

    0nterrpt# are not $or the $aint o$ heart. &he! can e %er! tric+! to implement properl!( t at the

    #ame time the! can pro%ide %er! #e$l $nction#. or e6ample( an interrpt cold e #ed to

    $$er #erial inpt data ehind the #cene# ,hile the main 0CB/S0C ROD program i# o$$ doing

    #omething el#e. &hi# particlar #age ,old reire a microcontroller ,ith a hard,are #erialport.

    &here are man! ,a!# to a%oid #ing interrpt#. Fic+l! polling a pin or regi#ter it in#tead i#

    #all! $a#t enogh to get the 5o done. Or !o can chec+ the %ale o$ an interrpt $lag ,ithot

    actall! enaling interrpt#.

    Go,e%er( i$ !o 5#t gotta do it( here are #ome hint# on ho, to go aot it.

  • 7/25/2019 Memory Segments.docx

    3/3

    &he 0CB/S0C ROD Compiler ha# t,o di$$erent mechani#m# to handle interrpt#. &he $ir#t i#

    #impl! to ,rite the interrpt handler in a##emler and tac+ it onto the $ront o$ a B program.

    &he #econd method i# to #e the 0CB/S0C ROD #tatement ON INTERR#$T. Each method,ill e co%ered #eparatel!( a$ter ,e tal+ aot interrpt# in general.

    RE%ERENCES&

    http99mela#.com9re#orce#9ppmanal9HI=.htm

    http99,,,.ttorial#point.com9a##eml!Iprogramming9a##eml!Imemor!I#egment#.htm

    http99#tac+o%er$lo,.com9e#tion#911HJ1