Sie sind auf Seite 1von 112

MCU 8051 IDE handbook draft

Martin Omera <martin.osmera@gmail.com>

February 26, 2012

2
s would like to thnk to the following people for their support during the projet developmentX

Andre Cunha (Brazil) for review of this doument Kara Blackowiak (USA) for ertin ode reviews Kostya V. Ivanov (Russia) for ug (xes in the simultor engineF Shakthi Kannan (India) for dding this softwre to the piv projet
nd for few pthesF

Miroslav Hradlek (EU) for ug reports nd suggestions Fabricio Alcalde (Argentina) for suggestions nd ug reportsF Francisco Albani (Argentina) for suggestions nd few ug reportsF

Contents
Preface
qols of the projet F F F F F F F F F F F F F F F F F F F F F F F F F F F equirements F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F sntended eudiene F F F F F F F F F F F F F F F F F F F F F F F F F F F IFI IFP IFQ PFI PFP QFI

S T U

1 Brief introduction

win omponents of wg VHSI shi F F F F F F F F F F F F F F W ht is wgESI F F F F F F F F F F F F F F F F F F F F F F F F F IP ht is the essemly lnguge F F F F F F F F F F F F F F F F F IP hemonstrtion projet F F F F F F F F F F F F F F F F F F F F F F IS our (rst projet in wg VHSI shi F F F F F F F F F F F F F F IT F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F

2 Quick start

15

3 Detailed introduction to GUI

QFP

QFQ

oure ode editor F F F F F F F F F F F F QFIFI yntx highlight nd vlidtion F QFIFP pell heking F F F F F F F F F F F QFIFQ eutoEompletion F F F F F F F F F QFIFR iditor ommnd line F F F F F F F fottom pnel F F F F F F F F F F F F F F F QFPFI win pnel of the wg simultor QFPFP g vriles F F F F F F F F F F F F QFPFQ qrph showing voltge levels F F F QFPFR wessges pnel F F F F F F F F F F QFPFS xotes F F F F F F F F F F F F F F F QFPFT glultor F F F F F F F F F F F F F QFPFU pind in (les F F F F F F F F F F F F QFPFV erminl emultor F F F F F F F F veft pnel F F F F F F F F F F F F F F F F F QFQFI vist of opened (les F F F F F F F F

17

IU IU IU IV IV PH PH PH PI PI PP PP PQ PQ PR PR

4
QFQFP vist of projet (les F F F F F F F F F F F F F QFQFQ p wthes F F F F F F F F F F F F F F F F QFQFR pile system rowser F F F F F F F F F F F F F ight pnel F F F F F F F F F F F F F F F F F F F F F QFRFI vist of ookmrks F F F F F F F F F F F F F F QFRFP vist of rekpoints F F F F F F F F F F F F F QFRFQ snstrution detils F F F F F F F F F F F F F QFRFR ht register wthes F F F F F F F F F F F F QFRFS uprogrms ll monitor F F F F F F F F F QFRFT vist of symols F F F F F F F F F F F F F F F QFRFU r plugEins mnger F F F F F F F F F F F yther tools F F F F F F F F F F F F F F F F F F F F F QFSFI p mp F F F F F F F F F F F F F F F F F F QFSFP wp of it ddressle re F F F F F F F F QFSFQ tk monitor F F F F F F F F F F F F F F F F QFSFR ymol viewer F F F F F F F F F F F F F F F F QFSFS egss hrt F F F F F F F F F F F F F F F F F QFSFT VHSI snstrution le F F F F F F F F F F F QFSFU VEsegment editor F F F F F F F F F F F F F F QFSFV topwth F F F F F F F F F F F F F F F F F F QFSFW rile notepd F F F F F F F F F F F F F F QFSFIH fse onverter F F F F F F F F F F F F F F F QFSFII EPQP deugger F F F F F F F F F F F F F F QFSFIP rexdeiml editors F F F F F F F F F F F F QFSFIQ rierntion of simulted progrm F F F F F QFSFIR snterrupt monitor F F F F F F F F F F F F F F QFSFIS gonversions etween BFhexD BFin nd BFdf QFSFIT xormliztion of soure ode indenttion F QFSFIU ghnge letter se F F F F F F F F F F F F F QFSFIV ser de(ned ommnds F F F F F F F F F F QFSFIW glenEup projet folder F F F F F F F F F F F QFSFPH pile sttisti F F F F F F F F F F F F F F F F F gon(gurtion dilogues F F F F F F F F F F F F F F F ttements F F F F F F F F F F F ymols F F F F F F F F F F F F gonstnts F F F F F F F F F F F ixpressions F F F F F F F F F F he instrution set proessing essemler diretives F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F

CONTENTS
F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F (les F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F PR PR PR PR PR PS PS PS PT PT PT PU PU PU PU PV PW PW PW PW PW QH QH QI QP QP QQ QQ QQ QR QS QS QS

QFR

QFS

QFT RFI RFP RFQ RFR RFS RFT

4 Build-in macro-assembler

39
QW QW RH RI RP RQ

CONTENTS
RFU RFV RFW RFIH RFII RFIP RFIQ RFIR RFIS essemler gontrols F F F F F F F F F F rede(ned ymols F F F F F F F F F F egment type F F F F F F F F F F F F F gonditionl essemly F F F F F F F F F wro roessing F F F F F F F F F F F eserved keywords F F F F F F F F F F gomptiility with eiwESI F F F F vist pile pormt F F F F F F F F F F F F pei(tion of sntel R V ri pormt F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F

5
RU RW SI SQ SR SV SW TH TP

5 Disassembler 6 MCU simulator


TFI TFP TFQ TFR TFS hort introdution F F F F F F F F F F F F F F wodes of simultion F F F F F F F F F F F F F ring onditions F F F F F F F F F F F F F F F vimittions F F F F F F F F F F F F F F F F F F irtul hrdwre F F F F F F F F F F F F F F F TFSFI hITPH temperture sensor F F F F F TFSFP pile interfe F F F F F F F F F F F F F TFSFQ vih nel F F F F F F F F F F F F F F TFSFR ingle vih hisply F F F F F F F F F F TFSFS wultiplexed vih hisply F F F F F F TFSFT vih wtrix F F F F F F F F F F F F F F TFSFU wtrix ueypd F F F F F F F F F F F F TFSFV imple ueypd F F F F F F F F F F F F TFSFW vgh disply ontrolled y rhRRUVH poreword F F F F F F F F F F F F row to write your own plugEin sing wg VHSI shi es F F e si exmple F F F F F F F F ndom remrks F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F

63 65
TS TS TT TT TU TU TU TV TV TV TW TW UH UH UI UP UQ UR US

7 Writing hardware tool control plug-ins


UFI UFP UFQ UFR UFS

71

8 Command Line Interface 9 Translating the IDE into dierent languages A License

77 79 81

6 B Regression testing

CONTENTS
fFI poreword F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F VQ fFP wore out the implementtion F F F F F F F F F F F F F F F F F VQ

83

C Project web page and other media

gFI y0il projet we pge F F F F F F F F F F F F F F F F F F F F F VS gFP yther medi F F F F F F F F F F F F F F F F F F F F F F F F F F F F VT gFQ qs repository F F F F F F F F F F F F F F F F F F F F F F F F F F VT

85

D 8051 Instructions in numerical Order E 8051 Instructions in alphabetical order F List of supported micro-controllers G Change log

87 93 99

pFHFI sntel R F F F F F F F F F F F F F F F F F F F F F F F F F F F WW pFHFP etmel R F F F F F F F F F F F F F F F F F F F F F F F F F F WW

101

Preface
Goals of the project
wg VHSI shi is n integrted development environment for miroonE trollers sed on wgESI intended for essemly lnguge nd g lngugeF R his shi is urrently ville on qxGvinux nd wirosoft R indows @sine version IFQFTAF his progrm ws originlly intended for edution purposesD ut now the re of potentil usge is surely signi(ntly widerF his progrm ws reted to (ll gp in the open soure softwre of this kindF ser interfeD soure odesD doumenttionD we pgesD etFD re writE ten in inglish in order to mke this softwre ville to s mny user s possileD ut there is support for interntionliztion using iIVn sine verE A sion IFQFIHF his doumenttion is written in v iF st is very importnt to note tht this softwre ws not developed for ny ompnyD person or something similr nd it is ompletely nonommerilD open soure softwre distriuted under qx qvvP liense intended for group of people with ommon interestD in this se VHSIF

MCU 8051 IDE should oer:


x e trnsprent view on simulted progrm for VHSIY y isy soure ode editing even for n user with smll knowledge of the ssemly lngugeY z ser friendly dvned shi for wgESIF

List of the most important parts of MCU 8051 IDE:



oure ode editorY yptimiztion ple mroEssemlerY edvned wg simultorY rexdeiml editorY

CONTENTS
snterfe for hrdwre tool ontrol plugEinsY ienti( lultor nd speil lultor optimized for VHSIF

Requirements
rrdwre requirements re not de(nedF his progrm should run without prolems on ll ys systems @like qxGvinuxD etFAD where ll of the softwre dependenies were stis(edF he shi is o0illy distriuted s soure ode pkge @primry progrmming lnguge is gvAD w pkge @urrently ville in o0il riv repositoriesAD hif pkge @urrently ville in o0il hein repositoriesA nd euild for qentoo vinux @urE rently xy ville in the portge treeAF
Package Min. version Required packages:
tcl tk bwidget itcl tdom tkimg tcllib Tclx cmake rxvt-unicode asem-51 sdcc doxygen indent hunspell bash gawk 8.5 8.5 1.8 3.4 0.8 1.3 1.6 8.4 2.6 8.3 1.3 2.9 1.3 1.2 1.2 4.0 3.1

Download location
(The IDE will not run without these packages)

Optional packages:

http://www.tcl.tk/software/tcltk/downloadnow85.html http://www.tcl.tk/software/tcltk/downloadnow85.html http://sourceforge.net/projects/tcllib http://sourceforge.net/projects/incrtcl http://www.tdom.org http://sourceforge.net/projects/tkimg http://sourceforge.net/projects/tcllib


(Functionality might be unnecessarily limited without these packages)

http://tclx.sourceforge.net http://www.cmake.org/HTML/Download.html ./configure && make && make install) http://software.schmorp.de http://plit.de/asem-51/download.htm http://sdcc.sourceforge.net/ www.doxygen.org/

(Signal handling (signals like SIGINT) (If you prefer this way of installation: (If you want terminal emulator)

(If you want to use a really good assembler :) ) (If you want to used C language compiler)

(If you want to use doxygen directly from the IDE)

http://www.gnu.org/software/indent/ http://hunspell.sourceforge.net

(If you want to use auto-indent function for C language) (If you want to have spell checker function available) (If you want to have spell checker function available) (If you want to have spell checker function available)
Table 1: Software requirements

http://tiswww.case.edu/php/chet/bash/bashtop.html http://www.gnu.org/software/gawk/

CONTENTS

Intended Audience
his mnul is intended for ny individulD regrdless of his or her experiene with ssemlerD g lngugeD wg VHSI shi or vinuxD ut it is ssumed here tht the reder is fmilir with si onepts of ssemly lnguge progrmE ming nd with VHSI proessor rhitetureF edvned users re not likely to red this mnulD ut ll suggestions on doumenttion will e onsideredF sf you would like to ontriute to this projet or the doumenttionD plese onsult the projet we pgeF hnks for your oopertion whih helps to mke this softwre etterF

10

CONTENTS

11

Chapter 1 Brief introduction


his hpter will provide you with rief introdution out the min omE ponents tht re prt of wg VHSI shiF he purpose of this hpter is to ontextulize you on the sofwreD informing out the prts tht omposes itF he next hpter will over rpidly the qrphil ser snterfeD whih will e desried in further detils on hpterF

1.1 Main components of MCU 8051 IDE


he ode editor is fetured with syntx highlighting nd vlidtionD utoEompletion nd spell heking for omments 1 D s well s ommnd line tht speeds up the ess to vrious editor optionsF st lso provides pnel showing line numersD ookmrksD rekpoints nd wrnings from syntx vlidtorF iditor is ple to export the soure ode within it s A rwv nd v i nd ontins numer of useful tools like utomti indenttionD serhing nd replement of expressionsD opy to lipordD pste from lipordD mong othersF

Editor

Assembler he ssemler is one of the integrl prts of wg VHSI shiF st is mro ssemler with support for dozens of diretives nd ple of perE forming peephole optimiztionsF upport for peephole optimiztions mens tht the ssemler n ttempt to optimize the resulting ode for higher exeE ution speed nd lower size without tempering with its very funtionlityF st is importnt to note tht utomti peephole optimiztion n sometimes e hrmful nd so it is disled y defultF e mro ssemler is softwre tht llows the user to de(ne macro instructionD whih onsists of sequene
1 Spell checking for comments is available only if you have installed the Hunspell program. This feature is currently not available on MS R Windows R OS.

12

CHAPTER 1. BRIEF INTRODUCTION

of si instrutionsD nd use it lter insted of repetedly opying nd pstE ing the set of instrutions over nd over long the soure odeF essemler ehvior n e on(gured either glollyD using the proper on(gurtion diE logD or lolly in soure odeD y mens of ssemler diretives nd ontrol sequenes @eFgF $TITLE('Some title to show in the code listing')AF he ssemler is ple of generting four kinds of output odeX

yjet ode @mhine odeA s n hexdeiml (leD with .hex extension nd in sntel R V ri formtY yjet ode @mhine odeA s inry (leD with .bin extension nd in formt of rw inry dtY gode listingD in .lst extensionY gode for integrted wg simultorD in .adf extensionF
he simultor is softwre omponent intended for the simuE ltion of the hosen miroontroller in virtul environmentF st llows user to monitor preisely wht is hppening in the wg in n ext moment in timeD s well s to modify its omponentsD for instne y ltering the vlue of registerD neling n interrupt or foring suprogrm to returnF sn tht wy it might e possile to ferret out ertin )ws in the progrm eE ing deuggedD whih would e hrd or nerly impossile to (nd ndGor (x in other wysF iven though it is etter to hve sgh @snEgiruit heuggerA or sgi @snEgiruit imultorA t hndD wg VHSI shi in urrent version does not support neither of them wg simultor implemented in this shi supports dozens of miroontrollers nd most of them re treted in slightly di'erent wy llowing to tke into ount most of the nunes etween the supported wgsF ser n djust simultor ehvior to (t his or her needs y modifying lok frequenyD size of onneted externl odeD dt memory nd othersD or for instne y disling or enling ertin wrningsD whih pops up when the simulted progrm do something strngeD like some kind of invlid ess into memory or stk over)ow or under)owF fesides thtD it is possile for the user to modify ll registers whih the wg dels withD inluding those whih re not essile y the running progrmD like the rogrm gounterF ser hve lwys n overview of ll possileD pending nd tive interrupts nd n temper with them t ny timeF he simultor lso llows for ltering ode memory nd ll kinds of dt memoriesF he proE grm eing simulted n e t ny time 4hiernted4 into (leD preferly with .m5ihib extensionD nd resumed lter from this sme (leF uh (le ontins the entire stte of the simultor t the point in whih the progrm ws hierntedF

Simulator

1.1. MAIN COMPONENTS OF MCU 8051 IDE

13

Project management st is funtionlity tht llows the shi to rememE er ertin set of soure ode (les long with set of on(gurtion prmE etersF rojets re stored in wv @etensile wrkup vngugeA (les with extension .mcu8051ideF hese (les re humn redle nd their preise formtting is desried in their inline hh @houment ype helrtionAF heir enoding is pEV @niode rnsformtionA nd s iyv @ind yf vineA hrter they use vp @vine peedAF he reson for tht is to mke it possile for the user to implement his or her own tools for mnipulting with themF Scientic calculator
wg VHSI shi sienti( lultor is implemented s simple sienti( lultor ple of omputtion in four numer sysE temsX hexdeimlD deimlD otl nd inryD nd with three ngle unitsX rdinsD degrees nd grdF sntegrl prt of the lultor is lso simple tool intended solely for omputing preset vlues for wg timersF

Special calculator

he experiene in wg progrmming shows tht it is very useful to hve some tools t hndD ple of performing reurrent oring lultions tht spend time to e done y hndF wg VHSI shi speil lultor is intended for performing ertin simple speilized luE ltions relted to VHSIF por instneD this lultor is ple of generting ssemly lnguge ode implementing wit loop with spei(ed prmetersF his utility is used here for wthing nd modifying lrge loks of rw dt in vrious memory types of the simulted wg @godeD sheeD heeD iiywD etFAF here is lso hexdeiml editor intended for editing sntel R ri V (lesF yther hexdeiml editors re speilly designed to (t spei( needs of the given purposeY for exmpleD there is n hexdeiml editor for viewing nd editing ode memoryD whih displys the urrent position of the progrm ounter in the mhine ode of the simulted progrmF his tool n trnslte one ssemled ode k to soure odeF st is importnt to note tht it is somewht improle tht the resultE ing soure ode will look 4resonle4 st is due to DB nd DW nd not (xed instrution word length on VHSIF xeverthelessD suh generted soure ode must posses extly the sme funtionlity when it gets ssemled ginF hisssemler implemented in this shi is frnkly speking only little more tht just toyF sf you wnt relly ple disssemlerD mye you should try some tool like hSP http://www.8052.com/users/disasm/F

Hexadecimal editor

Disassembler

14

CHAPTER 1. BRIEF INTRODUCTION

Notepad sn this shiD it is simple rih text editor for writing user notes of whtever kindF yriginllyD it ws intended for writing list of things whih remin to e done in your projetF Command Line Interface (CLI)
st is n useful tool tht llows the use of some shi funtions without entering it9s qsF ou n get list of ville options y typing mcu8051ide -h or mcu8051ide help to your terminl emultorF ou nD for exmpleD use just the ssemler of the shi or onvert n sntel R ri V (le to rw inry (leF

1.2 What is MCS-51


he sntel wgESI is rrvrd rhitetureD single hip miroEontroller @gA series whih ws develE oped y sntel in IWVH for use in emedded systemsF sntel9s originl versions were populr in the IWVHs nd erly IWWHsD ut hs todyupdte lrgely een superseded y vst rnge of fster ndGor funE tionlly enhned VHSIEomptile devies mnuE ftured y more thn PH independent mnufE turers inluding etmelD sn(neon ehnologies @forE merly iemens eqAD wxim sntegrted roduts @vi its hlls emiondutor susidiryAD x Figure 1.1: i8051 micro@formerly hilips emiondutorAD xuvoton @forE architecture merly inondAD wiroeletronisD ilion vE ortories @formerly gygnlAD exs snstruments nd gypress emiondutorF Ghis ws tken from ikipedi in PHIHG

1.3 What is the Assembly language


en ssemly lnguge is lowElevel progrmming lnguge for omputersD miroproessorsD miroontrollers nd other integrted iruitsF st impleE ments symoli representtion of the inry mhine odes nd other onE stnts needed to progrm given g rhitetureF roessors sed on wgESI hve omptile instrution setD similr registers nd mny other things re generlly very similr mong themF rere is n exmple of how piee of VHSI ssemly ode looks likeX

1.3. WHAT IS THE ASSEMBLY LANGUAGE

15

Code 1 en exmple piee of ode written in VHSI ssemly lnguge


main: if test=2 mov R0, #25h ; Configure EEPROM orl EECON, #38h inc R0 endif X0MI: anl EECON, #(0FFh - 020h) movx @R0, A

16

CHAPTER 1. BRIEF INTRODUCTION

17

Chapter 2 Quick start


2.1 Demonstration project
he im of the demonstrtion projet is to provide n esy wy to explore the shi without reding long nd oring douments like this oneF XA he demonstrtion projet n e opened from the welome dilog @  Main Menu  Help  Welcome dialog  Open demonstration projectF A hemonstrtion projet should introdue new user into usge of the most ommon funtions of the shi like ssemling the odeD running simultor nd so onF hemonstrtion projet nnot e modi(ed y the user in order to mke it less voltileF

Figure 2.1: MCU 8051 IDE with the demonstration project opened within it

18

CHAPTER 2. QUICK START

2.2 Your rst project in MCU 8051 IDE


et (rst let me explin wht the wg VHSI shi9s projet relly isF st is set of some (les in some diretoryD let9s ll this diretory the projet diretoryF end this long with the (le with extension .mcu8051ide forms the projetF he (le with .mcu8051ide extenE sion de(nes wht soure ode (les elongs to the projet nd ontins dditionl inforE mtion out the projetD like who is the projet uthor or for wht ext wg is the projet intendedF o rete you projet in you hve to speify the projet diretory nd the wg type for whih you will develop your odeF Figure 2.2: Project creation dialog his is done in projet retion dilogF his dilog n e essed from min menu  Main Menu  Project  NewF efter this step you n speify some dditionl informtion out the projet in projet editing dilogF yne you hve reted new projet you n egin to develop you ode from your hosen proessorF hen you wnt to sve your ode press gtrlCD gtrlCx retes new (le nd n existing (le n e opened y gtrlCyF ih opened (le n e dded or removed toGfrom your urrent projetF gtrlCf retes or deletes ookmrk nd gtrlChiftCf retes or deletes rekpointF rojet (lesD the (les whih re prts of the projetD re opened eh time you open the projetF ou n hve more thn one projet opened t the timeF imultor n e strted nd shut down y pressing pP key nd ssemler or ompiler is run when pII is pressedF yutput from ssemler or ompiler is displyed on the ottom pnel in t wessgesF end min wg simultor pnel is lso ville on the ottom pnel in t imultorF yn the left side you n (nd list of urrently opened soure ode (les nd list of projet (lesF end on the right side proly most useful tool t the eginning might e snstrution detilsD this tool displys help for instrution in the ode editor on line with ursorF sn the right pnel you n (nd for exmple lso list of ookmrks nd rekpointsF

19

Chapter 3 Detailed introduction to GUI


3.1 Source code editor
3.1.1 Syntax highlight and validation
he editor is equipped with n implementtion of synE tx highlighting lgorithm sed on simpli(ed syntx nlysisF end tht enles limited onEline syntx vlE idtionF ht mens tht s the user writes down the SynodeD editor tries to hek it for synttil orretnessF Figure 3.1: tax validation conguyntx vlidtor mrks strnge looking lines with exE ration button lmtion mrk nd tries to underline ext point of potentil syntx errorsF his feture n e disled s well s syntx highlighting n e disledF fy disling these fetures you n mke the editor work fsterD ut it would proly men only unneessry limittionF here re three levels of syntx vlidtionX

HX hisled IX pst si vlidtion PX low dvned vlidtion


yntx vlidtion on(gurtion utton ret to left nd right lik with the mouse pointerF ight utton lik dereses the level of vlidtion nd the left utton lik inreses itF

3.1.2 Spell checking

20

CHAPTER 3. DETAILED INTRODUCTION TO GUI

here is lso on(gurle spell heking funtion vilE leF st underlines words whih re mrked y runE spell1 s inorretly spelledF his funtion pplies to omments in the ode or the entire ode in se tht Figure 3.2: Spell the syntx highlight funtion hs een disledF ser checker conguration n hoose from ny of runspell or wyspell ditionrE button ies instlled on his or her systemF his feture n lso e turned o'F st mkes sense tht this funtion is ompletely dependent on the runspell progrmD if it is not instlledD spell heking won9t work hereF

3.1.3 Auto-completion
opEup sed utoEompletion is funE tion whih should mke it esier to use long nmes for lelsD mrosD vriE lesD funtionsD onstntsD etF his funtion is interonneted with syntx editor9s nlyzer used for syntx highE light nd vlidtion nd for the tle of symols in the right pnelF o it minE tins n overview of ll symols de(ned Figure 3.3: Syntax highlight, syntax in your soure ode (le nd then when validation and the pop-up based autocompletion all in action you write just few hrters whih symol strts withD this funtion will popEup window o'ering you ll de(ned symols eginning with tht lettersF xote tht this feture n e disled in editor on(gurtion dilog nd note lso tht esides symols it o'ers lso list of ssemly lnguge instrution mnemonis nd ssemler diretivesF

3.1.4 Editor command line


iditor is fetured with ommnd lineD whih n e invoked y pressing pIH key y defultF he ommnd line ppers elow the editor ove its sttus rF prom the ommnd line you n perform vriety of opertions like onversions etween vrious numeril sesD run simultorD insert urrent dte nd mny moreF sn the ommnd line it is su0ient to write just few hrters whih the requested ommnd strts with nd whih re su0ient to uniquely identify the ommnd nd press enterF ou n see help for eh
sourceforge.net
1 Hunspell is a spell checker and morphological analyzer.
for details. See

http://hunspell.

3.1. SOURCE CODE EDITOR

21

ommnd y running ommnd help listF gommnd line is fetured with its own olor highlightD history nd utoEompletionF
d2h d2o d2b h2d h2o h2b o2h o2d o2b b2h b2d b2o animate assemble auto-indent bookmark breakpoint capitalize clear comment copy custom cut date exit exit-program find goto help char indent kill-line open paste redo reload replace run save set-icon-border set-line-numbers sim step tolower toupper uncomment undo unindent hibernate resume switch-mcu set-xcode set-xdata

Command

Arguments
<decimal number> <decimal number> <decimal number> <hexadecimal number> <hexadecimal number> <hexadecimal number> <octal number> <octal number> <octal number> <binary number> <binary number> <binary number>

Description
Convert decimal number into hexadecimal Convert decimal number into octal Convert decimal number into binary Convert hexadecimal number into decimal Convert hexadecimal number into octal Convert hexadecimal number into binary Convert octal number into hexadecimal Convert octal number into decimal Convert octal number into binary Convert binary number into hexadecimal Convert binary number into decimal Convert binary number into octal Animate simulated program Run assembler Automatically indent the edited code Create or delete bookmark on the current line Create or delete breakpoint on the current line Capitalize selected text Clear history Comment selection Copy selection

<command number> <date format>

Run user command Cut selection Insert current time and/or date Leave command line Exit the IDE

<string> <line number> <command name> <character code>

Find a string Go to the specied line Display help for the specied command Insert a character Indent selection Delete current line

<le name>

Open the specied le Paste text from clipboard Take back last undo Reload current document

<string> <replacement>

Replace a string with another string Run simulator in animation mode Save the current le Show/Hide icon border Show/Hide line numbers Engage/Disengage simulator Step simulated program Convert selected text to lowercase Convert selected text to uppercase Comment current line Undo the last text editing operation Decrease indentation level of the current line

[<target le>] [<source le>] <MCU name> <size of XCODE mem.> <size of XDATA mem.>

Hibernate simulated program Resume hibernated program Switch current MCU simulation mode to another MCU Set size external data memory for simulated MCU Set size external program memory for simulated MCU

Table 3.1: Available commands

22

CHAPTER 3. DETAILED INTRODUCTION TO GUI

3.2 Bottom panel


3.2.1 Main panel of the MCU simulator
his pnel is the min prt of the simultor user interfeF st shows ll wg registers long with ontent of internl dt memoryF end ontins smll toolr with T uttonsX  trtG hutdownD  esetD  tep kD  tepD  tep overD  enimte nd  unF ell visile registers n e modi(ed from here nd most p registers re represented y enumertion of itsD where eh prtiulr it n e modi(ed seprtelyD green olor mens logil one nd red mens zeroF ih it hs its own tooltip help with short desription of its purpose nd sttus r tip with it ddress nd it nmeF
Figure 3.4: Main panel of the simulator

Figure 3.7: Figure 3.5:

Representa-

Highlighted Figure 3.6: Tool tip help tion of a register value in for a special function bit various numeric bases

SFR register

3.2.2 C variables
his pnel is prt of simultor user interfe tht mintins list of glol stti vriles de(ned in your g lnguge odeF xmes of vriles re displyed long with their urrent vlues in simulted wgF sf you progrm is not written in g lnguge then this tool hs no purpose for you t llF ytherwise the purpose of this pnel is to mke it esier to simulte progrm for VHSI written in g lnguge nd see wht is relly hppening in thereF his tool is ple of extrting vrile vlues from multiple registers nd the displying them s one vrileD one vlueF eltertion of vrile vlues is lso possileF end serh pnel in the top right orner of the pnel might

3.2. BOTTOM PANEL

23

help you with (nding ext vrile whih you need to seeF fut note tht funtionlity of this tool is in ft severely limitedD it supports only glol stti vrilesD integers nd )otsD ut vrile vlue modi(tion is llowed only for integer vrilesD no )otsF

3.2.3 Graph showing voltage levels


his pnel might help you to see wht is hppening on simulted qsy2 linesF esolution nd grid n e djusted to etter (t your needsF here re three grphsD one for port lthesD one for port outputs @without ny virtul rA nd one for the most relisti qsy simultion whih this shi n doF

Figure 3.8: GPIO Graph

3.2.4 Messages panel


his pnel displys output from the uildEin ssemlerD externl ssemlersD g ompiler nd other externl tools used in this shiD whih prints someE thing importnt to stndrd outputF yutput from ssemlers nd hgg @g ompilerA is prsed to highlight wrnings nd errors nd onvert them to hyperlinks pointing to soure ode if possileF he pnel lso implements tool for serhing strings in the displyed textF ser n mke this tools visile y pressing gtrlCpF

Figure 3.9: Messages panel

2 General Purpose Input Output

24

CHAPTER 3. DETAILED INTRODUCTION TO GUI

3.2.5 Notes
his is your personl notes for whtever you wntF yriginlly it ws intended for writing down list of things whih you need to (nish in your workD so some sort of to do listF fut it is just simple rih text editor with seprte (le spei( notepdF ser n use it s he or she onsider ppropriteF

Figure 3.10: Personal notes

3.2.6 Calculator
glultor is here more or less just for ompletenessF fut you might still (nd it to rel sset to your e'ortsF his lultor is ple of performing ommon rithmetil opertionsD omputing trigonometri funtionsD logiE l opertionsD etF upported numerl systems re hexdeimlD deimlD otl nd inry in oth integer nd rel numersF upported ngulr meE surement units re degreesD rdins nd grdinsF he lultor is lso equipped with three memory ells where you n sve ritrry numers for future omputtionsF yn the right side there is simple lultor dedited to lultion timers preset vlues for the spei(ed timeD lok frequenyD etF
3

Figure 3.11: Calculator

3 Essentially the same but much more advanced function has also the special calculator.

3.2. BOTTOM PANEL

25

3.2.7 Find in les


ith this tool you n serh ll (les in ertin diretory whih nmes mthes spei(ed qvyf4 ptternF he serh is mde for plin string or regulr expression mthF his tool might e very useful when you re deling with mnyD possily lrgeD soure ode (les nd you suddenly wnt to (nd something spei( in themF ih line printed in the list of found entries is hypertext link whih opens the (le mentioned in it in the soure ode editor nd nvigtes the editor to line mthing the itemF sn other words it generlly the sme s well known nix ommnd grep 5 D ut with grphil user interfeF

3.2.8 Terminal emulator


his is ommon olor IHP6 terminl emultor for the indow ystem7 s you proly knowF wore preisely st9s emedded rxvtEuniode terminl emultor y wr eF vehmnn nd othersF fkground nd foreground olors used in the terminl emultor re on(gurle in erminl on(gE urtion hilogF xote tht this feture in not ville on wirosoft R indows R operting system nd proly will never eD euse terminl emultor would hve only little use thereF

Figure 3.12: Embedded rxvt-unicode terminal emulator, with the Midnight Commander

running in it

4 An instance of pattern matching behavior, for example *.c++ matches all les with
.c++ extension.

5 A command line text search utility originally written for Unix. The name is taken

from the rst letters in global/regular expression/print. Its ocial date of creation is given as March 3, 1973.

6 A video terminal that was made by Digital Equipment Corporation (DEC). Its detailed 7 Computer software system and network protocol that provides a basis for graphical

attributes became the de facto standard for terminal emulators. user interfaces.

26

CHAPTER 3. DETAILED INTRODUCTION TO GUI

3.3 Left panel


3.3.1 List of opened les
hows list of ll (les opened withing the urrent projetF ih entry hs its own popEup menuF xoteworthy fetures re serh rD sorting y nmeD sizeD etF nd open with n externl editorF ih (le n e dded or removed from the list of projet (lesF here is not muh to sy out itD it9s just simple list with few nie fetures ut nothing omplexF

3.3.2 List of project les


hows list of ll (les ssigned to the urrent projetF ih entry hs its own popEup menuF xoteworthy fetures re serh rD sorting y nmeD sizeD etF nd open with n externl editorF ih (le n e exluded from the list of projet (lesD opened or lose withing the projetF

3.3.3 SFR watches


prom here you n see ll speil funtion regE isters on your hosen wg in one ompt listF erh pnel might help you loting prtiulr p in this pnel nd lso in the min simulE tor pnelF ih register hs two numeril repE resenttions of its vlue in the simulted wgD deiml nd hexdeimlF

3.3.4 File system browser


Figure 3.13: SFR watches

his pnel should help you quikly nvigte in your (le system in order to open (les you wnt to see s quikly s possileF fut mny people generlly don9t like pnels like this nd will lE wys use only (le seletion dilog instedF

3.4 Right panel


3.4.1 List of bookmarks
prom here you n esily nvigte trough ll ookmrks mde in the urrent soure ode (leF he pnel lso highlights item in the list whih orresponds

3.4. RIGHT PANEL

27

to the urrent line @line with ursorA in the soure ode editorF ou n lso remove ll ookmrks t one y pressing the  gler ll uttonF

3.4.2 List of breakpoints


retty muh the sme s list of ookmrksD ut this pnel shows rekpoints insted of ookmrksD tht is the only di'ereneF

3.4.3 Instruction details


hen you re writing ode in the ssemly lngugeD this pnel might e gret help for youF st shows ll vlid sets of opernds for the instrution on your urE rent ursor position in the soure ode nd highlights the set whih you re proly usingF he sme works lso for diretivesF ih line in list hs its own help window whih ppers when user points t it y the pointerF his help window shows dditionl deE Figure 3.14: tils regrding the ext instruE tionF xote lso the  how legE end utton in the upper right orner of the pnelF

Instruction details

3.4.4 Data register watches


his pnel might help you to keep trk of spei( dt registersD exept for p nd iiywF ser n dd ritrry dt memory registers whih he or she onsider to e the most imporE tnt for his or her urrent workF ou n dd register in the ottom prt of the pnelF end you n serh for spei( registerD on(gure the pnel nd sve or lod the list of register in the top pnelF his tool is ple of extrtion of used symE

Figure 3.15:

Data register

watches

28

CHAPTER 3. DETAILED INTRODUCTION TO GUI

ols from ode listing (le8 generted y n sE semlerF his feture n enled or disled in the pnel9s on(gurtion menuF he urrent list of wthed registers n e sved into (le nd loded from (le9 F wemory segments re distinguished y formt of the ddressesF es you n seen in the exmpleD the mening is thisX
Address format
1 or 2 digits 3 digits 4 digits dot and 2 digits

Memory segment
Internal RAM (not SFR) Expanded RAM External RAM Bit (including SFR area)

Table 3.2: Data register watches: Register address

3.4.5 Subprograms call monitor


prom here you n monitor ll suprogrm nd interrupt lls in your progrmF por eh enE try there is mentioned the type of llD acallD lcall or interruptD return ddress nd ddress from whih the ll ws invokedF end you n fore eh of them to premture returnF

3.4.6 List of symbols


his tools shows list of symols de(ned in Figure 3.16: Subprograms call monitor soure ode of your progrmD works for oth sE semly lnguge nd g lngugeF he list is mnE ged utomtilly s the user edit the ode nd is fetured with serh pnel for esy nvigtionF ypes of symols n e distinguished y their olors nd ionsF golors of prtiulr symols orresponds to the olors used in the soure ode editor to highlight themF

3.4.7 HW plug-ins manager


his tool does just one thingD llows user to use plugEins in wg VHSI shiF rimry purpose of these plugEins should e implementtion of interEopertion
9 These le usually have extension 8 File with

.lst

le name extension.

.wtc

3.5. OTHER TOOLS


Label Constant Macro C variable C function Other

29

Table 3.3: Symbol colors and icons in default settings

with ertin hrdwre toolsD most proly wg progrmmersF if you re interested in writing these plugEinsD plese refer to hpter UF

3.5 Other tools


3.5.1 SFR map
e tulr overview of ll ville ps on your wgF his tool hs similr grphil form s tles of p often used in VHSI mnulsD ut the most importnt di'erene is tht this one is onneted to the simultor nd is ple of representing nd modifying urrent vlues of ps in the wg simultorF

3.5.2 Map of bit addressable area


his tool is prt of the simultor user interfeF st shows ll its in the it dE dressle re of the simulted wgF ih squre represents one itD when simultor is onD you n lso hnge vlue of eh one of them y liking on itF vels nd olor used here should e hopefully ler from

Figure 3.17:

Map of the bit ad-

dressable area

the legend t the ottomF

3.5.3 Stack monitor


his tool mkes it possile to see entire wg stk in one viewF ou n lso push ny vlue you wnt onto the stk or pop vlue from it t ny timeF rowever this prtiulr tool does not llow for hnging the vlues on the tk in ny other wy thn theseF ih line in the stk monitor represents one otet in the stkD eh otet is represented in four numeril
Figure 3.18: Stack

monitor

30

CHAPTER 3. DETAILED INTRODUCTION TO GUI

sesD hexdeimlD deimlD inry nd otl nd lso s hrter ording to egss hrtF xewly dded vlues re pushed on the top of the listF end their origins re distinguished y kground olor of the ddressF hese olors re explined in the legend on ottomF xote tht utton gler doe not ler the stk ut insted it ler only the monitor3 futtons y nd r re intended for mnipultion with the stk9s ontentF

3.5.4 Symbol viewer


ymol viewer shows the tle of symols de(ned in your progrmD it works only for ssemly lngugeF he tle ontent is tken from ode listing generted y ssemE lerF sn the top prt of the window you n (nd serh rD nd in the ottom prt you n speify (lter riteri for wht you wnt to see in the tle nd speify sorting order of the symols displyedF ymol in this ontext re vrious onstnts nd lelsF
Figure 3.21: 8051 Instruction Table

Figure 3.19: Symbol viewer

Figure 3.20: ASCII chart

3.5. OTHER TOOLS

31

3.5.5 ASCII chart


golorful intertive egss hrtD it my proof hndy espeilly when you re deling with seril ommunition nd this sort of thingsF

3.5.6 8051 Instruction Table


golorful intertive VHSI instrution tleD very muh like the egss hrtF fut insted of egss ode you n (nd there the omplete tle of VHSI instrution mnemonisD y odes nd relted thingsF

3.5.7 8-segment editor


ith this tool you n esily determine wht vlue you hve to set on port to disply digit on numeril vih displyF sn the left prt of the dilog windowD you n (nd numeril vlE ues orresponding to the digit displyed in the middle prtF hese vlues re represented for oth ommon thode nd node nd in three numeril sesD hexdeimlD deiml nd oE tlF futtons on left side from entry oxes opies Figure 3.22: 8-segment editor vlue from djent entry ox into lipordF sn the right prt of the window you n set wht port pin is onneted to wht vih segmentF

3.5.8 Stopwatch
topwth is tool whih n mesure ertin things in the simulted proesE sorD suh s numer of instrutions proessed so frD numer of miroseonds whih would it tke for rel proessor to exeuteD numer of rekpoints met so fr etF ser n lso set it to stop the simultion when ertin limit in the mesurement hs een met or exeededF

3.5.9 Scribble notepad


his is something like smll whiteordD where you n drw of write your notesF st is little it more free thn onventionl text editorF ou n lso insert imgesD supported imge formts re xq nd few othersF fut don9t rely on the srile notepd to muhD this tool hs no sve or lod funtionsD nything you drw or write there is just temporry nd it will not reover upon next strt of the shiF

32

CHAPTER 3. DETAILED INTRODUCTION TO GUI

3.5.10 Base converter


hen you re progrmming miroEontrollersD you might wnt to onvert numers etween vrious nuE meri sesF yne ould sy tht everyone deling with suh things s miroEontrollers would e le to do these onversion without use of ny toolF fut Figure 3.23: Base converthis doesn9t men tht suh tool n never e tor usefulF lues written in the entry oxes of the se onverter re sved when user leved the shi nd re reovered upon next strt long with ll opened se onverter tool windowsF

3.5.11 RS-232 debugger


his tool is ple of trnsmitting nd reeiving dt toGfrom EPQP port in your omputerD tody perE sonl omputers usully do not hve this type of portD ut you n lwys use something like f to EPQP ridgeF s ssume here tht the reder is fmilir with the EPQP ommuniE tion protool nd relted termsF his tool ts s DTE10 F Figure 3.24: UART/RS-232 debugger yn the digrm in the upper left orner you n see urrent logil level on eh of EPQP wires exept for RxD nd TxDF ou n lso set vlue for wires DTR11 nd RTS12 nd trigger the rek y utton BREAKF ight upper orner ontins on(gurtion ontrolsD their funtions should e mostly oviousF ghekEox inle reeption enles or disles writing to hexdeiml editor eeived dtF futton glose loses the opened physil portF end utton   refreshes the list of ville physil portsF sn the ottom prt you n see two hexdeiml editorsX ht to send nd eeived dtF hese re representtions of dt whih we re deling withF fy utton eeive here you n set ddress in the hexdeiml editor
10 Data Terminal Equipment, the other side is
ment).

DCE

(Data Circuit-terminating Equip-

11 Data Terminal Ready 12 Ready To Send

3.5. OTHER TOOLS

33

where the reeived dt will e writtenF end y utton end seleted you n trigger trnsmission over the opened physil portD seleted hunk of the dt will e send thenF futton gler seleted re intended for removing dt from the hexdeiml editors editorsF

3.5.12 Hexadecimal editors


sn this shi there re severl hexE deiml editors used for vrious purposesF ih of these editors is equipped with string serh tool nd ddress rs of the left nd top sideF end in some ses with (le sving nd loding pilityD numeril se swithD egss view nd nvigtion r t the ottomF iditing is llowed only in overwrite modeD opy nd pste works s usulD serh dilog n e invoked y pressing gtrlCp nd user n Figure 3.25: MCU code memory editor swith etween view @left nd rightA y pressing keyF xon printle hrters in egss view re displyed in red olorF

MCU code memory editor

llows user to see nd modify ontents of the gyhi memory of the simulted miroEontrollerF peil feture of this prtiulr editor is tht instrution y ode urrently pointed y progrm ounter @gA is highlighted with drk ornge kground long with the instrution9s operndsF end the sme pplies lso for the previously exeuted instrution ut highlight olor is light ornge in this seF

MCU data/xdata/eeprom memory editor llows user to see nd modE ify ontents of the sheeGheeGiiyw memory of the simulted miroEontrollerF peil fetures of this editors re tht reently hnged otets re highlighted with light ornge foreground olor nd otets urrently eing written into the memory re highlighted with gry kground olorF MCU eeprom write buer editor
llows to see nd modify iiyw write u'erF gurrent iiyw write o'set is displyed s wellF

34

CHAPTER 3. DETAILED INTRODUCTION TO GUI

is universl hexdeiml editor with mximum pity of TRkf nd support for sntel R V ri (le formtF his tool is ompletely independent from your projet in the shiF his too might e prtiulrly useful when you wnt to nd possily modify ontent of sntel R V hex (leD ut do not lter the simulted wgF

Independent hexadecimal editor

3.5.13 Hibernation of simulated program


he shi is ple of sving exeution stte of the simulted progrm into (le nd resuming the progrm from it nytime lterF he (leD usully with extension .m5ihibD ontins vlues of ll dt registers inluding p in the simulted wg long with other vlues determining wg stte s for exmple list of tive interruptsF he (le is in wv formtD humn redle nd usully oupies few tens of kiloytesFhe (le does not ontin ontent of the gyhi memoryD so it hs to e ville somewhere else in seprte (leF

3.5.14 Interrupt monitor


snterrupts monitor is speilized tool intended for viewing nd mnipuE lting with interrupts in simulted wgF ith interrupt monitor you n invoke ny interrupt you wnt t ny timeD fore ny interrupt t ny time to returnD hnge interrupt priorities or disle or enle prtiulr interruptsF ou n lso see ll interrupts synoptilly in one window nd lter vlues of their on(gurtion )gsF

Figure 3.26: Interrupt monitor

3.5. OTHER TOOLS

35

3.5.15 Conversions between *.hex, *.bin and *.adf les


ometimes it might prove helpful to hve some tool to onvert inry (le to sntel R V rex nd vie versF por this purpose wg VHSI shi is equipped with simple tool set for this purposeF sn the  Main Menu  Utilities you n (nd these toolsX

HEX BIN gonvert sntel R V rex (le to rw inry (le BIN HEX gonvert rw inry (le to sntel R V rex SIM HEX gonvert simultor ssemler deug (le @.adfA to sntel R V rex (le SIM BIN gonvert simultor ssemler deug (le @.adfA to rw inry (le Normalize Hex ed nd rewrite the given sntel R V rex (leD so tht ll reords stis(es spei(ed mximum length @n e set in the ssemler on(gurtion dilogAD ll reords re in inrementl order nd no reords overlps with othersF

3.5.16 Normalization of source code indentation


niformly indented ode is lwys more esthetilly plesing nd more redE leF hen you don9t hve the luxury of hving suh ode from the (rst hndD perhps you will (nd this feture helpfulF his funtion is ville for ssemly lnguge nd g lnguge if progrm indent is instlled on your systemF ser n ess this funtion from the  Main Menu  Tools  Auto indentF
A small example of the auto indent function in action

Original code:

abc DATA 7Fh ; Start at address 0x00 ORG 0h label0:inc R0 inc @R0 cjne R0 , #abc ,label0 mov R0, #0h sjmp label0 ; End of assembly END

Automatically intended code:


abc

DATA 7Fh ; Start at address 0x00 ORG 0h label0: inc R0 inc @R0 cjne R0, #abc, label0 mov R0, #0h sjmp label0 ; End of assembly END

3.5.17 Change letter case

36

CHAPTER 3. DETAILED INTRODUCTION TO GUI

his tool n hnge letter sing to upper or lower se of ertin types tokens whih your soure onsists of ofF por exmple you n esily onvert ll instrution mnemonis in the ode to upperseF st is intended for users who stritly prefers one or nother onE vention of letter sing in ssemly lngugeF ou n invoke the tool from  Main Menu  Tools  Change letter caseF

Figure 3.27:

Change letter case

dialog

gonvert to upperse gonvert to lowerse ueep urrent se

3.5.18 User dened commands


his feture ws dded in order to enle for use of ny uxE iliry tools whih might useful while working in this shiF por instneD some hrdwre tools or some sort of soure ode mngement system like qit or xF hese ustom ommnds re silly mere fsh sripts with some kind of pseudoEvriles ville in itF hese pseudoEvriles re formed s strings eginning with  %F fefore eh sript exeution they re expnded to vlues orresponding to their meningF por instne  %filename expnds to the nme of the urrent (leF xote tht  %% is expnded s single  %F
Pseudo-variable
%URL %URLS %directory %lename %basename %mainle %line %column %selection %text

Introduction

Meaning
The full URL of the current le List of the URLs of all open documents Project directory The le name of the current document Same as %lename, but without extension Name of project main le Number of the current line Number of the current column The selected text in the current le The full text of the current le

Table 3.4: List of pseudo-variables

Conguration
ommndsF

here is speilized on(gurtion dilog for these ustom

3.6. CONFIGURATION DIALOGUES

37

Execution

efter the sript is exeuted suE essfully or notD dilog showing the results will pper upon ompletion of the sriptF his dilog ontins ll textul output from the sript ught on stndrd output nd stndrd error outputF sf the sript outputs nything to the stndrd error output it is onsidered unsuessfulF

Figure 3.28: Custom commands

3.5.19 Clean-up project folder

conguration dialog

his tool n proof useful prtiulrly when your projet diretory gets polluted with lots of unneessry (lesD nd you wnt to get rid of them esily nd (rst of ll sfelyF st removes (les with ertin (le nme extensions from the projet folderF he list of removed (les is then written in results dilogF eville from  Main Menu  Tools  Clean up project folderF

3.5.20 File statistic


hisply ertin sttistil informtion out the urrent soure ode (leF  Main Menu  File  File statisticF

3.6 Conguration dialogues


gon(gurtion dilogues re grphil tools for ustomiztion of this inteE grted development environmentF end they omprises of these omponentsX

Editor conguration

sn editor on(gurtion dilog user n hnge preferred editor from defult uiltEin editor to for exmple im or ims nd modify on(gE urtion the uiltEin editorF gon(gurle re olors used for syntx highlightD olors for text re kground nd so onD font used y editorD indenttion modeD utoE sve intervl nd othersF

Figure 3.29:

Editor

conguration dialog

38

CHAPTER 3. DETAILED INTRODUCTION TO GUI

Compiler conguration gompiler on(gurtion diE log llows user to on(gure ehvior of the uiltEin ssemlerD hose nother ssemler insted of this oneF gon(gure the preferred ssemler nd on(gure the g ompiler @hggAF gompiler on(gurtion is stored in the projet (le @the (le with .mcu8051ide extensionAF o these setting re spei( to the one spei( wg VHSI shi projetF gurrently supported externl ssemlers re theseX
eiwESI ev 14 eSI 15
13

row to link multiple (les when using g lngugeX16 IF rite mke(leD PF set the shi to use your mke(le insted of lling the g ompiler diE retly @gon(gurtion Eb gompiler on(gurtion Eb qx mke utilityAD QF strt ompiltion s usulF

Simulator conguration

imultor on(gurtion dilog on(gures theseX

IF row to tret indeterminle vlues in simultor engine PF row mny steps will e rememered during the simultion for lter kwrd stepsF QF ht wrning onditions will e ignored during the simultion

Right panel conguration

gon(gures olors used in tools snstrution detils nd egister wthes in the right pnelF

rF

Main toolbar conguration


de/asem-51/home.htm

gon(gures ontents of min pplition tool


http://plit.

13 A really useful assembler written by W.W. Heinz. You can nd it at 14 Available at http://linux.maruhn.com/sec/asl.html 15 Available at http://www.pjrc.com/tech/8051 16 This feature is not yet supported on MS Windows.

3.6. CONFIGURATION DIALOGUES

39

Figure 3.30: Main toolbar

gon(gures user de(ned ommndsD whih re essentilly fsh sriptsF his feture is urrently not ville on w R indows R yF

Custom commands conguration

Shortcuts conguration

gon(gures key shortuts used in the shiF

Terminal emulator conguration

gon(gures terminl emultor t the ottom pnelF his terminl emultor is emedded rxvtEuniodeF ser n set foreground olor nd kground olor of the terminl emultor window nd the fontF his feture is urrently not ville on w R indows R yF

Global MCU 8051 IDE conguration ghnges settings like qs lngugeD size of fonts used in the qsD qs widget styleD whether splsh sreen should e displyed eh time when the shi is strted nd so onF
Figure 3.31:

Global

conguration dialog

40

CHAPTER 3. DETAILED INTRODUCTION TO GUI

41

Chapter 4 Build-in macro-assembler


sn this hpter we will e onerned with wg VHSI shi uildEin ssemlerF 1 ith syntx of its sttementsD diretives nd VHSI ssemler instrutionsF s ssume tht the reder is fmilir with generl onepts of ssemly lnguge progrmming nd VHSI rhitetureF o s will not explin these hereF

4.1 Statements
oure ode (les for this ssemler must e text (les where lines re formed like theseX
[ [
label: label:

] ]

instruction

directive directive

[ [

operand

argument

, operand

, operand

]]]

symbol

argument

[ [ [

;comment

;comment ;comment

] ] ]

iverything in squre rkets is optionlF gompiltion does not go eE yond line ontining  end diretiveD so fter tht diretive the ode do not hve to e synttilly vlidF impty lines re llowed s well s line ontinE ing only omment or lelF ttements n e seprted y spesD xf hrters2 nd tsF ttements re se insensitive nd their length is not limitedD overll line length is lso not limitedF

4.2 Symbols
ymol nmes for numersD mros or ddresses de(ned y user in the ode using pproprite diretiveF vike with  equ diretive you n de(ne new
1 This assembler manual is inspired by ASEM-51 manual, a great work done by W.W.
Heinz

2 No Breaking Space (0xC2)

42
start: ; Start mov mov mov mov setb sjmp ; Main loop main: sjmp ; Program end end

CHAPTER 4. BUILD-IN MACRO-ASSEMBLER


timer 0 in mode 2 R5, #0h IE, #0FFh TL0, #255d TMOD, #03h TR0 main

Code 2 en exmple of well formed ssemly lnguge ode

; Inifinite loop

symol nd ssign vlue to it right wyF ymols my onsist of upper nd lower se letterD digits nd undersore hrter @AD their length is not limitedD they re se insensitive nd they n e the sme s lnguge keywordsF fe wre of tht there nnot oexists two or more symols in the sme memory segment whih di'ers only y letter singD in other words symols  abc nd  ABC re ompletely the sme thingF

4.3 Constants
here re two types of onstnts numeri onstnts nd hrter onstntsF xumeri onstnts onsist of sequene of digits llowed for the numeri se used nd followed y the rdix spei(erF sf the numer egins with letterD there must e the zero digit pled efore the numerF por exmple h is not vlid numeri onstntD ut Hh isF ghrter onstnts onE sist of sequene of one or more hrters enlosed y quote hrter @'AF g espe sequenes n e used in hrter onstntsF sf you wnt to ple quote hrter @'A into the onstntD you n either ple two quotes insted of one @ ''''A or espe the quoteD tht mens ple kslsh   efore itF here is signi(nt di'erene etween single hrter onstnt nd multiple hrter oneF ingle hrter onstnt is regrded y ssemE ler s V in integer numer nd multiple hrter onstnt is stringD sequene of hrtersF ine version IFRFI it is possile to use pre(x Hx @nd HA s rdix spei(er for hexdeiml numersD so Hxf is the sme s HfhD etF

4.4. EXPRESSIONS
Constant type Binary Octal Decimal Hexadecimal Allowed digits 0 .. 1 0 .. 7 0 .. 9 0 .. 9, A .. F Radix specier B O or Q D or none H

43

Table 4.1: Radix speciers

Code 3 en exmple of onstnts


; a a a a a These are the set 100111b set 47q set 39d set 27h set '''' same number ; Binary ; Octal ; Decimal ; Hexadecimal ; Character

; This is an example of string db 'string' ; String

4.4 Expressions
erithmetil expressions re evluted t ompiltion time nd repled y ssemler with onstnt orresponding the their resulting vlueF ixpressions omprises of rithmetil opertorsD onstntsD symols nd nother expresE sionsF en exmple of suh expression might e ( X XOR 0FF00H )
Operator NOT HIGH LOW + * / MOD SHL SHR AND OR XOR . EQ, = NE, <> LT, < LE, <= GT, > GE, >=

Unary Operators

Description one's complement high order byte low order byte unsigned addition unsigned subtraction unsigned multiplication unsigned division unsigned remainder logical shift left logical shift right logical and logical or exclusive or bit operator equal to not equal to less than less or equal than greater than greater or equal than

Example NOT 0a55ah HIGH 0a55ah LOW 0a55ah 11 + 12 13 + 11 3 * 5 20 / 4 21 MOD 4 32 SHL 2 32 SHR 2 48 AND 16 370q OR 7 00fh XOR 005h P1.4 11 EQ 11 11 NE 11 11 LT 12 11 LT 11 12 GT 11 12 GT 11

Binary Operators

Table 4.2: Expression operators

44

CHAPTER 4. BUILD-IN MACRO-ASSEMBLER

abc EQU ( 2000 * 3 / 100 ) xyz SET ( LOW abc ) IF ( abc > ( 5 MOD 2 ) ) MOV A, # ( ( 15h XOR 12 ) OR xyz ) ELSE ADDC A, # ( HIGH 1234h ) ENDIF

Code 4 en exmple of expressions

4.5 The instruction set processing


his ssemler is ple of trnslting ll VHSI instrutions with ll possile sets of operndsF end extends this set with P pseudoEinstrutionsX gevv nd tw whih do not stnd for ny opertion odeD ut re trnslted ording to the used operndF gevv n e trnslted s egevv or vgevvD tw ddr n e trnslted s twD etw or vtwF

4.6. ASSEMBLER DIRECTIVES

45
ENDM

4.6 Assembler directives


ifn
IF Not, conditional assembly Syntax:

IFN <expr> IF(2 * 4 - CND) MOV A, #20h ELSE MOV A, #40h ENDIF

if

Conditional assembly Syntax:

Example:

IF <expr>
Example:

ifdef

IF(2 * 4 - CND) MOV A, #20h ELSE MOV A, #40h ENDIF

IF DEFined Syntax:

IFDEF <symbol>
Example:

else

Conditional assembly Syntax:

ELSE
Example:

IFDEF CND MOV A, #20h ELSE MOV A, #40h ENDIF

IF(2 * 4 - CND) MOV A, #20h ELSE MOV A, #40h ENDIF

ifndef

IF Not DEFined Syntax:

elseif

Conditional assembly Syntax:

IFNDEF <symbol>
Example:

ELSEIF <expr>
Example:

IFNDEF CND MOV A, #20h ELSE MOV A, #40h ENDIF

IF(2 * MOV ELSEIF MOV ENDIF

4 - CND) A, #20h SOMETHING_ELSE A, #40h

rept

REPeaT Macro Syntax:

elseifn

Conditional assembly Syntax:

REPT <expr>
Example:

ELSEIF <expr>
Example:

REPT 5 NOP ENDM

times

IF(2 * MOV ELSEIF MOV ENDIF

4 - CND) A, #20h SOMETHING_ELSE A, #40h

REPeaT Macro Syntax:

TIMES <expr>
Example:

elseifdef

Conditional assembly

Syntax:

ELSEIF <expr>
Example:

TIMES 5 NOP

IF(2 * 4 - CND) MOV A, #20h

46

CHAPTER 4. BUILD-IN MACRO-ASSEMBLER


ELSEIFDEF SOMETHING_ELSE MOV A, #40h ENDIF NOP LIST NOP

elseifndef

Conditional assembly

nolist

disabled code listing Syntax:

Syntax:

ELSEIF <expr>
Example:

NOLIST
Example:

IF(2 * 4 - CND) MOV A, #20h ELSEIFNDEF SOMETHING_ELSE MOV A, #40h ENDIF

endif

NOP NOLIST NOP NOP LIST NOP

Conditional assembly Syntax:

ENDIF
Example:

dseg

switch to DATA segment [at address] Syntax:

IF(2 * 4 - CND) MOV A, #20h ELSE MOV A, #40h ENDIF

DSEG [AT <expr>]


Example:

DSEG at 20d

iseg

switch to IDATA segment [at address] Syntax:

endm

END of Macro denition Syntax:

ISEG [AT <expr>]


Example:

ENDM
Example:

ISEG at 10d

ABC MACRO MOV B, #12d ENDM

bseg

switch to BIT segment [at address] Syntax:

end

BSEG [AT <expr>]


END of the program Syntax: Example:

END
Example:

BSEG at 5d

END

xseg

switch to XDATA segment [at address] Syntax:

list

XSEG [AT <expr>]


enable code LISTing Syntax: Example:

LIST
Example:

XSEG at 30d

NOP NOLIST NOP

cseg

switch to CODE segment [at address] Syntax:

CSEG [AT <expr>]

4.6. ASSEMBLER DIRECTIVES


<symbol> CODE <expr>
Example:

47

CSEG at 40d

Example:

TBL CODE 600h

ag

dene a FLAG bit Syntax:

data

dene address in the DATA memory Syntax:

<symbol> FLAG <expr>


Example:

<symbol> DATA <expr>


Example:

F4 FLAG 16h

UIV DATA 20h

Note: Deprecated directive. Consider directive idata BIT dene instead.} address
ory

in the Internal DATA mem-

skip

Syntax: SKIP bytes in the code memory Syntax:

<symbol> IDATA <expr>


Example:

SKIP <expr>
Example:

UIV IDATA 20h

SKIP 5

xdata

dene address in the External DATA memory Syntax:

equ

EQUivalent Syntax:

<symbol> XDATA <expr>


Example:

<symbol> EQU <expr>


Example:

UIV XDATA 400h

ABC EQU R0 XYZ EQU 4Eh+12

macro

MACRO denition Syntax:

bit

<macro> MACRO [<arg0> [,<arg1> ... ]


dene BIT address Syntax: Example:

<symbol> BIT <expr>


Example:

ABC MACRO X MOV X, #12d ENDM

ABC BIT P4.5

local

dene a LOCAL label inside a macro Syntax:

set

LOCAL

<label>

SET numeric variable or variable register Syntax: Example:

<symbol> SET <expr> <symbol> SET <register>


Example:

ABC MACRO X LOCAL xyz xyz: MOV X, #12d ENDM

ALPHA SET R0 ALPHA SET 42*BETA

ds

Dene Space Syntax:

code

dene address in the CODE memory Syntax:

DS <expr>
Example:

48
DS 2+4

CHAPTER 4. BUILD-IN MACRO-ASSEMBLER

dw

Dene Words Syntax:

DW <expr1> [,<expr2> ... ]


Example:

DW 0,02009H,2009,4171

db

Dene Bytes Syntax:

DB <expr1> [,<expr2> ... ]


Example:

DB 24,'August',09,(2*8+24)/8

dbit

Dene BITs Syntax:

DBIT <expr>
Example:

DBIT 4+2

include

INCLUDE an external source code

Syntax:

INCLUDE <filename>
Example:

INCLUDE 'my file.asm'

org

ORiGin of segment location Syntax:

ORG <expr>
Example:

ORG 0Bh

using

USING register banks Syntax:

USING <expr>
Example:

USING 2

byte

dene BYTE address in the data memory Syntax:

<symbol> BYTE <expr>


Example:

UIV BYTE 20h Note: Deprecated directive. Consider directive DATA instead.

4.7. ASSEMBLER CONTROLS

49
Don't list subsequent source lines Syntax:

4.7 Assembler Controls$noli


$date
Inserts date string into page header Syntax:

$NOLI $NOLI

Example:

$DATE(string) $DATE(1965-12-31)

Example:

$nolist

Don't list subsequent source lines Syntax:

$da

Inserts date string into page header Syntax:

$NOLIST $NOLIST

Example:

$DA(string) $DA(1965-12-31)

Example:

$nomod

Disable predened SFR symbols

$eject

Syntax: Start a new page in list le Syntax:

$NOMOD $NOMOD

Example:

$EJECT $EJECT

Example:

$nomo

Disable predened SFR symbols Syntax:

$ej

Start a new page in list le Syntax:

$NOMO $NOMO

Example:

$EJ $EJ

Example:

$nomod51

Disable predened SFR symbols

$include

Syntax: Include a source le

$NOMOD51 $NOMOD51

Syntax:

Example:

$INCLUDE(string) $INCLUDE(somefile.asm)

Example:

$paging

Enable listing page formatting

$inc

Syntax: Include a source le Syntax:

$PAGING $PAGING

Example:

$INC(string) $INC(somefile.asm)

Example:

$pi

Enable listing page formatting Syntax:

$list

List subsequent source lines Syntax:

$PI $PI

Example:

$LIST $LIST

Example:

$nopi

Disable listing page formatting Syntax:

$li

List subsequent source lines Syntax:

$NOPI $NOPI

Example:

$LI $LI

Example:

$nopaging

Disable listing page formatting

Syntax:

$NOPAGING

50
Example:

CHAPTER 4. BUILD-IN MACRO-ASSEMBLER


$NOPAGING

$title

Inserts title string into page header Syntax:

$TITLE(string) $TITLE(My firts code)

$pagelength

Example: Set lines per page for listing

Syntax:

$PAGELENGTH(int) $PAGELENGTH(64)

Example:

$tt

Inserts title string into page header Syntax:

$TT(string) $TT(My firts code)

$pl

Example: Set lines per page for listing Syntax:

$PL(int) $PL(64)

Example:

$noobject

Do not create Intel HEX le

Syntax:

$NOOBJECT $NOOBJECT

$pagewidth

Example: Set columns per line for listing

Syntax:

$PAGEWIDTH(int) $PAGEWIDTH(132)

Example:

$object

Specify le name for Intel HEX

Syntax:

$OBJECT(string) $OBJECT(my_hex.hex)

$pw

Example: Set columns per line for listing Syntax:

$PW(int) $PW(132)

Example:

$print

Specify le name for list le Syntax:

$PRINT(string) $PRINT(my_list.lst)

$symbols

Example: Create symbol table

Syntax:

$SYMBOLS $SYMBOLS

Example:

$noprint

Do not create list le at all

Syntax:

$NOPRINT $NOPRINT

$sb

Example: Create symbol table Syntax:

$SB $SB

Example:

$nomacrosrst
Syntax:

Dene and expand macro instruc-

tions after! conditional assembly and denitions of constants

$nosymbols

Don't create symbol table

$NOMACROSFIRST $NOMACROSFIRST

Syntax:

$NOSYMBOLS $NOSYMBOLS

Example:

Example:

$nosb

Don't create symbol table Syntax:

$NOSB $NOSB

Example:

4.8. PREDEFINED SYMBOLS

51

4.8 Predened Symbols


here re symols whih re de(ned y defult y ssemlerF he im is to mke it little esier to write ode in ssemly lnguge for VHSID euse user don not hve to de(ne ll these symols in his or her odeF his feture n e turned of y  $NOMOD ontrol sequeneF
Table 4.3: Code addresses

Symbol
RESET TIMER1

Value
000h 01Bh

Symbol
EXTI0 SINT

Value
003h 023h

Symbol
TIMER0 TIMER2

Value
00Bh 02Bh

Symbol
EXTI1 CFINT

Value
013h 033h

Table 4.4: Plain numbers, these symbols are always dened!

Symbol
??MCU_8051_IDE ??VERSION

Value
8051h 0139h
3

Table 4.5: Predened SFR bit addresses

Symbol
IT0 TR0 RI REN FE EX0 ES RXD T0 PX0 PS PPCL PT1L TF2 EXEN2 P RS1 CR CCF3

Value
088h 08Ch 098h 09Ch 09Fh 0A8h 0ACh 0B0h 0B4h 0B8h 0BCh 0BEh 0BBh 0CFh 0CBh 0D0h 0D4h 0DEh 0DBh

Symbol
IE0 TF0 TI SM2 ET0 ET2 TXD T1 PT0 PT2 PT2L PX1L EXF2 TR2 OV F0 CCF4 CCF2

Value
089h 08Dh 099h 09Dh 0A9h 0ADh 0B1h 0B5h 0B9h 0BDh 0BDh 0BAh 0CEh 0CAh 0D2h 0D5h 0DCh 0DAh

Symbol
IT1 TR1 RB8 SM1 EX1 EC INT0 WR PX1 PC PSL PT0L RCLK CT2 RS0 AC CCF1

Value
08Ah 08Eh 09Ah 09Eh 0AAh 0AEh 0B2h 0B6h 0BAh 0BEh 0BCh 0B9h 0CDh 0C9h 0D3h 0D6h 0D9h

Symbol
IE1 TF1 TB8 SM0 ET1 EA INT1 RD PT1

Value
08Bh 08Fh 09Bh 09Fh 0ABh 0AFh 0B3h 0B7h 0BBh

PX0L TCLK CPRL2 CY CCF0

0B8h 0CCh 0C8h 0D7h 0D8h

52

CHAPTER 4. BUILD-IN MACRO-ASSEMBLER

Table 4.6: Predened SFR addresses

Symbol
P0 PCON TL1 SCON P3 B DP0H T2CON TL2 CLKREG SADEN AUXR CH CCAP3H CCAPL4H ADDH CCAP0L CCAPL4L CCAPM1 P1M2 P3M1 SPDAT IPH0 KBLS SADEN_1 OSCCON

Value
080h 087h 08Bh 098h 0B0h 0F0h 083h 0C8h 0CCh 08Fh 0B9h 08Eh 0F9h 0FDh 0FEh 0F5h 0EAh 0EEh 0DBh 0E2h 0D5h 0C5h 0B7h 09Ch 0BAh 086h

Symbol
SP TCON TH0 SBUF IP P4 DP0L T2MOD TH2 ACSR SPCR CKCON CCAP0H CCAP4H ADCLK ADCF CCAP1L CCON CCAPM2 P3M2 P4M1 IPL0 BRL KBE SADDR_0 CKRL

Value
081h 088h 08Ch 099h 0B8h 0C0h 082h 0C9h 0CDh 097h 0D5h 08Fh 0FAh 0FEh 0F2h 0F6h 0EBh 0D8h 0DCh 0E3h 0D6h 0B8h 09Ah 09Dh 0A9h 097h

Symbol
DPL TMOD TH1 P2 PSW WDTCON DP1H RCAP2L AUXR1 IPH SPSR WDTPRG CCAP1H CCAPL2H ADCON P5 CCAPL2L CMOD CCAPM3 P4M2 SPCON IPL1 BDRCON KBF SADDR_1 CKCON0

Value
082h 089h 08Dh 0A0h 0D0h 0A7h 085h 0CAh 0A2h 0B7h 0AAh 0A7h 0FBh 0FCh 0F3h 0E8h 0ECh 0D9h 0DDh 0E4h 0C3h 0B2h 09Bh 09Eh 0AAh 08Fh

Symbol
DPH TL0 P1 IE ACC EECON DP1L RCAP2H WDTRST SADDR SPDR CCAP2H CCAPL3H ADDL CL CCAPL3L CCAPM0 CCAPM4 P1M1 SPSTA IPH1 BDRCON_1 SADEN_0 CKSEL

Value
083h 08Ah 090h 0A8h 0E0h 096h 084h 0CBh 0A6h 0A9h 086h 0FCh 0FDh 0F4h 0E9h 0EDh 0DAh 0DEh 0D4h 0C4h 0B3h 09Ch 0B9h 085h

4.9. SEGMENT TYPE

53

4.9 Segment type


egment type spei(es the ddress spe to whih symol is ssignedF por exmple if you de(ne symol efg using hee diretiveD then ef is ssigned to hee segmentF urpose of this is to semntilly distinguish etween di'erent types of symolsF por exmple if we use symol s ddress to progrm memory it hs di'erent mening tht if we used it s ddress to it ddressle reF
DATA IDATA XDATA BIT CODE NUMBER Internal data memory and SFR Internal data memory only External data memory only Bit addressable area only Program memory only Arbitrary value

Table 4.7: Segment types

ymols might e ssigned to these segment types y these diretivesX

hee @segment heeA shee @segment sheeA hee @segment heeA fs @segment fsA gyhi @segment gyhiA iD i @segment xwfiA

Code 5 ixmple of symol de(nitions


MY_A MY_B MY_C MY_D MY_E MY_F DATA IDATA XDATA BIT CODE EQU '\n' 0AAH 14Q P1.2 62348D 242Q ; ; ; ; ; ;

DATA segment (internal data memory and SFR) IDATA segment (internal data memory only) XDATA segment (external data memory only) BIT segment (bit addressable area only) CODE segment (program memory only) Segment NUMBER (arbitrary value)

; Segment NUMBER (arbitrary value) MY_G SET MY_A + MY_B + MY_C + MY_D + MY_E + MY_F

54
; CODE segment cseg at my_c CODE word: DW my_cs: DB

CHAPTER 4. BUILD-IN MACRO-ASSEMBLER

Code 6 ixmple of ddress spe reservtion


40h ; 00abch ; 01234h ; 'abcdef'; Start this segment at address 40 hexadecimal (64d) Define an address in code memory Define a word in code memory, will be written to code memory Define a string in code memory, will be written to code memory

; DATA segment dseg at 10q my_d DATA 'd' my_ds: DS 4 ; IDATA segment iseg at 10d my_i IDATA 'i' my_is: DS 4 ; BIT segment bseg at 10b my_bit BIT 'b' my_bs: dbit 4 ; XDATA segment xseg at 10 my_x XDATA 'x' my_xs: DS 4 address equ org 0h

; Start this segment at address 10 octal (8d) ; Define address in internal data memory or SFR area ; Reserve 4 bytes here and set ``my_ds'' to point there ; Start this segment at address 10 decimal ; Define address in internal data memory ; Reserve 4 bytes here and set ``my_is'' to point there ; Start this segment at address 10 binary (2d) ; Define address in bit addressable area ; Reserve 4 bits here and set ``my_bs'' to point there ; Start this segment at address 10 decimal ; Define address in external data memory ; Reserve 4 bytes here and set ``my_xs'' to point there ; Define symbol ``address' in the NUMBER segment

address ; Start writing program code at address defined by symbol ``address''

; Clear 1st bit in BIT array ``my_bs'' clr my_bs+1 ; Move 10d to 2nd byte in DATA array ``my_ds'' mov my_ds+2, #10d ; Move 88d to 3rd byte in IDATA array ``my_is'' mov my_is+3, #88d ; Move 55h to 0th byte in XDATA array ``my_xs'' mov A, #55h mov DPTR, #( my_xs + 0 ) movx @DPTR, A ; Read 1st byte from CODE array ``my_cs'' mov DPTR, #my_cs mov A, #1 movc A, @A+DPTR sjmp end $ ; Infinite loop (``$'' stands for address of current instruction) ; End of assembly, everything after this directive is ignored

4.10. CONDITIONAL ASSEMBLY

55

4.10 Conditional Assembly


he im of onditionl ssemly to to ssemle ertin prts of the ode if nd only if ertin rithmetilly expressed ondition is metF his feture n prove useful prtiulrly when the user wnt to mke the ode someE how on(gurleF his ssemler provides these instrutions to work with onditionl ssemlyX

sp `onditionb spx `onditionb sphip `symolb spxhip `symolb ivi ivisp `onditionb ivispx `onditionb ivisphip `symolb ivispxhip `symolb ixhsp

his n e est demonstrted on n exmpleX

Code 7 en exmple of onditionl ssemly usge


abc xyz equ equ 16 10 ifdef abc if ( abc = 13 ) mov a, #01010101b elseif ( abc = 14 ) mov a, #0aah elseifn ( abc % 2 ) mov a, #abc else mov a, #377q endif elseifndef xyz clr A else ifn (xyz mod 2) mov a, #128d endif endif sjmp end $ ;<--+ ; | ; | ; | ; | ; | ; | ; | ; | ; | ;<--+ ; | ;<--+ ; | ; | ; | ;<--+

; Assign number 14 to symbol abc ; Assign number 10 to symbol abc Assemble only if symbol abc has been defined <--+ Assemble if 13 has been assigned to symbol abc | <--+ Assemble if 14 has been assigned to symbol abc | <--+ Assemble if the value assigned to symbol abc is even | <--+ Else .. | <--+ Assemble if symbol xyz has NOT been defined Else ... <--+ Assemble if ( yxz modulo 2 ) is 0 | <--+

; Infinite loop ; End of assembly

56

CHAPTER 4. BUILD-IN MACRO-ASSEMBLER

4.11 Macro Processing


wro is sequene of instrutions whih n e expnded nywhere in the ode nd for ny numer of timesF ht my redue neessity of repeting ode frgments s well s soure ode size nd mke the solved tsk esier to omprehend nd solveF nlike suprogrms mros do not dd extr runEtime overhed nd repeting usge of mros my signi(ntly inrese size of the resulting mhine odeF wros supported y this ssemler re divided to nmed nd unnmed onesF
MACRO REPT TIMES ENDM Dene a new named macro Dene a new unnamed macro and expand it right away for the specied number of times Exactly the same as REPT End of macro denition

Table 4.8: Directives directly related to macros

his n e well demonstrted on exmplesX

Code 8 en exple of i diretive


rept endm 3 mov cpl mov ; Repeat the code 3 times a, p0 a p1, a

; This is the same as if you wrote this: mov a, p0 cpl a mov p1, a mov a, p0 cpl a mov p1, a mov a, p0 cpl a mov p1, a

4.11. MACRO PROCESSING

57

Code 9 en exple of simple nmed mro


abc endm abc abc macro mov cpl mov ; Define named macro ``abc'' a, p0 a p1, a

; Expand macro ``abc'' here ; Expand macro ``abc'' here

; This is the same as if you wrote this: mov a, p0 cpl a mov p1, a mov a, p0 cpl a mov p1, a

; Define macro named as ``xyz'' with 2 mandatory parameters xyz macro foo, bar mov foo, #10h cpl bar endm xyz xyz a, c p0, p1.0 ; Expand macro ``xyz'' here ; Expand macro ``xyz'' here

Code 10 en exple of nmed mro with two prmeters

; This is the same as if you wrote this: ; xyz a, c mov a, #10h cpl c ; xyz p0, p1.0 mov p0, #10h cpl p1.0

58

CHAPTER 4. BUILD-IN MACRO-ASSEMBLER

Code 11 en exple of nmed mro used with if sttement


ijk macro add foo A, @R0 if foo = 4d nop endif endm ijk ijk subb 5 4 as if you wrote this: @R0 A, #foo

; This is the same ; ijk 5 add A, if 5 = 4d nop endif subb A, ; ijk 4 add A, if 4 = 4d nop endif subb A,

#5 @R0

#4

4.11. MACRO PROCESSING Code 12 en exple of nested mros

59

; Suppose we have these macros: abc macro mov a, p0 cpl a mov p1, a endm ijk macro foo add A, @R0 if foo = 4d nop endif endm xyz subb macro ijk ijk abc A, #foo foo, bar foo bar

endm

; And we expand ``xyz'' like this: xyz 4, 5 ; Then we get this result: ; ijk 4 add A, @R0 nop ; <-- Note this subb A, #4 ; ijk 5 add A, @R0 subb A, #5 ; abc mov a, p0 cpl a mov p1, a

abc macro ; Unnamed macro cannot be contained inside a named one times 2 mov a, p0 cpl a mov p1, a endm endm

Code 13 en exple of nested mrosD whih will not work

60

CHAPTER 4. BUILD-IN MACRO-ASSEMBLER

4.12 Reserved keywords


Table 4.9: Special instruction operands
$ A AB C DPTR PC R0..R7 Location counter Accumulator A/B register pair Carry ag (in PSW register) Data pointer Program counter Registers

Table 4.10: Instruction mnemonics


ACALL DEC JNZ MOVX RLC ADD DIV SJMP MUL RR ADDC DJNZ JNC NOP RRC AJMP INC CALL ORL SETB ANL JB JZ POP SUBB CJNE JBC LCALL PUSH SWAP CLR JC LJMP RET XCH CPL JMP MOV RETI XCHD DA JNB MOVC RL XRL

Table 4.11: Directives


BIT DATA DW ELSEIFNDEF FLAG IFNDEF NAME SKIP BSEG DB ELSE END IDATA INCLUDE NOLIST TIMES BYTE DBIT ELSEIF ENDIF IF ISEG ORG USING CODE DS ELSEIFDEF ENDM IFDEF LIST REPT XDATA CSEG DSEG ELSEIFN EQU IFN MACRO SET XSEG

Table 4.12: Expression operators


AND LE NOT EQ LOW OR GE LT SHL GT MOD SHR HIGH NE XOR

Table 4.13: Assembler controls


DA LI NOMACROSFIRST NOOBJECT NOSB PAGEWIDTH PRINT TITLE DATE LIST NOMO NOPAGING NOSYMBOLS PAGING PW TT EJ NOLI NOMOD NOPI OBJECT PI SB EJECT NOLIST NOMOD51 NOPRINT PAGELENGTH PL SYMBOLS

4.13. COMPATIBILITY WITH ASEM-51

61

4.13 Compatibility with ASEM-51


xot yet spei(edF

62

CHAPTER 4. BUILD-IN MACRO-ASSEMBLER

4.14 List File Format


gode listing serves s n dditionl informtion out the ssemled ode nd the progress of the ssemly proessF st ontins informtion out ll symols de(ned in the odeF here nd how were they were de(nedD wht re their vlues nd whether they were used in the odeF elso detiled inforE mtion out ll mros de(ned in the ode ndGor expnded in the odeF gonditionl ompiltion on(gurtionD instrution y odesD ddress spe reservtionsD inlusion of ode from nother (lesF end ll wrningsD errors nd notes generted during the ssemly y the ssemlerF here re ssemE ler ontrol sequenes whih lters formtting of the ode listing (leF hese ontrol sequenes will e disussed hereF pormt of ode listing generted y this ssemler is very similr to the one generted wetlink R ewSIF gode listing ontins entire soure ode whih ws ssemled ut with eh

Code 14 e simple ode listing


1 ; MCU 8051 IDE - Demostration code 2 ; Very simple code 3 4 ; Press F2 and F6 to run the program (start simulator and animate) 5 6 org 0h 7 0000 08 8 main: inc R0 0001 06 9 inc @R0 0002 B87FFB 10 cjne R0, #07Fh, main 0005 7800 11 mov R0, #0d 0007 80F7 12 sjmp main 13 14 end ASSEMBLY COMPLETE, NO ERRORS FOUND, NO WARNINGS demo0

line pre(xed with line numer nd some dditionl informtion whih will e explined lterF fesides the originl ode there is lso tle of symols de(ned during the ssemly unless it ws turned o'F gode listing is divided into pges seprted y form feed hrterD this ehvior my e ltered y ertin ssemler ontrol sequenes s well s pge height nd widthF ih line of ode listing whih ontins originl soure ode line my ontin eside line numer lso some dditionl informtion regrding the ompiltion of the given line of odeF uh dditionl informtion might look like this nd is omposed of these prtsX gontrol sequenes 'eting formt of the generted ode listingF

4.14. LIST FILE FORMAT Code 15 ixplntion ode listing formt


0055 0014 1122 001E E580 0020 F4 0021 F590

63
X data 55h l: inc A abc ; Expand macro abc here mov a, p0 cpl a mov p1, a

=1

18 33 35 36 37 38

+1 +1 +1 +1

vine numer vevel of (le inlusion vevel of mro expnsion eddress in ode memory whine ode or nother vlue to e stored in the ode memory lue of symol yriginl line

Table 4.14: Control sequences aecting code listing


$eject $list $nopaging $pagelength $date $noprint $ej $li $nopi $pl $da $symbols $nolist $paging $pagewidth $title $nosb $sb $noli $pi $pw $tt $nosymbols $print

Code 16 e more omplited exmple of ode listing


1 abc equ ( 14 * 2 ) ; Define symbol abc 2 org 0 ; Start writing code at address 0 3 =1 4 include 'my_macros.asm' ; Include file my_macros.asm =1 5 ; This is the beginning of file my_macros.asm =1 6 my_cpl macro foo =1 7 mov A, foo =1 8 cpl A =1 9 mov foo, A =1 10 endm =1 11 ; This is the end of file my_macros.asm 12 13 +1 main: my_cpl P0 ; Expand macro my_cpl here 0000 E580 14 +1 mov a, p0 0002 F4 15 +1 cpl a 0003 F580 16 +1 mov p0, a 0005 80F9 17 sjmp main ; Jump back to label main 18 end ; End of assembly ASSEMBLY COMPLETE, NO ERRORS FOUND, NO WARNINGS complicated_lst 001C

PA

64

CHAPTER 4. BUILD-IN MACRO-ASSEMBLER

4.15 Specication of Intel R 8 HEX Format


sntel R V ri is populr ojet (le formt ple of ontining up to TRkf of dtF rex (les hve usully extension .hex or .ihxF hese (les re text (les onsisting of sequene of reordsD eh line line n ontin t most one reordF eords strts with X @olonA hrter t the eginning of the line nd ends y end of the lineF iverything else esides reords should e ignoredF eords onsist of sequene of VEit hexdeiml numers @eFgF P or VAF hese numers re divided into (elds with di'erent meningD see the exmple elowF

Code 17 en exmple of n sntel


: : : : : : : : 0F 0F 0F 10 10 10 0B 00 0000 000F 001E 002D 003D 004D 005D 0000 00 00 00 00 00 00 00 01

V hex ode

E580F4F590E580F4F590E580F4F590 57 E580F4F590E580F4F590E580F4F590 48 E580F4F590E580F4F590E580F4F590 39 E580F4F5907410B3758010B2907410B3 30 758010B2902694052600940426940526 0A 00940426009404269405E580F4F59026 8A 009404269405E580F4F590 63 FF

trt ode fyte ount eddress eord type ht gheksum @two9s omplement of VEit sum of entire reordD exept for the strt ode nd the heksum itselfA eord types ville in sntel R V ri

00 01

ht reord ind of (le reord

65

Chapter 5 Disassembler
hisssemler is tool intended to generte ssemly lnguge ode from n ojet (leF sn other words it hs ertin level of pility of reversing the ssemly proess nd regining the originl soure ode from ny ojet odeF fut there re some restrition to tht pility nd the whole thing is not so simple fter llF o let9s disuss disssemly proess deeperF sn wg VHSI shi you n invoke disssemler from the min menu  Main Menu  Tools  DisassembleF
A simple example of a code generated by disassembler

Original code:
org main: inc inc cjne mov sjmp end

0h

; Start at address 0x00

Code generated by disassembler


ORG label0: inc inc cjne mov sjmp END 0h R0 @R0 R0, #7Fh, label0 R0, #0h label0

R0 ; Increment R0 @R0 R0, #07Fh, main R0, #0d ; main ; Jump back to label main ; End of assembly

es you n see from the exmple oveD the ode generted y disssemE ler is the sme s the originl odeF fut of ourse originl symol nmes hve vnished s well s ommentsD indenttion nd other tiny detils whih nnot e determined from the ojet odeF his is used y the simple ft tht the ojet ode ontins only the mhine odeF st ontins no inforE mtion regrding how extly the originl ode looked likeF tust instrutions with their opernds nd dt diretly written to the ode memory y hf nd h diretivesF end here we re getting to the rel prolem whih emerges every time when you try to disssemle not extly simple odeF VHSI instrutions omprises of ID P or Q ytesD the (rst yte determintes wht instrution re we deling with nd so wht is its length in ytesF fut

66

CHAPTER 5. DISASSEMBLER

if the originl ode ontined diretives hf or h then the disssemler thinks tht these vlues re instrutions tooF sf the disssemler onsider ritrry vlue given y hf or h instrution to e n instrutionD it determintes its length ording to its y ode @the Ist rgument to the diE retiveAF end so it tkes HD I or P ytes next nd interprets them s opernds to tht instrutionF hen when it enounters rel instrution y ode it might think of it s nother opernd to something nd so misinterpret itF hen you might end up with ode tht is ompletely di'erent from the originl ode nd mkes no sense t ll to humnF fut if you ressemle suh non sense ode with disled peep hole optimiztion you must get the originl ojet ode kD nd its funtionlity must not e hngedF iven if the ode seems to e solutely non senseF sn tht se s strongly reommend to use nother disssemler thn is the uiltEin oneF gonsider for exmple hSP http://www.8052.com/users/disasm/F he uiltEin dissemE ler is provided just for ompletenessD ut its suitility for rel reverse engineering is highly questionleF
A simple example of a BADLY generated code by disassembler

Original code:
org main: inc inc jmp db cjne mov sjmp end

0h

; Start at address 0x00

Code generated by disassembler


label0 CODE 11h ORG label1: inc inc ljmp jmp xrl xrl xrl jmp mov xrl xrl xrl mov mov mov sjmp END 0h R0 @R0 label0 @A+DPTR A, R7 A, R5 A, 20h @A+DPTR A, #72h A, R1 A, R6 A, @R1 R0, #0B8h R7, #0ECh R0, #0h label1

cont:

R0 ; Increment R0 @R0 cont 'some stringx' R0, #07Fh, main R0, #0d ; main ; Jump back to label main ; End of assembly

67

Chapter 6 MCU simulator


6.1 Short introduction
he wg simultor is tool designed to mimis ehvior of rel wg s muh s possileF fut it n hve ertin limittionsD the most expetle limittion is of ourse the speed of simultionF his simultor is very slowD ut o'ers some extr feturesF

6.2 Modes of simulation


here re R modes of simultionX

Step

ixeute extly one intrutionD no mtter how mny mhine yles it will tkeF his does not pply for mroEinstrutionD in tht se eh instrution of the mro is exeuted seprtelyF ixeute s mny instrutions s possile until simultor ursor hnges its lotion from one line of soure ode to notherF

Step over Animate Run

ho the sme s step ut in loopD one fter nother until stopped y wring ondition or user requestF his is generlly the sme s nimteD ut muh fsterD euse qs is not updted so o'ten s in the nimte modeF ke k the lst performed stepF here is limited numer of step whih n e tken kF

(Step Back)

irul r n e enled or disledD it signi(ntly 'ets speed of the simultionF yf ourse simultion is slower when virtul r is onF

68

CHAPTER 6. MCU SIMULATOR

6.3 Waring conditions



tk over)ow tk under)ow snvlid instrutions thdog over)ow snvlid return from interrupt eding from write only register snvlid ess to sheeGp snvlid ess to ihee snvlid ess to hee snvlid ess to it snvlid ess to gyhi iiyw write filure iiyw write ort e frme disrd sllegl e mode hnge sllegl imerGgounter mode hnge

6.4 Limitations
IF PF QF RF e simultion is limited in urrent version s simultion is not implemented imultion of redued power onsumption modes is not supported imulted wg is mny times slower the rel one would e on norml onditions

6.5. VIRTUAL HARDWARE

69

6.5 Virtual hardware


wg VHSI shi simultor is lso equipped with few simulted simple hrdE wre deviesD whih n e onneted to the simulted wgF hese virtul hrdwre omponents re intended primrily to o'er etter insight into progrms interting with things like vihs or keysF ell wires onneted to spei( qsy lines re olored ording to the voltge level present on themD olors re the sme s for grph in the otE tom pnel @GREEN aa logF HY RED aa logF IY GRAY aa not onnetedD etFA ih of these virtul r omponents hs its own on(gurtion menu nd help text ville trough tht menuF gon(gurtion n e sved to (le with extension .vhcD nd n e loded from tht (le lterF he onE (gurtion menu is essile trough the utton with this ionX  F he  ON / OFF  button enables or disables entire subsystem of virtual hardware simulation including the graph of GPIO wires on the bottom panel.

6.5.1 DS1620 temperature sensor


Simulates DALLAS
R

DS1620 thermometer along Tem-

with its 3-wire communication interface.

perature which this simulated device should measure can be set by used on the scale in DS1620 simulator window. All internal registers of the device are displayed to the user and are modiable by the user, current conguration of the device simulator including DS1620 non-volatile registers can be save into a le for further use. All communications with the simulated MCU and internal operation of the simulated thermometer are displayed in simulator log, log can be accessed via the DS1620 simulator conguration menu ( ).
Figure 6.1:

DS1620 simulator

and its log window

6.5.2 File interface


This tool can automatically switch states of GPIO lines of the simulated according to certain denition le and it can also record all changes occurring on arbiFigure 6.2: PALE I/O interface

trary GPIO line to a specied output le. This function can be particularly useful when you are dealing with a 8051 pro-

gram which extensively works with I/O ports.

70

CHAPTER 6. MCU SIMULATOR

6.5.3 LED Panel


This is the simplest example of such a virtual hardware component. with common anode. A simple panel consisting of 8 independent LEDs Each LED can be connected to separate port and pin and react immediately to any change in voltage level on that line. the Connections with
Figure 6.3: LED Panel

C are made with combo boxes on the

bottom side of the panel.

6.5.4 Single LED Display


Single 8 segment LED display with one decimal point. Common electrode for the LEDs can be congured as well as the LED color. Each LED can be independently connected to any port and pin and reacts immediately to any change in voltage level
Figure 6.4: LED Display

on that pin. or Vcc.

Common electrode is stati-

cally connected to either common ground

6.5.5 Multiplexed LED Display


4 digits LED displays indented for run in multiplexed mode, LEDs are fading with congurable delay. Each digit has its own common electrode which polarity is congurable, this common electrode is connected to output from an inverter or transistor. There are four color shades for each LED segment, one for inactive, one for active, one for fast blinking and one for segment which was recently dimmed, that makes it possible to see an image which would probably appear on a real display when viewed just by the eye. Unit for the fading interval is one instruction cycle.
Figure 6.5: M LED Display

6.5. VIRTUAL HARDWARE

71

6.5.6 LED Matrix


Simple one color 8 x 8 LED matrix indented for run in multiplexed mode, LEDs are fading with congurable delay. Everything here is the same as for the Multiplexed LED Display, except for one thing, mapping. Mapping can be set to row, column or random, which is default. Row mapping means that row which has been activated right now immediately forgets which LEDs were
Figure 6.6: LED Matrix

shinning last time and which were not. Column mapping is the same but for columns and random mapping means that each LED will dim af-

ter specied interval and not when its row or column is activated. So in random mapping you have to wait until all LEDs are gray before you can draw a new image without being aected by the last one.

6.5.7 Matrix Keypad


4 x 4 Matrix keypad, each row and column can be connected to any GPIO line. Connections with the

are

made with the combo boxes. button .


1

Keys

can be congured to behave as radio Note that this tool can be also used to interconnect some port pins together statically, like wires in a bread board. Any key press takes
Figure 6.7: Matrix Keypad

eect immediately in all other virtual hardware components connected to the same line.

1 Radio buttons that means that one one key can be pressed at the time and when you
press another key, the originally pressed key will return back to non pressed state

72

CHAPTER 6. MCU SIMULATOR

6.5.8 Simple Keypad


Array of 8 independent keys, each one of them can connect any GPIO line to the ground. Any key press takes eect immediately in all other virtual hardware components connected to the same line. Keys can also be congured to behave as radio
Figure 6.8: Simple Keypad

buttons.

6.5.9 LCD display controlled by HD44780


This tool simulates a HD44780 character LCD of any size up to 2 rows and 40 columns. There are 11 I/O lines serving as interface for the MCU, E, RS, User can view end modify content of the display data R/W and D0..D7.

RAM (DDRAM), the character generator RAM (CGRAM) and certain HD44780 registers: instruction register (IR), data register (DR), address counter (AC) and display shift, these registers are shown in hexadecimal representation. User can also view content of character generator ROM (CGROM) and set font to use. All of the driver commands are fully supported and all important events occurring in the simulated driver (HD44780) are recorded in the simulator log. User can also see and modify certain HD44780 conguration ags like B, S, D and so on. And the window is collapsible.

Figure 6.9: Simulated LCD display

Figure 6.10: HD44780 Log

Figure

6.11: Figure

6.12: Figure 6.13: View on CGROM

CGRAM

DDRAM

73

Chapter 7 Writing hardware tool control plug-ins


7.1 Foreword
It is not surprising that IDE for micro-controllers should be capable of inter-operation with certain hardware tools. MCU 8051 IDE has tool named HW plugins manager which is responsible for loading and managing plug-ins written in order to to integrate exiting hardware tools into this IDE. With this feature every author of a 8051 programmer, ICD, ICE etc. who knows Tcl/Tk language has the opportunity to make his or her own tool working in direct cooperation with the IDE. These plug-ins have to be written at least partially in the TCL language and use the Tk library along with API of MCU 8051 IDE. But that doesn't mean that they should be written entirely in Tcl/Tk. On the contrary I would encourage usage of another languages for example SSP89S, also a part of MCU 8051 IDE project, is written almost completely in C++/Qt4, but only a small piece of the software is written in Tcl/Tk. Tcl/Tk can easily inter-operate with C and C++, also it is possible to run arbitrary separate process from inside of Tcl/Tk program and control it vie for example TCP sockets or its stdin/stdout or something else.
Figure 7.1: An example of

HW control plug-in

74

7.2 How to write your own plug-in


At rst take these steps: 1.

CHAPTER 7. WRITING HARDWARE TOOL CONTROL PLUG-INS

Create the plug-in directory


On POSIX system the plug-in directory have to be placed in /usr/share/mcu8051ide/hwplugins, on Microsoft is <YourInstallationDirectory>\hwplugins. derscore) characters.
R

Windows

the directory

The plug-in directory must

carry the name of your plug-in, where spaces are replaced with  _ (unFor example suppose you want to create a plug-in named as My First Plug-in v1.0, then your plug-in directory directory is My_First_Plug-in_v1.0. 2.

Create the plug-in initialization le


Plug-in initialization le tells the IDE that there is some plug-in at all. The le contains basic initialization of the plug-in environment and must follow certain rules. The le name must also follow name of the plug-in in the same way as the plug-in directory. But the initialization le have to be placed in directory hwplugins. And must have extension plug-in directory is:

.tcl!

For example consider The

again our My First Plug-in v1.0 plug-in, as we mentioned before. in_v1.0 then the initialization le is: /usr/share/mcu8051ide/hwplugins/My_First_Plug-in_v1.0.tcl. 3.

/usr/share/mcu8051ide/hwplugins/My_First_Plug-

Dene mandatory variables


set set set set AUTHOR EMAIL P_VERSION MIN_IDE_VER "<your name>" "<your_email@example.com>" "<version_of_your_plug-in>" "1.1" ;# ;# ;# ;# e.g. "Homer Simpson" e.g. "superman.spiderman@supehero.ru" e.g. "1.2.3" or "0.9" Mimimal required version of MCU 8051 IDE

4.

Dene mandatory functions


# Free resources occupied by this plugin proc dispose {} { ... } # Initialize the plug-in proc init {main_frame current_namespace directory} { ... } # Restore previous session proc restore_session {session_data} { ... } # Save plug-in session proc save_session {} { ...; return <String> } # Is plugin busy ? proc is_busy {} { ...; return <BooleanValue> }

7.3. USING MCU 8051 IDE API

75

... means any code you want there. See /usr/share/mcu8051ide/hwplugins/plugin_template.txt or <YourInstallationDirectory>\hwplugins\plug-in_template.txt for more details and for a template for such le. When you have these steps completed you have prepared basic environment for the plug-in. Then the HW plug-ins manager in the right panel in IDE's If it Any other les which your GUI should now recognize your plug-in and be able to attempt to load it. is not so, then there is denitely something wrong. in directory (1).

plug-in consist of and just whatever you want there should be placed in your plugAnd the initialization le should do nothing else than source some real plug-in's le(s) and call appropriate functions inside them. important thing, the plug-in runs it One more Take it

dynamically assigned namespace.

into account, otherwise your plug-in wont work! Function init takes the name of this namespace in parameter current_namespace. So as you can see, it's quite easy you have just to dene 4 variables and 5 functions and you can interface with the IDE.

7.3 Using MCU 8051 IDE API


You can used any part the API you want, but the entire IDE's API is wast and may change in future without notice. So there is special API dedicated to use in hardware control plug-ins, it is located in  ::HwManager namespace and consists of merely 10 simple functions. This API is available since version 1.4. Here is the list of its functions:

## Check whether there is some project opened in the IDE # @return Bool - 1 == Yes, there is; 0 == No there is not proc is_project_opened {} ## Check whether MCU simulator is engaged # @return Bool - 0 == 1 == Yes, it is; No it is not (or no project is opened) proc is_simulator_engaged {} ## Get full name of file which is currently displayed in the source code editor # @return String - Full file name including path or empty string in case there is no project opened proc get_current_file {} ## Get full name of file which has been chosen as the project main file # @return String - Full file name or empty string proc get_project_main_file {} ## Get path the directory of currently active project # @return String - Directory path or empty string in case there is no project opened proc get_project_dir {} ## Get name of the current project # @return String - Name of the current project or empty string in case there is no project opened proc get_project_name {} ## Initiate compilation if at least one of the source files was modified

76

CHAPTER 7. WRITING HARDWARE TOOL CONTROL PLUG-INS

# @parm String success_callback - Any command to execute after successful compilation # @parm String failure_callback - Any command to execute after unsuccessful compilation # @return Bool - 1 == Process successfully started; 0 == Unable to comply (no project is opened) proc compile_if_nessesary_and_callback {success_callback failure_callback} ## Open the specified Intel R 8 hex file in hexadecimal editor # @parm String filename - Name of file to open (including path) # @return Bool - 1 == Success; 0 == Failure proc open_in_hexeditor {filename} ## Start MCU simulator if possible # @return Bool - 1 == Success; 0 == Unable to comply proc start_simulator {} ## Shutdown MCU simulator if possible # @return Bool - 1 == Success; 0 == Unable to comply proc shutdown_simulator {}

7.4 A basic example


Lets write just a simple plug-in which merely demonstrates usage of some of the above mentioned functions.

Figure 7.2: A basic example of a plug-in

set set set set

AUTHOR EMAIL P_VERSION MIN_IDE_VER

"Homer Simpson" "superman.spiderman@supehero.ru" "1.0" "1.3.11"

proc dispose {} { tk_messageBox \ -title "My First Plug-in" \ -message "Called: dispose {}" } proc init {main_frame project_object current_namespace directory} { pack [label $main_frame.l0 -text $current_namespace] -anchor w pack [label $main_frame.l1 -text $directory] -anchor w set f [labelframe $main_frame.f -text "My First Plug-in"] pack [label $f.l0 -text "is_project_opened : [::HwManager::is_project_opened]"] -anchor w

7.5. RANDOM REMARKS


pack pack pack pack pack [label [label [label [label [label $f.l1 $f.l2 $f.l3 $f.l4 $f.l5 -text -text -text -text -text "is_simulator_engaged : [::HwManager::is_simulator_engaged]"] -anchor w "get_current_file : [::HwManager::get_current_file]"] -anchor w "get_project_main_file : [::HwManager::get_project_main_file]"] -anchor w "get_project_dir : [::HwManager::get_project_dir]" ] -anchor w "l : [::HwManager::get_project_name]"] -anchor w

77

pack [ttk::button $f.b0 -text "update" -command " $f.l0 configure -text \"is_project_opened : \[::HwManager::is_project_opened\]\" $f.l1 configure -text \"is_simulator_engaged : \[::HwManager::is_simulator_engaged\]\" $f.l2 configure -text \"get_current_file : \[::HwManager::get_current_file\]\" $f.l3 configure -text \"get_project_main_file : \[::HwManager::get_project_main_file\]\" $f.l4 configure -text \"get_project_dir : \[::HwManager::get_project_dir\]\" $f.l5 configure -text \"get_project_name : \[::HwManager::get_project_name\]\" "] -anchor w pack $f -fill both -expand 1 pack [ttk::button $main_frame.b1 \ -text "start_simulator" \ -command {::HwManager::start_simulator} \ ] -side left pack [ttk::button $main_frame.b2 \ -text "shutdown_simulator" \ -command {::HwManager::shutdown_simulator} \ ] -side left

proc restore_session {session_data} { tk_messageBox \ -title "My First Plug-in" \ -message "Called: restore_session {$session_data}" } proc save_session {} { tk_messageBox \ -title "My First Plug-in" \ -message "Called: save_session {}" return "my data, time: [clock format [clock seconds] -format {%T}]" } proc is_busy {} { return [expr { [tk_messageBox \ -title "My First Plug-in" \ -message "Called: is_busy {}" \ -type {yesno} ] == {yes}}] }

7.5 Random remarks

Don't forget that your plug-in runs the main thread as well as the GUI of the entire IDE. So if your plug-in does some time expensive operations and it is probable that it does. Then these operations have to be performed in either separate thread or have to run in separate process. It is also possible to regularly update the application by reentering the event loop using Tcl's

update command.

Plug-in les must use encoding UTF-8 and should use LF (Line Feed) char-

78

CHAPTER 7. WRITING HARDWARE TOOL CONTROL PLUG-INS


acter as line end delimiter. In other words Unix line termination sequence.

Although it is possible to name the plug-in directory in any way what your OS accept. It is generally a good idea to follow the mentioned recommendation. At least the name of the initialization le have to follow the mentioned recommendation.

Plug-ins have unrestricted access to the entire application. So they should be written carefully, because plug-ins can theoretically crash down the entire IDE.

Program errors which occurs during loading or unloading of a plug-in are reported via a special dialog. email address are mentioned. In this dialog plug-in author and his or her

The above mentioned API provided by  ::HwManager is just a facade .


1

Before version 1.4 plug-ins must have had to be written to access directly the functionality currently hidden behind  ::HwManager, so it was much more complicated.

Each instance of a hardware plug-ins manager is bond to its project. But actual plug-ins don't have to be. That's the reason why there is function All functions inside the above men::HwManager::is_project_opened .

tioned API (::HwManager::*) works with the current project, not necessaryly with the project which is the HW manager bond with.

1 A design pattern as described in the GOF book

79

Chapter 8 Command Line Interface


MCU 8051 IDE's CLI makes it possible to use entire IDE just as an assembler, disassembler or converter between .hex les and binary les. MCU 8051 IDE supports these switches:

Switch
General
help, -h quiet, -q nosplash nocolor, -n version, -V defaults minimalized config-file filename check-libraries ignore-last-session open-project project reset-user-settings auto-indent input hex2bin input output bin2hex input output sim2hex input output sim2bin input output normalize-hex input disassemble hex_file assemble asm_file compile asm_file iram-size size code-size size xram-size size no-opt comp-quiet no-sim no-bin no-lst

Meaning
Show help for CLI Do not who initialization progress on start-up Do not show the splash screen Do not show colorful output in console Show program version and exit Ru program in empty session Run in minimalized window Specify path to an alternative conguration le Verify whether all required libraries are available Start with an empty session Open just this project Reset all user setting to defaults

Data conversions

Reformat indentation the specied le Convert Intel 8 Hex into a binary le Convert a binary le in Intel 8 HEX Convert MCU 8051 IDE simulator le to Intel 8 Hex le Convert MCU 8051 IDE simulator le to binary le Normalize Intel 8 HEX (force incremental addressing order)

Assembler/Disassembler
Disassemble Intel 8 HEX le to hex_le.asm Assemble the specied le The same as assemble Set size of internal data memory for assembler Set size of program data memory for assembler Set size of external data memory for assembler Disable peephole optimization Suppress text output from the assembler Disable generation of .adf le Disable generation of .bin le Disable generation of .lst le

80
no-hex warning-level

CHAPTER 8. COMMAND LINE INTERFACE Switch


Disable generation of .hex le 0-3 Set warning level to the specied level

Meaning

Interesting examples:

# Reset all IDE settings to defaults mcu8051ide --reset-user-settings # Use MCU 8051 IDE as assembler (without GUI) mcu8051ide --compile /some_directory/my_file.asm # Use MCU 8051 IDE as disssembler (without GUI) mcu8051ide --disassemble /some_directory/my_file.hex # Use MCU 8051 IDE as convertor from binary files to Intel 8 HEX (without GUI) mcu8051ide --bin2hex /some_directory/my_file /some_directory/my_file.hex

81

Chapter 9 Translating the IDE into dierent languages


The IDE can be translated to almost any language. The translation can be acSuch a le must follow Windows the complished by creating of a translation denition le. certain strict rules in order to work properly. Translation les are normally located in directory /usr/share/mcu8051ide/translations, on Microsoft directory is <YourInstallationDirectory>\translations.
R R

There you can nd le

template.txt which is template of MCU 8051 IDE translation le. Along with it there is also le languages.txt which denes names of languages to which the IDE was already translated. These names are written in these languages. Translation les look like this ru.msg (Russian translation) or cs.msg (Czech translation), these les need to be regularly updated. Note also that these les are quite big, each about 0.5MB and each contains about 4500 translated sentences. Further details regarding the translation are mentioned directly in the les related to translation, particularly in le template.txt. Refer to them if you are interested in making your own translation of the IDE. This is an open-source project so any help is appreciated. The rst several lines in le template.txt:

# # # # # # # # # # # # #

This is a template of MCU 8051 IDE translation file This file allows to localize the the user environment of the IDE to almost any language. HOW TO MAKE IT WORK: 1) Copy this file (template.txt) to <lang_code>.msg in the same directory. Where ``<lang_code>'' is supposed to be replaced with language code of the translation. For example ``ru'' means Russian, or ``cs'' means Czech. The language code must be lowercase. 2) Translate all sentences enclosed by ``'' (paragraph) character. And be sure to remove the ``'' character. 3) Modify file ``languages.tcl'' and add name of language which you are

CHAPTER 9. TRANSLATING THE IDE INTO DIFFERENT 82 LANGUAGES


# making the translation for. Name should be specified in that language. # # IMPORTANT RULES FOR TRANSLATION: # 1) Be aware of that this file is very sensitive. # 2) Everything besides actual sentences for translation must not be modified # in any way! Otherwise the file might cause serious program instability. # 3) Escape sequences and all special characters must be preserved. # 4) Sentences enclosed with ``"'' (double quote) character, can be translated # into sentences with different length. But the same does not apply for # sentences enclosed with ``{'' and ``}'' (curly brackets) characters, # their lengths must stay preserved. # 5) Do not translate ``$'' dollar symbol, it has a special meaning here, not # related to currency. # 6) Keep UTF-8 encoding and if possible, please keep also Unix line ends. # # NOTES: # 1) `` ;# <-- NOT TRANSLATED YET'' is just a comment and can be removed at # any time # 2) Nothing is perfect ... if you find anything strange or not functional # here, please report it as a regular bug. # 3) Recommended syntax highlight pattern for this file is "Tcl/Tk" # 4) Please don't hesitate to ask any questions. # # Thank you for your cooperation, which helps us make the software better! #

A random piece of the translation denition le template

mcset $l "Replace all" \ "Replace all" ;# <-- NOT TRANSLATED YET mcset $l "Find next" \ "Find next" ;# <-- NOT TRANSLATED YET mcset $l "Close" \ "Close" ;# <-- NOT TRANSLATED YET mcset $l "Replace confirmation - %s" \ "Replace confirmation - %s" ;# <-- NOT TRANSLATED YET mcset $l "Go to line" \ "Go to line" ;# <-- NOT TRANSLATED YET mcset $l "Ok" \ "Ok" ;# <-- NOT TRANSLATED YET mcset $l "Cancel" \ "Cancel" ;# <-- NOT TRANSLATED YET mcset $l "Go to line - MCU 8051 IDE" \ "Go to line - MCU 8051 IDE" ;# <-- NOT TRANSLATED YET mcset $l "Choose directory - MCU 8051 IDE" \ "Choose directory - MCU 8051 IDE" ;# <-- NOT TRANSLATED YET

83

Appendix A License
MCU 8051 IDE and all its components is distributed under terms of GNU GPLv2.
GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundations software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each authors protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyones free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Programs source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that whole or in part contains or is part thereof, to be licensed as parties under the terms of this you distribute or publish, that in derived from the Program or any a whole at no charge to all third License.

c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,

84
c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions

APPENDIX A. LICENSE
either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the programs name and a brief idea of what it does.> Copyright (C) 19yy <name of author> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w. This is free software, and you are welcome to redistribute it under certain conditions; type `show c for details. The hypothetical commands `show w and `show c should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w and `show c; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision (which makes passes at compilers) written by James Hacker. <signature of Ty Coon>, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License.

85

Appendix B Regression testing


B.1 Foreword
The IDE is featured with a regression testing environment, the aim of this to make the software as reliable as possible. Currently there is prepared environment for testing the simulator engine and the builtin assembler. This allows to write test cases for specic software features and check whether the results of these tests conform to expected results. the test cases are Regretfully
Figure B.1:

Assembler regression test

YET.

NOT PREPARED

run in terminal emulator

Each time when a change is made

to the IDE's code, these regression test should be run in order to detect possible bug introductions caused by recent changes. Regression test also serves as a proof of certain software functionality and reliability.

B.2 More about the implementation


Additional details can be found in the MCU 8051 IDE development snapshot downloaded from the project's GIT repository in directory regression_tests in various README les. Here we will mention just general overview. Each test have its own directory, like 'test_something' or 'another_test', let's call this directory the test directory. Each test consist of a set of test cases. Each test case should test one and only one specic function of the tested software. Test cases are represented by les with extension 'testcases' inside the test directory. Directory results inside the test directory should be left empty. It is used by the testing environment for storing temporary les generated during the tests. The

.in

located in directory named

86

APPENDIX B. REGRESSION TESTING

testcases directory also contains les intended for comparison with les generated during the test and stored in the results directory, these les must have extension .<x>.exp. Where <x> must be substituted with extension of a le which this le is supposed to be compared to. In another words, if I want to check whether for example ./results/something.abc was generated as it should be, I have to create le ./testcases/something.abc.exp and this le will be automatically compared with ./results/something.abc. And that's it! This is simple, isn't it? It's just about comparing les. But how are the tests run and how the les in the results directory gets generated? For that we need some Bash script, which is used to run the test, let's call this script the runtest script. The runtest script must be located in the test directory and must include the rte.lib.sh le, using the source command (or '.' command). This script should have set permissions to be executable and this script species how exactly should be the test performed and also runs the test itself. When the script is about to exit, this condition is trapped and the 'rte.lib.sh' reacts by starting the test. So there is no need to explicitly run the test by invoking some function or something like that. It runs the test automatically when there is nothing else left to do.

87

Appendix C Project web page and other media


C.1 Ocial project web page
Ocial web page of the MCU 8051 IDE project provides basic presentation of the project. Contains news about the project development, users comments and forums for users. Also the project's hardware tools are described here and there is some personal information about authors of the project. All components of the IDE can be downloaded from sourceforge.net, which provides hosting for the web pages and entire project. The address is

http://mcu8051ide.sf.net.

Figure C.1: Ocial web page of the MCU 8051 IDE project

88 APPENDIX C. PROJECT WEB PAGE AND OTHER MEDIA

C.2 Other media


Project has also its own page on Source Forge, ohloh and Fresh meat. Installation packages are in ocial Fedora repositories and Ubuntu repositories. There is currently also one Gentoo overlay providing ebuild for the IDE. Project has its own IRC channel, although it is rarely used. And wiki pages. Not yet in a good shape. Project is also mentioned on Wikipedia. Project ocial web page is written in PHP5, XHTML-1.1, CSS2 and JavaScript and uses MySQL as database. Volunteers who would like to improve the web page are also welcomed as contributors to the project.

C.3 GIT repository


GIT is a distributed revision control system originally developed by Linus Torvalds. MCU 8051 IDE also takes advantage of GIT and uses it as its tool for managing current development version. The project's GIT repository is hosted by Source Forge and is available at address  git://mcu8051ide.git.sourceforge.net/gitroot/mcu8051ide/mcu8051ide. Access to the repository is for reading only unless you posses the required clearance. In the GIT repository you can always nd the newest development version with the newest bug xes and features. List of latest changes is available on

//mcu8051ide.git.sourceforge.net.
1. Install GIT 2. Run  git

http:

Here is a short description to download

and install the latest development version of the IDE:

clone git://mcu8051ide.git.sourceforge.net/gitroot/mcu8051ide/mcu8051ide.

It will create your own copy of the Git repository in the current directory. 3. Once you have an existing copy of the repository you can just update it each time when you want the fresh version by this command:  git

fetch origin master

4. Then you can try the downloaded IDE version without installation using the following sequence of commands (for POSIX only) (a) (b)

cd mcu8051ide/lib ./main.tcl

5. Or install it and the use it using the following sequence of commands (for POSIX only) (a) (b) (c) (d)

cd mcu8051ide ./configure && make sudo su # or just "su" make install

89

Appendix D 8051 Instructions in numerical Order


Opcode
0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1A 0x1B 0x1C 0x1D 0x1E 0x1F 0x20 0x21

Mnemonic
code11 code16 A A data @R0 @R1 R0 R1 R2 R3 R4 R5 R6 R7 bit code11 code16 A A data @R0 @R1 R0 R1 R2 R3 R4 R5 R6 R7 bit code11

Operands

Bytes
1 2 3 1 1 2 1 1 1 1 1 1 1 1 1 1

Flags

Cycles
1 2 2 1 P 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2

NOP AJMP LJMP RR INC INC INC INC INC INC INC INC INC INC INC INC JBC ACALL LCALL RRC DEC DEC DEC DEC DEC DEC DEC DEC DEC DEC DEC DEC JB AJMP

code8

3 2 3 1 1 2 1 1 1 1 1 1 1 1 1 1 CY P P

1 1 1 1 1 1 1 1 1 1 1 1 1 2 2

code8

3 2

90
0x22 0x23 0x24 0x25 0x26 0x27 0x28 0x29 0x2A 0x2B 0x2C 0x2D 0x2E 0x2F 0x30 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x3A 0x3B 0x3C 0x3D 0x3E 0x3F 0x40 0x41 0x42 0x43 0x44 0x45 0x46 0x47 0x48 0x49 0x4A 0x4B 0x4C 0x4D 0x4E 0x4F 0x50 0x51 0x52 0x53 0x54 0x55 0x56 0x57 0x58

APPENDIX D. 8051 INSTRUCTIONS IN NUMERICAL ORDER


Opcode
RL ADD ADD ADD ADD ADD ADD ADD ADD ADD ADD ADD ADD JNB ACALL RETI RLC ADDC ADDC ADDC ADDC ADDC ADDC ADDC ADDC ADDC ADDC ADDC ADDC JC AJMP ORL ORL ORL ORL ORL ORL ORL ORL ORL ORL ORL ORL ORL ORL JNC ACALL ANL ANL ANL ANL ANL ANL ANL A A A A A A A A A A A A A code8 code11 data data A A A A A A A A A A A A code8 code11 data data A A A A A A #imm8 #imm8 data @R0 @R1 R0 A #imm8 #imm8 data @R0 @R1 R0 R1 R2 R3 R4 R5 R6 R7 #imm8 data @R0 @R1 R0 R1 R2 R3 R4 R5 R6 R7

Mnemonic
A A A A A A A A A A A A A bit code11

Operands
#imm8 data @R0 @R1 R0 R1 R2 R3 R4 R5 R6 R7 code8

Bytes
1 1 2 2 1 1 1 1 1 1 1 1 1 1 3 2 1 1 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 3 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 3 2 2 1 1 1 CY CY CY CY CY CY CY CY CY CY CY CY CY CY CY CY CY CY CY CY CY CY CY CY CY

Flags
AC AC AC AC AC AC AC AC AC AC AC AC OV OV OV OV OV OV OV OV OV OV OV OV

Cycles
2 1 P P P P P P P P P P P P 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 P 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 2 P P P P P P P P P P P P 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 2 P P P P P 1 1 1 1 1

RET

AC AC AC AC AC AC AC AC AC AC AC AC

OV OV OV OV OV OV OV OV OV OV OV OV

P P P P P P P P P P P P

91
Opcode
0x59 0x5A 0x5B 0x5C 0x5D 0x5E 0x5F 0x60 0x61 0x62 0x63 0x64 0x65 0x66 0x67 0x68 0x69 0x6A 0x6B 0x6C 0x6D 0x6E 0x6F 0x70 0x71 0x72 0x73 0x74 0x75 0x76 0x77 0x78 0x79 0x7A 0x7B 0x7C 0x7D 0x7E 0x7F 0x80 0x81 0x82 0x83 0x84 0x85 0x86 0x87 0x88 0x89 0x8A 0x8B 0x8C 0x8D 0x8E 0x8F

Mnemonic
A A A A A A A code8 code11 data data A A A A A A A A A A A A code8 code11 C

Operands
R1 R2 R3 R4 R5 R6 R7

Bytes
1 1 1 1 1 1 1 2 2

Flags

Cycles
P P P P P P P 1 1 1 1 1 1 1 2 2 1 2 P P P P P P P P P P P P 1 1 1 1 1 1 1 1 1 1 1 1 2 2

ANL ANL ANL ANL ANL ANL ANL JZ AJMP XRL XRL XRL XRL XRL XRL XRL XRL XRL XRL XRL XRL XRL XRL JNZ ACALL ORL JMP MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV SJMP AJMP ANL MOVC DIV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV

A #imm8 #imm8 data @R0 @R1 R0 R1 R2 R3 R4 R5 R6 R7

2 3 2 2 1 1 1 1 1 1 1 1 1 1 2 2

bit #imm8 #imm8 #imm8 #imm8 #imm8 #imm8 #imm8 #imm8 #imm8 #imm8 #imm8 #imm8

2 1 2 3 2 2 2 2 2 2 2 2 2 2 2 2

CY P

2 2 1 2 1 1 1 1 1 1 1 1 1 1 2 2

@A+DPTR A data @R0 @R1 R0 R1 R2 R3 R4 R5 R6 R7 code8 code11 C A AB data data data data data data data data data data data data @R0 @R1 R0 R1 R2 R3 R4 R5 R6 R7 bit @A+PC

2 1 1 3 2 2 2 2 2 2 2 2 2 2

CY P CY OV P

2 2 4 2 2 2 2 2 2 2 2 2 2 2

92
0x90 0x91 0x92 0x93 0x94 0x95 0x96 0x97 0x98 0x99 0x9A 0x9B 0x9C 0x9D 0x9E 0x9F 0xA0 0xA1 0xA2 0xA3 0xA4 0xA5 0xA6 0xA7 0xA8 0xA9 0xAA 0xAB 0xAC 0xAD 0xAE 0xAF 0xB0 0xB1 0xB2 0xB3 0xB4 0xB5 0xB6 0xB7 0xB8 0xB9 0xBA 0xBB 0xBC 0xBD 0xBE 0xBF 0xC0 0xC1 0xC2 0xC3 0xC4 0xC5 0xC6

APPENDIX D. 8051 INSTRUCTIONS IN NUMERICAL ORDER


Opcode Mnemonic
DPTR code11 bit A A A A A A A A A A A A A C code11 C DPTR AB @R0 @R1 R0 R1 R2 R3 R4 R5 R6 R7 C code11 bit C A A @R0 @R1 R0 R1 R2 R3 R4 R5 R6 R7 data code11 bit C A A A data @R0 #imm8 data #imm8 #imm8 #imm8 #imm8 #imm8 #imm8 #imm8 #imm8 #imm8 #imm8 code8 code8 code8 code8 code8 code8 code8 code8 code8 code8 code8 code8 data data data data data data data data data data /bit bit C @A+DPTR #imm8 data @R0 @R1 R0 R1 R2 R3 R4 R5 R6 R7 /bit

Operands
#imm16

Bytes
3 2 2 1 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 1 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 1 1 2 1 CY CY CY CY CY CY CY CY CY CY CY CY CY CY CY CY CY

Flags

Cycles
2 2 2 P 2 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 2 OV P 4 2 2 2 2 2 2 2 2 2 2 2 2 1 1

MOV ACALL MOV MOVC SUBB SUBB SUBB SUBB SUBB SUBB SUBB SUBB SUBB SUBB SUBB SUBB ORL AJMP MOV INC MUL Invalid opcode MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV ANL ACALL CPL CPL CJNE CJNE CJNE CJNE CJNE CJNE CJNE CJNE CJNE CJNE CJNE CJNE PUSH AJMP CLR CLR SWAP XCH XCH

AC AC AC AC AC AC AC AC AC AC AC AC

OV OV OV OV OV OV OV OV OV OV OV OV

P P P P P P P P P P P P

CY CY CY CY CY CY CY CY CY CY CY CY

2 2 2 2 2 2 2 2 2 2 2 2 2 2 1

CY P P

1 1 1 1

93
Opcode
0xC7 0xC8 0xC9 0xCA 0xCB 0xCC 0xCD 0xCE 0xCF 0xD0 0xD1 0xD2 0xD3 0xD4 0xD5 0xD6 0xD7 0xD8 0xD9 0xDA 0xDB 0xDC 0xDD 0xDE 0xDF 0xE0 0xE1 0xE2 0xE3 0xE4 0xE5 0xE6 0xE7 0xE8 0xE9 0xEA 0xEB 0xEC 0xED 0xEE 0xEF 0xF0 0xF1 0xF2 0xF3 0xF4 0xF5 0xF6 0xF7 0xF8 0xF9 0xFA 0xFB 0xFC 0xFD

Mnemonic
A A A A A A A A A data code11 bit C A data A A R0 R1 R2 R3 R4 R5 R6 R7 A code11 A A A A A A A A A A A A A A @DPTR code11 @R0 @R1 A data @R0 @R1 R0 R1 R2 R3 R4 R5

Operands
@R1 R0 R1 R2 R3 R4 R5 R6 R7

Bytes
1 1 1 1 1 1 1 1 1 2 2 2 1 1

Flags

Cycles
P P P P P P P P P 1 1 1 1 1 1 1 1 1 2 2 1

XCH XCH XCH XCH XCH XCH XCH XCH XCH POP ACALL SETB SETB DA DJNZ XCHD XCHD DJNZ DJNZ DJNZ DJNZ DJNZ DJNZ DJNZ DJNZ MOVX AJMP MOVX MOVX CLR MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOVX ACALL MOVX MOVX CPL MOV MOV MOV MOV MOV MOV MOV MOV MOV

CY CY P P P

1 1 2 1 1 2 2 2 2 2 2 2 2 P P P P P P P P P P P P P P P 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 P 1 1 1 1 1 1 1 1 1 1

code8 @R0 @R1 code8 code8 code8 code8 code8 code8 code8 code8 @DPTR @R0 @R1 data @R0 @R1 R0 R1 R2 R3 R4 R5 R6 R7 A A A A A A A A A A A A

3 1 1 2 2 2 2 2 2 2 2 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1

94
0xFE 0xFF

APPENDIX D. 8051 INSTRUCTIONS IN NUMERICAL ORDER


Opcode Mnemonic
R6 R7

Operands
A A

Bytes
1 1

Flags

Cycles
1 1

MOV MOV

Table D.1: 8051 Instructions in numerical Order

95

Appendix E 8051 Instructions in alphabetical order


Opcode
0x11 0x31 0x51 0x71 0x91 0xB1 0xD1 0xF1 0x24 0x25 0x26 0x27 0x28 0x29 0x2A 0x2B 0x2C 0x2D 0x2E 0x2F 0x34 0x35 0x36 0x37 0x38 0x39 0x3A 0x3B 0x3C 0x3D 0x3E 0x3F 0x01 0x21

Mnemonic
code11 code11 code11 code11 code11 code11 code11 code11 A A A A A A A A A A A A A A A A A A A A A A A A code11 code11

Operands

Bytes
2 2 2 2 2 2 2 2

Flags

Cycles
2 2 2 2 2 2 2 2

ACALL ACALL ACALL ACALL ACALL ACALL ACALL ACALL ADD ADD ADD ADD ADD ADD ADD ADD ADD ADD ADD ADD ADDC ADDC ADDC ADDC ADDC ADDC ADDC ADDC ADDC ADDC ADDC ADDC AJMP AJMP

#imm8 data @R0 @R1 R0 R1 R2 R3 R4 R5 R6 R7 #imm8 data @R0 @R1 R0 R1 R2 R3 R4 R5 R6 R7

2 2 1 1 1 1 1 1 1 1 1 1 2 2 1 1 1 1 1 1 1 1 1 1 2 2

CY CY CY CY CY CY CY CY CY CY CY CY CY CY CY CY CY CY CY CY CY CY CY CY

AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC

OV OV OV OV OV OV OV OV OV OV OV OV OV OV OV OV OV OV OV OV OV OV OV OV

P P P P P P P P P P P P P P P P P P P P P P P P

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2

APPENDIX E. 8051 INSTRUCTIONS IN ALPHABETICAL 96 ORDER


Opcode
0x41 0x61 0x81 0xA1 0xC1 0xE1 0x52 0x53 0x54 0x55 0x56 0x57 0x58 0x59 0x5A 0x5B 0x5C 0x5D 0x5E 0x5F 0x82 0xB0 0xB4 0xB5 0xB6 0xB7 0xB8 0xB9 0xBA 0xBB 0xBC 0xBD 0xBE 0xBF 0xC2 0xC3 0xE4 0xB2 0xB3 0xF4 0xD4 0x14 0x15 0x16 0x17 0x18 0x19 0x1A 0x1B 0x1C 0x1D 0x1E 0x1F 0x84 0xD5

Mnemonic
code11 code11 code11 code11 code11 code11 data data A A A A A A A A A A A A C C A A @R0 @R1 R0 R1 R2 R3 R4 R5 R6 R7 bit C A bit C A A A data @R0 @R1 R0 R1 R2 R3 R4 R5 R6 R7 AB data

Operands

Bytes
2 2 2 2 2 2

Flags

Cycles
2 2 2 2 2 2

AJMP AJMP AJMP AJMP AJMP AJMP ANL ANL ANL ANL ANL ANL ANL ANL ANL ANL ANL ANL ANL ANL ANL ANL CJNE CJNE CJNE CJNE CJNE CJNE CJNE CJNE CJNE CJNE CJNE CJNE CLR CLR CLR CPL CPL CPL DA DEC DEC DEC DEC DEC DEC DEC DEC DEC DEC DEC DEC DIV DJNZ

A #imm8 #imm8 data @R0 @R1 R0 R1 R2 R3 R4 R5 R6 R7 bit /bit #imm8 data #imm8 #imm8 #imm8 #imm8 #imm8 #imm8 #imm8 #imm8 #imm8 #imm8 code8 code8 code8 code8 code8 code8 code8 code8 code8 code8 code8 code8

2 3 2 2 1 1 1 1 1 1 1 1 1 1 2 2 3 3 3 3 3 3 3 3 3 3 3 3 2 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 CY OV P CY CY P P P CY P CY CY CY CY CY CY CY CY CY CY CY CY CY CY P P P P P P P P P P P P

1 2 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 2

code8

97
Opcode
0xD8 0xD9 0xDA 0xDB 0xDC 0xDD 0xDE 0xDF 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F 0xA3 0x20 0x10 0x40 0x73 0x30 0x50 0x70 0x60 0x12 0x02 0x74 0x75 0x76 0x77 0x78 0x79 0x7A 0x7B 0x7C 0x7D 0x7E 0x7F 0x85 0x86 0x87 0x88 0x89 0x8A 0x8B 0x8C 0x8D 0x8E 0x8F 0x90

Mnemonic
R0 R1 R2 R3 R4 R5 R6 R7 A data @R0 @R1 R0 R1 R2 R3 R4 R5 R6 R7 DPTR bit bit code8

Operands
code8 code8 code8 code8 code8 code8 code8 code8

Bytes
2 2 2 2 2 2 2 2 1 2 1 1 1 1 1 1 1 1 1 1 1

Flags

Cycles
2 2 2 2 2 2 2 2 P 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 P 1 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2

DJNZ DJNZ DJNZ DJNZ DJNZ DJNZ DJNZ DJNZ INC INC INC INC INC INC INC INC INC INC INC INC INC JB JBC JC JMP JNB JNC JNZ JZ LCALL LJMP MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV

code8 code8

3 3 2 1

@A+DPTR bit code8 code8 code8 code16 code16 A data @R0 @R1 R0 R1 R2 R3 R4 R5 R6 R7 data data data data data data data data data data data DPTR #imm8 #imm8 #imm8 #imm8 #imm8 #imm8 #imm8 #imm8 #imm8 #imm8 #imm8 #imm8 data @R0 @R1 R0 R1 R2 R3 R4 R5 R6 R7 #imm16 code8

3 2 2 2 3 3 2 3 2 2 2 2 2 2 2 2 2 2 3 2 2 2 2 2 2 2 2 2 2 3

APPENDIX E. 8051 INSTRUCTIONS IN ALPHABETICAL 98 ORDER


Opcode
0x92 0xA2 0xA6 0xA7 0xA8 0xA9 0xAA 0xAB 0xAC 0xAD 0xAE 0xAF 0xE5 0xE6 0xE7 0xE8 0xE9 0xEA 0xEB 0xEC 0xED 0xEE 0xEF 0xF5 0xF6 0xF7 0xF8 0xF9 0xFA 0xFB 0xFC 0xFD 0xFE 0xFF 0x83 0x93 0xE0 0xE2 0xE3 0xF0 0xF2 0xF3 0xA4 0x00 0x42 0x43 0x44 0x45 0x46 0x47 0x48 0x49 0x4A 0x4B 0x4C

Mnemonic
bit C @R0 @R1 R0 R1 R2 R3 R4 R5 R6 R7 A A A A A A A A A A A data @R0 @R1 R0 R1 R2 R3 R4 R5 R6 R7 A A A A A @DPTR @R0 @R1 AB data data A A A A A A A A A

Operands
C bit data data data data data data data data data data data @R0 @R1 R0 R1 R2 R3 R4 R5 R6 R7 A A A A A A A A A A A @A+PC @A+DPTR @DPTR @R0 @R1 A A A

Bytes
2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Flags
CY

Cycles
2 1 2 2 2 2 2 2 2 2 2 2 P P P P P P P P P P P 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 P P P P P 2 2 2 2 2 2 2 2

MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV MOVC MOVC MOVX MOVX MOVX MOVX MOVX MOVX MUL NOP ORL ORL ORL ORL ORL ORL ORL ORL ORL ORL ORL

CY

OV

4 1 1 2

A #imm8 #imm8 data @R0 @R1 R0 R1 R2 R3 R4

2 3 2 2 1 1 1 1 1 1 1 P P P P P P P P P

1 1 1 1 1 1 1 1 1

99
Opcode
0x4D 0x4E 0x4F 0x72 0xA0 0xD0 0xC0 0x22 0x32 0x23 0x33 0x03 0x13 0xD2 0xD3 0x80 0x94 0x95 0x96 0x97 0x98 0x99 0x9A 0x9B 0x9C 0x9D 0x9E 0x9F 0xC4 0xC5 0xC6 0xC7 0xC8 0xC9 0xCA 0xCB 0xCC 0xCD 0xCE 0xCF 0xD6 0xD7 0x62 0x63 0x64 0x65 0x66 0x67 0x68 0x69 0x6A 0x6B 0x6C 0x6D 0x6E

Mnemonic
A A A C C data data

Operands
R5 R6 R7 bit /bit

Bytes
1 1 1 2 2 2 2 1 1

Flags

Cycles
P P P 1 1 1 2 2 2 2 2 2 1

ORL ORL ORL ORL ORL POP PUSH RET RETI RL RLC RR RRC SETB SETB SJMP SUBB SUBB SUBB SUBB SUBB SUBB SUBB SUBB SUBB SUBB SUBB SUBB SWAP XCH XCH XCH XCH XCH XCH XCH XCH XCH XCH XCH XCHD XCHD XRL XRL XRL XRL XRL XRL XRL XRL XRL XRL XRL XRL XRL

CY CY

A A A A bit C code8 A A A A A A A A A A A A A A A A A A A A A A A A A A data data A A A A A A A A A A A data @R0 @R1 R0 R1 R2 R3 R4 R5 R6 R7 @R0 @R1 A #imm8 #imm8 data @R0 @R1 R0 R1 R2 R3 R4 R5 R6 #imm8 data @R0 @R1 R0 R1 R2 R3 R4 R5 R6 R7

1 1 1 1 2 1 2 2 2 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 2 3 2 2 1 1 1 1 1 1 1 1 1 P P P P P P P P P P P P P P P P P P P P P P P P CY CY CY CY CY CY CY CY CY CY CY CY AC AC AC AC AC AC AC AC AC AC AC AC OV OV OV OV OV OV OV OV OV OV OV OV P P P P P P P P P P P P CY CY P CY P

1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1

APPENDIX E. 8051 INSTRUCTIONS IN ALPHABETICAL 100 ORDER


Opcode
0x6F 0xA5

Mnemonic
A

Operands
R7

Bytes
1

Flags

Cycles
P 1

XRL Invalid opcode

Table E.1: 8051 Instructions in lexical Order

101

Appendix F List of supported micro-controllers


F.0.1 Intel
8051 80C51 8052

http://download.intel.com/design/MCS51/MANUALS/27238302.pdf http://download.intel.com/design/MCS51/MANUALS/27238302.pdf http://download.intel.com/design/MCS51/MANUALS/27238302.pdf


R

F.0.2 Atmel
AT89C2051 AT89C4051 AT89C51 AT89C51RC AT89C52 AT89C55WD AT89LV51 AT89LV52 AT89LV55

Flash (Reprogramable)

http://www.atmel.com/dyn/resources/prod_documents/doc0368.pdf http://www.atmel.com/dyn/resources/prod_documents/doc1001.pdf http://www.atmel.com/dyn/resources/prod_documents/doc0265.pdf http://www.atmel.com/dyn/resources/prod_documents/doc1920.pdf http://www.atmel.com/dyn/resources/prod_documents/doc0313.pdf http://www.atmel.com/dyn/resources/prod_documents/doc1921.pdf http://www.atmel.com/dyn/resources/prod_documents/doc0303.pdf http://www.atmel.com/dyn/resources/prod_documents/doc0375.pdf http://www.atmel.com/dyn/resources/prod_documents/doc0811.pdf http://www.atmel.com/dyn/resources/prod_documents/doc1919.pdf http://www.atmel.com/dyn/resources/prod_documents/doc3053.pdf http://www.atmel.com/dyn/resources/prod_documents/doc2601.pdf http://www.atmel.com/dyn/resources/prod_documents/doc3286.pdf http://www.atmel.com/dyn/resources/prod_documents/doc3390.pdf http://www.atmel.com/dyn/resources/prod_documents/doc3390.pdf http://www.atmel.com/dyn/resources/prod_documents/doc3c0c80904bc57.pdf http://www.atmel.com/dyn/resources/prod_documents/doc3c0c80904bc57.pdf http://www.atmel.com/dyn/resources/prod_documents/doc4184.pdf http://www.atmel.com/dyn/resources/prod_documents/doc4184.pdf http://www.atmel.com/dyn/resources/prod_documents/doc4184.pdf http://www.atmel.com/dyn/resources/prod_documents/doc4431.pdf

Flash ISP (Programable via ISP)


AT89S52 AT89LS51 AT89LS52 AT89S8253 AT89S2051 AT89S4051

OTP (One-Time Programmable)


T87C5101 T83C5101 AT80C32X2 TS87C52X2 AT87C52X2 AT80C54X2

102
ROM

APPENDIX F. LIST OF SUPPORTED MICRO-CONTROLLERS

T83C5102 TS80C32X2 TS80C52X2 AT80C58X2 AT87C54X2 AT87C58X2 TS80C54X2 TS80C58X2 TS87C54X2 AT80C52X2 TS87C58X2

http://www.atmel.com/dyn/resources/prod_documents/doc3c0c80904bc57.pdf http://www.atmel.com/dyn/resources/prod_documents/doc4184.pdf http://www.atmel.com/dyn/resources/prod_documents/doc4184.pdf http://www.atmel.com/dyn/resources/prod_documents/doc4431.pdf http://www.atmel.com/dyn/resources/prod_documents/doc4431.pdf http://www.atmel.com/dyn/resources/prod_documents/doc4431.pdf http://www.atmel.com/dyn/resources/prod_documents/doc4431.pdf http://www.atmel.com/dyn/resources/prod_documents/doc4431.pdf http://www.atmel.com/dyn/resources/prod_documents/doc4431.pdf http://www.atmel.com/dyn/resources/prod_documents/doc4184.pdf http://www.atmel.com/dyn/resources/prod_documents/doc4431.pdf http://www.atmel.com/dyn/resources/prod_documents/doc4428.pdf http://www.atmel.com/dyn/resources/prod_documents/doc4428.pdf

ROMless
TS80C31X2 AT80C31X2

103

Appendix G Change log


1.3.11 -> 1.4 * Bug fixes * Added new Virtual HW component: LCD display controlled by HD44780 * Added new Virtual HW component: simulated DS1620 temperature sensor * Added new Virtual HW component: File interface * Added AT89S51 * Improved performance of Virtual HW * Added support for spelling checker (Hunspell) * Added 8051 Instruction table * Improved table of symbols on the right panel * Final draft of the handbook 1.3.10 -> * * * * 1.3.11 Bug fixes New interface for hardware control plug-ins Added new assembler directives: ELSEIF ELSEIFN ELSEIFDEF ELSEIFNDEF Removed assembler directive: EXITM

1.3.9 -> 1.3.10 * Bug fixes * Extended help menu * Extended global configuration dialog * Added support for multiple widget styles and GUI background colors * Added draft of handbook * Added basic support for assembler and simulator regression testing * Added regular support for i18n (internationalization) * Modified welcome dialog * Added support for external links in the GUI 1.3.8 -> 1.3.9 * Bug fixes 1.3.7 -> 1.3.8 * Bug fixes * Added feature "Global Font Size Factor" (see MCU 8051 IDE configuration dialog) * Added breakpoint validation 1.3.6 -> 1.3.7 * Bug fixes 1.3.5 -> 1.3.6

104
* Bug fixes 1.3.4 -> 1.3.5 * Bug fixes 1.3.3 -> 1.3.4 * "Modernized" GUI * Bug fixes 1.3.1 -> 1.3.3 * Bug fixes 1.3.1 -> 1.3.2 * Bug fixes

APPENDIX G. CHANGE LOG

1.3 -> 1.3.1 * Dependency on TclX is now only optional * Important chage !: Native assembler now expands macro instructions before doing conditional assembly and before defining constants and variables ! Control sequence $NOMACROSFIRST can be used to change this behavior to the state of previous versions. * Added support for AS31 assembler * Added files notepad * Improved instruction help panel * Native assembler was extended to support these directives: "IFN IFDEF IFNDEF BYTE FLAG REPT TIMES" and these constrol sequences: "$NOXR $NOXREF $XR $XREF $NOSB $SB $RESTORE $RS $SA $SAVE $PHILIPS $NOPI $PI $NOTABS $NOMOD51 $NOBUILTIN $NOMO $MO $MOD51 $NOMACRO $NOMR $LI $NOLI $GENONLY $GO $NOGEN $NOGE $GEN $GE $ $EJ $NODB $NODEBUG $DB $DEBUG $CONDONLY $NOCOND $COND $TT $PW $PL $MR $MACRO $INC $WARNING $ERROR $DA $NOMACROSFIRST" * Added stack monitor * Various bug fixes 1.2 -> 1.3 * New dependency: TclX (tested with v8.4) * Added RS232/UART debugger * A few changes in assembler * Bug fixes (Thanks to Miroslav Hradlek for many useful bug reports) 1.1.1 -> 1.2 * Bug fixes * Added tab bar 1.1 -> 1.1.1 * Added "Special calculator" * Added "Base converter" * Many tiny improvements 1.0.9 -> 1.1 * Added support for new MCUs from Intel R : 8031, 8751, 8032, 8752, 80C31, 87C51, 80C52, 87C52, 80C32, 80C54, 87C54, 80C58, 87C58 * Added support for simulating virtual hardware * Improved simulator (Implemented UART (experimental support), improved support for timers, etc.) * Improved register watches * Improved editor (improved autocompletion and many other things) * Improved panel "Instruction details" * Improved 8-segment editor * Bug fixes in assembler, disassembler and simulator engine * Some other bug fixes * Added utility "Scribble notepad" * Improved graph panel

105
1.0.7 -> 1.0.9 * Added support for C language * Added map of bit addressable area 1.0.6 -> 1.0.7 * Added Stopwatch * Improved code editor * Some bug fixes 1.0.5 -> 1.0.6 * Fixed * Added * Added * Added critical bug in Assembler v1.0.5 (related to peephole code optimization) 8 segment LED display editor ASCII chart Assembly symbol table viewer

1.0 -> 1.0.5 * Added support for external assemblers ("ASEM-51" and "ASL") * Added support for external editors ("emacs", "gvim", "kwrite" and "gedit") * Added support for embedded editors ("emacs", "vim", "nano", "dav" and "le") * Added embedded terminal emulator (rxvt-unicode) * Added function "File statistics" * Improved assembler * Added syntax highlight for code listing (*.lst) * Added search bars for "Messages" and "Todo" * Removed dependency on "tcl-thread" and "tclxml" * Added dependency on "TkImg" and "tdom" * Improved hex editor * Improved simulator (especially simulation across multiple files) * Added panel "Find in files" * Modified GUI * New error handling dialog * Some bug fixes (especially critical bug in disassembler and a few bugs in assembler) * All images are now in PNG (Portable Network Graphics) (Requires TkImg) * Some more improvements 0.9.5 -> 1.0 * MANY BUG FIXES ! (including critical) * Added support for some new MCUs ( AT89S52,AT89LS51,AT89LS52,AT89S8253,AT89S2051,AT89S4051, T87C5101,T83C5101,T83C5102,TS80C32X2,TS80C52X2,TS87C52X2, AT80C32X2,AT80C52X2,AT87C52X2,AT80C54X2,AT80C58X2,AT87C54X2, AT87C58X2,TS80C54X2,TS80C58X2,TS87C54X2,TS87C58X2,TS80C31X2, AT80C31X2 ) * Added support for peephole optimization * Faster project opening * Added interrupt monitor * Added subprograms monitor * Added SFR map * Added SFR watches * Extended command line interface * Compiler now checks for valid memory addressing (new CLI options --iram-size, --eram-size, --xram-size, --code-size) * Added program hibernation capability * Added editor commands hibernate, resume, switch-mcu, set-xcode and set-xdata * Added desktop file and application icon * Some more improvements

106

APPENDIX G. CHANGE LOG

0.9.1 -> 0.9.5 * Implemented support for 80C51, 8052, AT89C2051, AT89C4051, AT89C51, AT89C51RC, AT89C52, AT89C55WD, AT89LV51, AT89LV52 and AT89LV55 * Simulator can now step back * Added popup-based completion for editor * Added tool tips for bits in simulator control panel * Added simulator configuration dialog * Added auto save function * Manual page * Added support for multi-view (editor can be now splitted vertically or horizontally) * Many bug fixes (in compiler, editor, file selection dialog, syntax highlight, simulator, etc.) * Some minor improvements (graph, disassembler, etc.) * Thread extension is no longer required to run this program (but custom commands will won't work without it) 0.9.0 -> 0.9.1 * New hexadecimal editor * New file selection dialog * Added file system browser tab on left panel * Added tips on start-up * Added editor command line * Improved editor configuration dialog * A few bug fixes * Removed dependency on IWidgets and Tix * Some minor improvements 0.8.7 -> 0.9.0 * Implemented graph * Many bug fixes (GUI, compiler, memory leaks) * Editable shortcuts * Bookmarks for opened and project files * Search panels in left and right panel * Modified GUI (checkboxes, radio buttons ...) * Support for various encodings and EOLs * Added "Tools" -> "Change letter case", "Normalize HEX" and "SIM -> BIN" * Added editor functions "Lowercase", "Uppercase" and "Capitalize" * Added help windows for opened and project files and opened projects * Added pop-up menus for entry and text widgets (globally) * Fixed problem with fonts (bad sizes) * Implemented support for line wrapping (experimental) * Added new command line options (see `mcu8051ide --help') * More status tips and tool tips * Added welcome dialog * Added demonstration project * Cleaner, faster and safer compiler * Some more minor improvements 0.8.5 -> 0.8.7 * Implemented code validation * Added tab "Instruction details" (on the right panel) * Added Clean Up dialog * Added Right Panel configuration dialog * Added Toolbar configuration dialog * Added support for custom commands * Fixed some bugs (in GUI) * Fixed many memory leaks * Cleaner code 0.8.4 -> 0.8.5

107
* * * * * * Fixed many bugs in GUI Improved editor Extended calculator Redesigned editor configuration dialog Added functions "Tools -> Reformat code" and "Tools -> Sim2Hex" Extended CLI (--reset-user-settings, --config-file, --compile, --hex2bin ...)

0.8.1 -> 0.8.4 * Fixed many bugs ... (including critical) * Added compiler configuration dialog * Added calculator timers preset * Added dialog about * Added support for exporting highlighted source code to LaTeX source * Added many ToolTips * Added StatusBar tips * Added splash screen * Added support for command line options * All images are now *.XPM (X PixMap) (require Tix package) * Changed installation procedure 0.8.0 -> 0.8.1 * Fixed * Fixed * Fixed * Added some bugs in compiler (not critical) bug in to do list (saving text as SGML) bug in project management pop-up menu to to do list

108

APPENDIX G. CHANGE LOG

109

List of Tables
1 3.1 3.2 3.3 3.4 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 Software requirements Available commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 19 26 27 34 41 41 49 49 49 50 51 54 58 58 58 58 58 61 92 98 Data register watches: Register address List of pseudo-variables

Symbol colors and icons in default settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Radix speciers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Expression operators . . . . . . . . . . . . . . . . . . . . . . . . . . Code addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Plain numbers, these symbols are always dened! . . . . . . . . . . Predened SFR bit addresses Predened SFR addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Segment types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Directives directly related to macros Special instruction operands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4.10 Instruction mnemonics . . . . . . . . . . . . . . . . . . . . . . . . . 4.11 Directives 4.12 Expression operators . . . . . . . . . . . . . . . . . . . . . . . . . . 4.13 Assembler controls 4.14 Control sequences aecting code listing . . . . . . . . . . . . . . . . D.1 E.1 8051 Instructions in numerical Order . . . . . . . . . . . . . . . . . 8051 Instructions in lexical Order . . . . . . . . . . . . . . . . . . .

110

LIST OF TABLES

111

List of Figures
1.1 2.1 2.2 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 i8051 micro-architecture . . . . . . . . . . . . . . . . . . . . . . . . . 12 15 16 17 18 18 20 20 20 20 21 21 22 22 23 24 25 25 26 27 27 28 28 28 29 30 30 31 32 MCU 8051 IDE with the demonstration project opened within it

Project creation dialog . . . . . . . . . . . . . . . . . . . . . . . . . Syntax validation conguration button . . . . . . . . . . . . . . . . Spell checker conguration button completion all in action . . . . . . . . . . . . . . . . . .

Syntax highlight, syntax validation and the pop-up based auto. . . . . . . . . . . . . . . . . . . . . . . . Main panel of the simulator . . . . . . . . . . . . . . . . . . . . . . Highlighted SFR register . . . . . . . . . . . . . . . . . . . . . . . . Tool tip help for a special function bit . . . . . . . . . . . . . . . .

Representation of a register value in various numeric bases . . . . . GPIO Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Messages panel

3.10 Personal notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.11 Calculator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.12 Embedded rxvt-unicode terminal emulator, with the Midnight Commander running in it . . . . . . . . . . . . . . . . . . . . . . . . . . 3.13 SFR watches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3.14 Instruction details

3.15 Data register watches . . . . . . . . . . . . . . . . . . . . . . . . . . 3.16 Subprograms call monitor . . . . . . . . . . . . . . . . . . . . . . .

3.17 Map of the bit addressable area . . . . . . . . . . . . . . . . . . . . 3.18 Stack monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.19 Symbol viewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3.20 ASCII chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.21 8051 Instruction Table . . . . . . . . . . . . . . . . . . . . . . . . . 3.22 8-segment editor 3.23 Base convertor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3.24 UART/RS-232 debugger . . . . . . . . . . . . . . . . . . . . . . . . 3.25 MCU code memory editor . . . . . . . . . . . . . . . . . . . . . . . 3.26 Interrupt monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . .

112
3.28 Custom commands conguration dialog 3.30 Main toolbar

LIST OF FIGURES
34 35 35 37 37 67 67 68 68 68 69 69 70 70 70 70 70 70 71 74 83 85 . . . . . . . . . . . . . . .

3.27 Change letter case dialog . . . . . . . . . . . . . . . . . . . . . . . . 3.29 Editor conguration dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.31 Global conguration dialog 6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8 6.9

DS1620 simulator and its log window . . . . . . . . . . . . . . . . . PALE I/O interface . . . . . . . . . . . . . . . . . . . . . . . . . . . LED Panel LED Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

M LED Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LED Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Matrix Keypad Simple Keypad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Simulated LCD display . . . . . . . . . . . . . . . . . . . . . . . . .

6.10 HD44780 Log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.11 CGRAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.12 DDRAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.13 View on CGROM . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.1 7.2 B.1 C.1 An example of HW control plug-in . . . . . . . . . . . . . . . . . .

A basic example of a plug-in . . . . . . . . . . . . . . . . . . . . . . Assembler regression test run in terminal emulator . . . . . . . . .

Ocial web page of the MCU 8051 IDE project . . . . . . . . . . .

Das könnte Ihnen auch gefallen