Computer Laboratory Manual1

download Computer Laboratory Manual1

of 58

Transcript of Computer Laboratory Manual1

  • 8/12/2019 Computer Laboratory Manual1

    1/58

    Microprocessor Based System Design-Lab Manual

    Computer Laboratory Manual

    Microprocessor Based System Design

    (CE-207)

    Computer Engineering Department

    Sir Syed ni!ersity o" Engineering # $ec%nology

    ni!ersity &oad' (arac%i7*00

    %t t p +,, .ssuet.edu .p /

    Sir Syed University of Engineering and Technology Page

  • 8/12/2019 Computer Laboratory Manual1

    2/58

    Microprocessor Based System Design-Lab Manual

    Content

    Lab $opic 1age

    1 Explore debugger using different commands 32 To understand the basic concept and functionality of Assembly Language. 10

    3 To understand the concept of new line using carriage return line feed and macro. 1!

    " To understand the concept of displaying string in assembly language.. 20

    # To understand the concepts of loop in assembly language. 23

    $ To understand the concept of stac% in assembly language. 2#& 'ntroduction to ()A * !0!$ Training +it 2&

    ! To understand the basic operations of ()A !0x!$ trainer %it 2,

    , To understand the concept of how to access a memory of trainer !0!$ andunderstand some Assembl instructions.

    3"

    10 To understand the different commands of ()A !0x!$ trainer +it 3$

    11 -rite a program to display the digits in decimal from 0& into &segment "012 To initiali/e dot matrix display "3

    13 Exploring ()E !0#1 (icrocontroller Trainer oards "$

    1" rogramming !0#1 ' orts as 'nput orts #3

    1# rogramming !0#1 ' orts as 'nput orts and utput orts #$

    Sir Syed University of Engineering and Technology Page !

  • 8/12/2019 Computer Laboratory Manual1

    3/58

    Microprocessor Based System Design-Lab Manual

    LB3

    4B5EC$6E+

    Explore debugger using different commands.

    $8E4&9+

    1&4:&MM6;: L;::E

    A programming language is an artificial language that can be used to control the beha4ior of a

    machine particularly a computer. rogramming languages li%e human languages ha4e syntactic

    and semantic rules to define meaning.

    $91ES 4< 1&4:&MM6;: L;::E

    rogramming languages can be classified into three basic categories on the basis of understandingle4el of users as well as the machine to which instructions has been gi4en5

    3. 86:8 LEEL L;::ES

    A programming language that enables a programmer to write programsthat are more or less independent of a particular type of computer and are designed to gi4e abetter program efficiency. 6uch languages are considered highle4el because they are closer tohuman languages.

    2. L4= LEEL L;::ES

    These are designed to ha4e both5 a relati4ely good programming

    efficiency and relati4ely good machine efficiency.

    *. MC86;E L;::E

    (achine language is at the lowest le4el because it is the actual binarycode of 1s and 0s that the computer understands. These are designed to gi4e a better machineefficiency.

    &E:6S$E&S CLSS6

  • 8/12/2019 Computer Laboratory Manual1

    4/58

    Microprocessor Based System Design-Lab Manual

    S4ME :E;E&L 1&14SE &E:6S$E&S+

    > (CCML$4& &E:6S$E&)

    't is the preferred register to use in the arithmetic logic and data transfer instructionsbecause its use generates the shortest machine code.

    'n multiplication and di4ision operations one of the numbers in4ol4ed must be in A7 or

    AL.

    'nput and output operation also re8uires the use of A7 and AL.

    B> (BSE &E:6S$E&)

    't is used to store the data also it ser4es as an address register.

    C> (C4;$ &E:6S$E&)

    rogram loop instructions are facilitated by the use of 97 register ser4es as a loop counter.

    Also used as a counter in the string operations.

    9L is used as count in instructions that shift and rotate bits.

    D> (D$ &E:6S$E&)

    't is used in multiplication and di4ision operations.

    't is used in ' operation li%e )L in character output and )7 in string output functions.

    &E:6S$E& S6?E+

    -e ha4e three different si/es of registers5

    !bit register5 A: AL : L 9: 9L ): )L

    1$bit registers5 A7 7 97 )7 6 6' )' 66 )6 96 E6 ;6

  • 8/12/2019 Computer Laboratory Manual1

    5/58

  • 8/12/2019 Computer Laboratory Manual1

    6/58

    Microprocessor Based System Design-Lab Manual

    A uit the debug program

    & )isplay the contents of one or more registers

    $ Trace the contents of one instruction

    Bnassembled machine code into symbolic code

    = -rite a program onto dis%

    't is possible to 4isuali/e the 4alues of the internal registers of the 9B using the )ebug

    program. To begin wor%ing with )ebug type the following prompt in your computer5

    C+,Debug Enter

    n the next line a dash will appear this is the indicator of )ebug at this moment the

    instructions of )ebug can be introduced using the following command5

    -rEnter

    A7C0000 7C0000 97C0000 )7C0000 6C;;EE C0000 6'C0000 )'C0000

    )6C0)$2 E6C0)$2 66C0)$2 96C0)$2 'C0100 @= E' L @D @A @9

    0)$250100 2E 965

    0)$250101 !03E)3);00 9( TE T? F);)3G00 965);)3C03

    All the contents of the internal registers of the 9B are displayed> an alternati4e of 4iewingthem is to use the HrH command using as a parameter the name of the register whose 4alue

    wants to be seen.

  • 8/12/2019 Computer Laboratory Manual1

    7/58

    Microprocessor Based System Design-Lab Manual

    :ere HaddH is the command to be executed> in this case an addition and HahH as well as HbhH are the

    parameters.

  • 8/12/2019 Computer Laboratory Manual1

    8/58

    Microprocessor Based System Design-Lab Manual

    t

    A7C0002 7C0000 97C0000 )7C0000 6C;;EE C0000 6'C0000 )'C0000

    )6C0)$2 E6C0)$2 66C0)$2 96C0)$2 'C0103 @= E' L @D @A @9

    0)$250103 0"00 (= 7000

    ou see that the 4alue 2 mo4e to A7 register. Type the command HtH Ktrace again and you

    see the second instruction is executed.

    t

    A7C0002 7C000" 97C0000 )7C0000 6C;;EE C0000 6'C0000 )'C0000

    )6C0)$2 E6C0)$2 66C0)$2 96C0)$2 'C010$ @= E' L @D @A @9

    0)$25010$ 01)! A)) A77

    Type the command HtH Ktrace to see the instruction add is executed you will see the follow

    lines5

    t

    A7C000$ 7C000" 97C0000 )7C0000 6C;;EE C0000 6'C0000 )'C0000

    )6C0)$2 E6C0)$2 66C0)$2 96C0)$2 'C010! @= E' L @D @A E @9

    0)$25010! ,0 @

    LA ME9T'=E65LA ME9T'=E65

    TA6+N1TA6+N155 )isplay the contents of the defined memory locations 120 133 122 using Dcommand.

    TA6+N25TA6+N25 Edit the contents of the abo4e memory locations 120 133122 by 020"03respecti4ely using Ecommand.

    TA6+N35TA6+N35 Then again display the contents of the memory locations which we edit in the Tas%N2.

    TA6+N"5TA6+N"5 Add the contents of the abo4e defined memory location using mo! instruction.

    TA6+N#5TA6+N#5 6ubtract the content of 120 location by 133 and then store the result in the120 locationand add the new 120 location contents with the content of 122 location.

    Sir Syed University of Engineering and Technology Page '

  • 8/12/2019 Computer Laboratory Manual1

    9/58

    Microprocessor Based System Design-Lab Manual

    TA6+N$5TA6+N$5 erform the following debug acti4ities

    C$ 3.3 +C$ 3.3 + Use debug command U100 to un-assemble the instructions in ACT 1.1. What is themachine code corresponding to each assembly code instruction.

    ssembly Code Mac%ine Codemo! a@'2FG%

    add a@'*7GH%

    mo! b@'a@

    sub b@'20

    nop

    C$ 3.2 +C$ 3.2 + How many bytes does it need to represent each instruction in binary.

    ssembly Code ;o. 4" Byte

    mo! a@'2FG%add a@'*7GH%

    mo! b@'a@

    sub b@'20

    nop

    C$ 3.* +C$ 3.* + What are the contents of C ! "# ! A$ % &$ '. Use debug command ( to display theseinformation.

    &egister Content

    CS61

    >

    B>

    C$ 3.G +C$ 3.G + #redict the contents of the following registers after e)ecution of each instruction C ! "# !A$ ! &$

    &egister Mo! a@'2FG dd a@'*7HG Mo! b@'a@

    CS

    61>

    B>

    LB2

    4B5EC$6E

    Sir Syed University of Engineering and Technology Page (

  • 8/12/2019 Computer Laboratory Manual1

    10/58

    Microprocessor Based System Design-Lab Manual

    $o understand t%e basic concept and "unctionality o" ssembly Language.

    $8E4&9

    SSEMBL9 L;::E

    Assembly language is a machine specific programming language with aonetoone correspondence between its statements and the computerOs nati4e machine language.There are many different types of assembly language each specific to a processor or processorfamily. '(9 assembly language refers to instruction recogni/ed by a number of differentmicroprocessors in the 'ntel family5 !0!$ !0!! !01!$ !02!$ !03!$ !0"!$ and entium.

    SES+

    Assembly language is used most often when either communicating with the operating

    system or directly accessing computer hardware.

    6econdly assembly language is used to optimi/e certain critical areas of application

    programs to speed up their runtime execution.

    SSEMBLE&

    An assembler is a program that con4erts source code programs from the assemblylanguage into machine language. The assembler can optionally generate a source listing file withline numbers memory addresses source code statements and a crossreference listing of symbolsand 4ariables used in a program.The most popular assemblers for the 'ntel family are (A6( K(icrosoft Assembler TA6( KTurboAssembler.

    L6;E&

    A companion program that combines indi4idual files created by an assembler into asingle executable file

    DEB::E&

    A program that pro4ides a way for a programmer to trace the execution of a program andexamine the contents of memory.

    M6C&41&4CESS4& &C86$EC$&E

    As assembly language is microprocessor specific so before writing assembly languageprograms it is re8uired to %now the architecture of that microprocessor.

    0F M6C&41&4CESS4&+

    -e will be studying the assembly language for the microprocessor !0!$.

    Sir Syed University of Engineering and Technology Page )

  • 8/12/2019 Computer Laboratory Manual1

    11/58

    Microprocessor Based System Design-Lab Manual

    !0!$ microprocessor is a 1$bit microprocessor Ka 1$bit microprocessor can operate on

    the 1$bits of data at a time ha4ing 1$ bit registers.

    1$bit data bus and 20bit address bus.

    't can access 1 ( of total memory.

    To write the assembly language programs for !0!$ microprocessor we are re8uired to %now the

    internal organi/ation at least programming model

    1&4:&MM6;: M4DEL+

    The programming model of the !0!$ through entium '' is considered to be program 4isible

    because its registers are used during application programming and are specified by the

    instruction.ther registers are considered to be program in4isible because they are not addressed

    directly during application programming but may be used indirectly during system programming.

    &E:6S$E&S CLSS6

  • 8/12/2019 Computer Laboratory Manual1

    12/58

    Microprocessor Based System Design-Lab Manual

    A data structure called 6tac% is used by the microprocessor to implement procedure calls.

    The programOs code data and stac% are loaded into different memory segments called code

    segment data segment and the stac% segment.

    SE:ME;$ &E:6S$E&S

    To %eep trac% of the 4arious program segments the !0!$ microprocessor is e8uippedwith four segment registers to hold the segment numbers.

    The 96 )6 and 66 registers contain the code data and stac% segment numbers

    respecti4ely.

    'f a program needs to access a second data segment it can use the E6 KExtra 6egment

    register.146;$E& ;D 6;DE> &E:6S$E&S

    The registers 6 6' and )' normally points to Kcontain the offset address of memory

    location.

    These registers can be used in arithmetic and other operations.S1 (S$C 146;$E&)

    The 6 register contains the offset of the top of stac%.

    The 6 and 66 registers combine to form the complete address of the top of the stac%.

    B1 (BSE 146;$E&)

    The register contains an assumed offset from the 66 register as does the stac% pointer.

    The register is often used by a subroutine to locate 4ariables that were passed on the

    stac% by a calling program.

    The register can be used for other segment unli%e 6 register.

    S6 (S4&CE 6;DE>)

    The 6' register is used to point to memory locations in the data segment addressed by )6. This register ta%es its name from the string mo4ement instructions in which the source

    string is pointed to by the 6' register.D6 (DES$6;$64; 6;DE>)

    The )' register performs the same operation as the 6' register.

    The )' register acts as the destination for string mo4ement instructions.

    C4;$&4L &E:6S$E&

    61 (6;S$&C$64; 146;$E&)

    The ' register contains the offset of the next instruction to be executed within the current

    code segment.

    The ' and 96 registers combine to form the complete address of the next instruction.

    Sir Syed University of Engineering and Technology Page !

  • 8/12/2019 Computer Laboratory Manual1

    13/58

    Microprocessor Based System Design-Lab Manual

    identifies the endof the procedure

    S$C SE:ME;$

    The stac% segment is used for temporary storage of addresses and data. 'f no stac% segment

    is declared an error message is generated so there must be a stac% segment e4en if theprogram doesnOt utili/e the stac%.

    These segments begin with the directi4es .stac/ .code and .data

    1&4:&M S9;$>T'TLE first program syntax.(odel 6mall >6pecifies the memory model used.6tac% 100: >allocate 100: memory locations for stac%.)ata >start of the data segment> )ata definitions hereA ) QRR...9ode >start of the code segment

    Sir Syed University of Engineering and Technology Page "

  • 8/12/2019 Computer Laboratory Manual1

    14/58

    Microprocessor Based System Design-Lab Manual

    (ain roc >start of the first procedure> instructions hereRR(ain Endp >end of the first procedure> ther procedures here

    End (ain >end of the complete assembly program

    BS6C D6&EC$6ES

    ;ollowing are the description of commonly used directi4es>

    M4DEL+ 't is used to specify the memory model used for program to identify the si/e of code and

    data segments.

    S$C+ )efines the si/e of stac% used in program

    D$+ )efines the data segments for data used in the program. (ar% the beginning of the data

    segment

    C4DE+ 'dentifies the code segment which contains all the statements. Also .code mar%s the

    beginning of the code segment.

    1&4C+ eginning of the procedure

    E;D1+ End of the procedure

    E;D+ End of assembly language program

    BS6C M4 6;S$&C$64;+

    -e already defined in the LabN1

    &ES$&6C$64;S+

    (o4e between memory to memory is not allowed.

    A number directly inside a segment register is not allowed.

    6egment to segment registers mo4e is not allowed.

    6;1$,4$1$ 41E&$64;S

    To display a character is an output operation.

    -e actually want to display single character from the microprocessor to the screen.

    -e donOt ha4e any instruction that perform this operation li%e printf in 9 language.

    -e actually use the ser4ice routines which are already designed and assembled programs to

    perform the ' operations.

    Sir Syed University of Engineering and Technology Page #

  • 8/12/2019 Computer Laboratory Manual1

    15/58

    Microprocessor Based System Design-Lab Manual

    There are two categories of ser4ice routines

    Basic 6nput 4utput System (B64S) routines

    D4S routines

    The '6 routines are stored in ?( and interact directly with the ' ports. -e carry out basicscreen operations.

    The )6 routines are the part of the operating system running into the system.

    )6 routines can carry out more complex tas%s e.g. printing a character string.

    )6 routines actually use the '6 routines to perform direct ' operations.

    6;$ 6;S$&C$64;

    '@T instruction is used to in4o%e a )6 or '6 routine.

    6yntax '@T 10: K '6 routine call

    '@T 21: K)6 routine call

  • 8/12/2019 Computer Laboratory Manual1

    16/58

    Microprocessor Based System Design-Lab Manual

    (= )LOQO I c%aracter is JK

    '@T 21h I c%aracter ill be displayed

    Sample 1rogram

    4B5EC$+4B5EC$+

    Title a program that displays single character on screen.

    S4&CE C4DE+S4&CE C4DE+

    .model small *specify memory model

    .stac/ 300% * specify si+e of stac,

    .code * start of the code segment

    main proc * start of the first procedure

    mo! a%'02% * display a single character

    mo! dl' * transfer A to register dl

    int 23% * routine interrupt

    mo! a%'Gc% * e)it function

    int 23%

    main endp

    end main

    S$E1S $4

  • 8/12/2019 Computer Laboratory Manual1

    17/58

    Microprocessor Based System Design-Lab Manual

    4$1$+

    2

  • 8/12/2019 Computer Laboratory Manual1

    18/58

    Microprocessor Based System Design-Lab Manual

    LB*

    4B5EC$6E

    To understand the concept of new line using carriage return line feed and macros.

    $8E4&9

    6;$ 23%+

    This can be used to in4o%e large number of )6 functions. A particular function is re8uested by

    placing a function number in the A: register and in4o%ing '@T 21h.

    ;or E.g. following functions can be used in our program5

  • 8/12/2019 Computer Laboratory Manual1

    19/58

    Microprocessor Based System Design-Lab Manual

    E@ample+

    C&&6:E &E$&;

    This macro can be used for the purpose of carriage return.

    C&N&$; MC&4

    M4 8' GC8

    6;$ 238

    E;DM

    nce declared and defined this macro can be in4o%ed anywhere in the program by the name

    [email protected] name of the macro can be any string as defined by the user.

    L6;E

  • 8/12/2019 Computer Laboratory Manual1

    20/58

    Microprocessor Based System Design-Lab Manual

    LBG

    4B5EC$6E

    $o understand t%e concept o" displaying string in assembly language.

    $8E4&9+

    string constant

    4ersion2 db VaO VbO VcO > character constants

    4ersion3 db ,& ,! ,, > A69'' codes

    The first 4ersion uses the method of high le4el languages and simply encloses the string in 8uotes.This is the preferred method.

    The second 4ersion defines a string by specifying a list of the character constants that ma%e up the

    string.

    -e may also combine the abo4e methods to define a string as in the following example5message db

    :ello worldU 13 10 VWO

    Sir Syed University of Engineering and Technology Page !)

  • 8/12/2019 Computer Laboratory Manual1

    21/58

    Microprocessor Based System Design-Lab Manual

    S$&6;: 4$1$

    (6)6 pro4ides subprogram number H% to display strings which are terminated by the JO

    character. 'n order to use it we must5

    3. Ensure the string is terminated with the VWO character.2. 6pecify the string to be displayed by storing its address in the d@ register.*. 6pecify the string output subprogram by storing ,h in ah.G. Bse int 21h to call (6)6 to execute subprogram ,h..

    eyord + MS:

    The message to be displayed in the output can also be declared in the data segment using

    the %eyword (6

  • 8/12/2019 Computer Laboratory Manual1

    22/58

    Microprocessor Based System Design-Lab Manual

    end main

    LA ME9T'=E65LA ME9T'=E65

    $S35-rite a program to display your bio data using carriage return and line feed macro

    $S35-rite a program to ma%e your 3rdsemester mar% sheet.

    LB

    4B5EC$6E+

    Sir Syed University of Engineering and Technology Page !!

  • 8/12/2019 Computer Laboratory Manual1

    23/58

    Microprocessor Based System Design-Lab Manual

    To understand the concepts of loop in assembly language

    $8E4&9

    Loop

    A loop is a se8uence of instructions that is repeated. The number of times to repeat may be %nown

    in ad4ance or it may depend on conditions i.e. itOs a count controlled loop.

  • 8/12/2019 Computer Laboratory Manual1

    24/58

    Microprocessor Based System Design-Lab Manual

    ;alse

    True

    LA ME9T'=E65LA ME9T'=E65

    $as/ 03+-rite a program to print V[O 100 times using linefeed and carriage return.

    $as/02+-rite a program to print A69'' characters.

    $as/0*+-rite a program to print your name 10 times using linefeed and carriage return.

    LBF

    4B5EC$6E+4B5EC$6E+

    Sir Syed University of Engineering and Technology Page !#

  • 8/12/2019 Computer Laboratory Manual1

    25/58

    Microprocessor Based System Design-Lab Manual

    To understand the concept of stac% in assembly language.

    Sample 1rogram+

    LB

    $S+$S+

    Ta%e input from user at run time and show the output in re4erse order.

    Sir Syed University of Engineering and Technology Page !$

    S4&CE C4DE+

    4bPect+$a/e t%e input "rom user at run time and s%o output in re!erse order.

    .model small

    .stac% 100h

    .codemain procmo4 ah02hmo4 dlQint 21hxor cxcxmo4 ah01hint 21hwhileS5cmp al0dh\e endSwhilepush axinc cxint 21h\mp whileSendSwhile5mo4 ah02hmo4 bl0dhint 21hmo4 ah02hmo4 dl0ahint 21h\ex/ exittop5pop dxint 21hloop topexit5moh ah"chint 21hmain endpend main

  • 8/12/2019 Computer Laboratory Manual1

    26/58

    Microprocessor Based System Design-Lab Manual

    'nput a string5

    6tring in ?e4erse rder5

    LB7LB7

    Sir Syed University of Engineering and Technology Page !%

  • 8/12/2019 Computer Laboratory Manual1

    27/58

    Microprocessor Based System Design-Lab Manual

    4B5EC$6E+4B5EC$6E+

    'ntroduction to ()A * !0!$ Training +it

    6;$&4DC$64;+

    ()A!0!$ has high performance $"+byte monitor program. 't is designed for easy function.

    After power is on the monitor begins to wor%. 'n addition to all the %ey function the monitor has a

    memory chec%ing routine.

    The following is a simple description of the %ey functions.

  • 8/12/2019 Computer Laboratory Manual1

    28/58

    Microprocessor Based System Design-Lab Manual

    9B !0!$

    Sir Syed University of Engineering and Technology Page !'

  • 8/12/2019 Computer Laboratory Manual1

    29/58

    Microprocessor Based System Design-Lab Manual

    (ain ?A( $" + K$22#$ x 2

    (onitor ?( $" + K2&92#$ x 2

    )isplay Bnit L9) K1$ x 2 Line

    ' ort !2##A

    6erial ort ?62329 K!2#1A x 1

    6ystem 9loc% ".,1#2 (:/9loc%

  • 8/12/2019 Computer Laboratory Manual1

    30/58

    Microprocessor Based System Design-Lab Manual

    4B5EC$6E+To understand the basic operations of ()A !0x!$ trainer %it.

    $8E4&9+$8E4&9+

    n a power up following message will be displayed on L9).

    6o as to use serial monitor mo4e \umper 1 which located on the 9 li%e this.

    -hene4er ?E6 is pressed the display becomes ;'M1LE 3.6ET T:E 9@TE@T6 '@ (E(?.

    Sir Syed University of Engineering and Technology Page ")

  • 8/12/2019 Computer Laboratory Manual1

    31/58

    Microprocessor Based System Design-Lab Manual

    Sir Syed University of Engineering and Technology Page "

  • 8/12/2019 Computer Laboratory Manual1

    32/58

  • 8/12/2019 Computer Laboratory Manual1

    33/58

    Microprocessor Based System Design-Lab Manual

    $as/3+$as/3+ 1er"orm t%e "olloing operation on MD Q 0F.

    Set Segment and o""set address 0000+3000

    Enter eRui!alent mac%ine code o" t%e "olloing statements.

    M4 L ' *E

    ;D L ' 0

    97 C 0000 &&!!

    0F & D>

    )7 C0000 1111

    $o see t%e result+

    0F &

    A7C123" 7C"#$& 97C&&!! )7C1111

    6C0#"0 C0000 6'C0000 )'C0000

    )6C0000 E6C0000 66C0000 96C0000

    'C1000 ;LC0000 C . . . . . . .

    $S3+

    3-To store the following data to the gi4en addresss

    2-)isplay all registers with its content.

    LetOs store the following li%e to 01000: ` 01003:

    DD&ESS D$

    01000 A

    01001 9)

    01002 E;

    01003 3"

    $S2+

    3To enter data from 000050000 memory address to 000050020 memory address using command.

    Sir Syed University of Engineering and Technology Page "(

  • 8/12/2019 Computer Laboratory Manual1

    40/58

    Microprocessor Based System Design-Lab Manual

    2)isplay the data you entered in tas%N1 using command.

    *9hange all register content using command then display all registers.

    $S*+

    1;ill the data #$&!123" from "000 to "100 addresses

    2(o4e the abo4e filled data to address 2000

    3Assume your roll number as data and fill it from 0 to 2#$ addresses.@ote your roll no should

    contain four digit.Example 0001

    LB 33

    Sir Syed University of Engineering and Technology Page #)

  • 8/12/2019 Computer Laboratory Manual1

    41/58

    Microprocessor Based System Design-Lab Manual

    4B5EC$6E+

    -rite a program to display the digits in decimalfrom 0& in to &segment.

    $8E4&9+

    7 SE:ME;$ D6S1L9+7 SE:ME;$ D6S1L9+

    The & segment inside the ()A * !0!$ trainer %it can be used to display numbers.

    This re8uires ' !2## ports which are already connected to the & segment internally.

    Through the code we can access these ports and pro4ide binary or hex 4alue to switch the re8uired

    segment on and off.

    'n order to turn a segment @ a logical 0 is re8uired as shown below.

    Any number from 0 * , can be display on the & segment by pro4iding the actual hex or binary 4alue

    which turns those segments @ to display the digit.

    S4&CE C4DE+S4&CE C4DE+

    Sir Syed University of Engineering and Technology Page #

  • 8/12/2019 Computer Laboratory Manual1

    42/58

    Microprocessor Based System Design-Lab Manual

    ssembly code ERui!alent mac%ine language code

    (o4 Al !0: >to ma%e all port out use!0h

    in command byte

    !0

    ut 1; AL > mo4 !0h to port 9 E$ 1;

    (o4 AL0: > mo4 0C3 to AL 0 0

    ut 1,: AL > mo4 0C3 to port A E$ 1,

    'nt 3 99

    S$E1S $4

  • 8/12/2019 Computer Laboratory Manual1

    43/58

    Microprocessor Based System Design-Lab Manual

    4$1$+ *U (B0) is displayed on t%e 7 segment in MD Q 0F

    $S35-rite a program to display all digits from 0, as shown in the following diagram.

    LB 32

    Sir Syed University of Engineering and Technology Page #"

  • 8/12/2019 Computer Laboratory Manual1

    44/58

    Microprocessor Based System Design-Lab Manual

    4bPecti!e+

    To initiali/e )T (AT?'7 )'6LA.

    $%eory+

    DotDot MMaattrri@i@ DisDispplaylay

    1.1. The )ot (atrix inside the ()A * !0!$ trainer %it can be used to display any pattern of

    LE)s in the dot matrix display.

    2. This re8uires ' !2## ports which are already connected to the )ot (atrix internally.3. Through the code we can access these ports and pro4ide binary or hex 4alue to switch the

    re8uired LE)s on and off.". 'n order to turn an LE) @ a logical 0 should be pro4ided to the row and a logical 1 should

    be pro4ided to the column because of the following arrangement

    #. Any particular shape aur design can be formed by turn on the re8uired LE)s on the )ot

    (atrix )isplay.

    SS44&&CECE C4DC4DEE++

    ssembly code ERui!alent mac%ine language code

    Mo! l' 08 0 !0

    4ut 3E' L E$ 1E

    Mo! L' 038 * column to pro/ide

    logical 1

    0 01

    4ut 3C8' L E$ 19Mo! L' 008 * row to pro/ide logical

    00 00

    4ut 38' L E$ 1

    Mo! L'

  • 8/12/2019 Computer Laboratory Manual1

    45/58

    SSteteppss ttoo

  • 8/12/2019 Computer Laboratory Manual1

    46/58

    4utpu t+ ;irst 9olumn LE)s are acti4ated

    LLaabb b\b\ececti4ti4ees5s5

    TA12-rite a program to display 2nd

    column with alternate colors ledOs.

    TA32-rite a program to display a pattern V+A?A9:'O on )T (AT?'7.

    LB 3*

    4bPecti!e

  • 8/12/2019 Computer Laboratory Manual1

    47/58

    Exploring ()E !0#1 (icrocontroller Trainer oards

    $% eory

    6ntrod u c t ion t o Mic r oco n tr o lle r s

    A microcontroller Ksometimes abbre4iated 9 u9 or (9B is a small computer on a singleintegrated circuit containing a processor core memory and programmable inputoutput

    peripherals. (icrocontrollers are designed for embedded applications in contrast to the

    microprocessors used in personal computers or other general purpose applications.

    (icrocontrollers are used in automatically controlled products and de4ices such as automobile

    engine control systems implantable medical de4ices remote controls office machines

    appliances power tools toys and other embedded systems. y reducing the si/e and cost

    compared to a design that uses a separate microprocessor memory and inputoutput de4ices

    microcontrollers ma%e it economical to digitally control e4en more de4ices and processes.

    MDE 03 $ rain er Board s

    The !0#1 board is a useful tool for embedded control and robotics pro\ects for both students and

    hobbyists. 'ts 4ersatile design and programmable microcontroller lets you access numerous

    peripheral de4ices and program the board for multiple uses. The board has many ' connectors

    and supports a number of programming options including !0#1 assembly and 9.

    The !0#1 trainer board has ! switches and ! buffered LE)s for connection to the

    microcontroller bread board or peripheral de4ices. 't pro4ides access to pins of the !0#1 through

    sip male and female connectors for wiring to bread board or attaching )iligent modperipheral modules. )iligent peripheral modules include :bridges analogtodigital and

    digital to analog con4erters spea%er amplifier switches buttons LE)s as well as con4erters

    for easy connection to screw terminals @9 \ac%s ser4o motors and more.

    ;eatures include5

    A (axim 6emiconductor )6!,9"#0 microcontroller Kan !0#1#2 with $"+ bytes of onchip ;lash memory

  • 8/12/2019 Computer Laboratory Manual1

    48/58

    Eight onboard switches accessible 4ia both male and female connector

    Eight onboard LE)s accessible 4ia both male and female connector

    An onboard 4oltage regulator Kin some 4ersions Two 20pin male and female connectors allowing access to all !0#1 ports of 0 1 2

    and 3 for connection to external de4ices such as bread board or )iligent peripheral

    module boards. 6upport for the (axim onchip serial programmer

    Two ?6232 compatible 6erial ports with ), connectors

    An small bread board can be screwed on the board to insert any external '9 and connectit to the board

    ()E !0#1Trainer oard

  • 8/12/2019 Computer Laboratory Manual1

    49/58

    ()E !0#1 9ircuit

    )iagram

  • 8/12/2019 Computer Laboratory Manual1

    50/58

    S tep s to " ollo

    9onnecting the !0#1 Trainer to 9 with :yperTerminal5

    1. 9onnect the 6erial 0 connector of the !0#1 Trainer to 9( port of the 9 using ),

    cable as shown below.

    2. n your 9 go to 6tart Accessories 9ommunications select :yperTerminal.3. Enter a name for the terminal session.

    ". 6elect the 9 9( ort the ()E !0#1 is connected to.

  • 8/12/2019 Computer Laboratory Manual1

    51/58

  • 8/12/2019 Computer Laboratory Manual1

    52/58

    9onfigure :yperTerminal for ,$00 !n1 with no hardware flow control

    #. 9onnect the power and put the 6witch on ?

  • 8/12/2019 Computer Laboratory Manual1

    53/58

    &. 9lear KErase the ;lash by entering letter followed by Enter.!. ?eady to download by entering letter L followed by Enter.,. Bsing :yperTerminal send a text file to the trainer li%e shown below.10. -hen the dialogue appears select all files and na4igate to find your :E7 file to be sent

    to the trainer.

    11. ou should see a series of

  • 8/12/2019 Computer Laboratory Manual1

    54/58

    4bPecti!e+

    L B 3G

    rogramming !0#1 ' orts as 'nput orts

    $ % e o r yThe four !bit ' ports 0 1 2 and 3 each use ! pins. All the ports upon ?E6ET are

    configured as input ready to be used as input ports. -hen the first 0 is written to a port it

    becomes an output. To reconfigure it as an input a 1 must be sent to the port. To use any of these

    ports as an input port it must be programmed.

    14&$ 0

    't can be used for input or output> each pin must be connected externally to a 10+ ohm pullup

    resistor. This is due to the fact that 0 is an open drain unli%e 1 2 and 3. pen drain is a

    term used for (6 chips in the same way that open collector is used for TTL chips.

  • 8/12/2019 Computer Laboratory Manual1

    55/58

    'n order to ma%e port 0 an input port the port must be programmed by writing 1to all the bits.

    ort 0 is also designated as A)0A)& allowing it to be used for both address and data. -hen

    connecting an !0#131 to an external memory port 0 pro4ides both address and data

    14&$ 3

    ort 1 can be used as input or output. 'n contrast to port 0 this port does not need any pullup

    resistors since it already has pullup resistors internally. Bpon reset port 1 is configured as an

    input port. To ma%e port 1 an input port it must be programmed as such by writing 1to all its bits

  • 8/12/2019 Computer Laboratory Manual1

    56/58

    14&$ 2

    ort 2 can be used as input or output. Must li%e 1 port 2 does not need any pullup resistors

    since it already has pullup resistors internally. Bpon reset port 2 is configured as an input port.

    To ma%e port 2 an input port it must be programmed as such by writing 1 to all its bits. 'n many

    !0#1based systems 2 is used as simple '. To ma%e port 2 an input port it must be

    programmed as such by writing 1 to all its bits. 'n many !0#1based systems 2 is used as

    simple '.

    14&$ *

    ort 3 can be used as input or output. 't also does not need any pullup resistors. ort 3 is

    configured as an input port upon reset> this is not the way it is most commonly used.

    LLaabb b\b\ececti4ti4ees5s5

    $as / 3 -rite a program for the )6!,9"20 to toggle all the bits of 0 1 and 2 e4ery 1" of

    a second

    6ource 9ode in Assembly Language

    ?< 0A9+5 (= AN##:

    (= 0A(= 1A(= 2AA9ALL 6)ELA

    (= AN0AA:(= 0A(= 1A(= 2AA9ALL 6)ELA6M( A9+

    6)ELA5(= ?# N11

    :35 (= ?" N2"!:25 (= ?3 N2##:15 )M@D ?3 :1

    )M@D ?" :2)M@D ?# :3?ETE@)

  • 8/12/2019 Computer Laboratory Manual1

    57/58

    LB 3

    4bPecti!e+

    rogramming !0#1 ' orts as 'nput orts and utput orts

    $% eory+

    ?efer Lab N12

    LLaabb b\b\ececti4ti4ees5s5

    $as/ 3 -rite a program to that ta%es input from switch to port 1 and display output at port 2

    ?< 0 (= AN0 (= 2A >2 as output (= AN0;;:

    (= 1A >1 A6 '@BT

    A9+5 (= A1 >get data from 6-s on 1 (= A2 >send it to LE)s 2 6M( A9+ >%eep doing it E@)

  • 8/12/2019 Computer Laboratory Manual1

    58/58