entc 349 week 3 - session 3 program design calculator

27
2012 Texas A&M Univesity 1 ENTC 349 Week 3 – Session 3 Calculator Design & Example Program George B. Wright Senior Lecturer Electronics & Telecommunications Engineering Technology

Upload: yoftahi

Post on 21-Oct-2015

10 views

Category:

Documents


0 download

TRANSCRIPT

2012 Texas A&M Univesity 1

ENTC 349 Week 3 – Session 3Calculator Design & Example Program

George B. WrightSenior LecturerElectronics & TelecommunicationsEngineering Technology

Texas A&M Univesity 2

Topics

ReviewProject DesignProgram ExampleDevelopment – Input

Input Hierarchy ChartInput Flow ChartsInput Code

Program Example

test.asm

Texas A&M Univesity 3

* Test Program - ARM Assembly on TMS570* Programmer - George B. Wright

.armSTART mov r0,#1

mov r1,#2add r1,r1,r0str r1,sum

EXIT b EXIT

sum .set 0.end

Assembly Language Options

In-line assemblyCommand line environment with standalone tools, Assembler, linker, loader, debugger, etc.Integrated Development Environment

Texas A&M Univesity 4

How do I Assemble this code.

Texas A&M Univesity 5

Command Line View

DOS Window

Texas A&M Univesity 6

Editor View of .asm

Texas A&M Univesity 7

Editor View of .lst

Texas A&M Univesity 8

Command Line Assembly

Texas A&M Univesity 9

Texas A&M Univesity 10

Objectives

Expand our knowledge of Program DesignExpand our knowledge of the ARM RCPU Instruction Set –TMS570Design a Four Function Calculator using the Texas Instruments RCPU as implemented on the TMS570 family RCPU’s.

Texas A&M Univesity 11

Project Design Review

Program SpecificationBlock Diagram - HardwareFunctional DescriptionHierarchy Chart (s)Flow Chart (s)Pseudo CodeCode

AssemblyC or a combination of the these languages

Texas A&M Univesity 12

A Starting Point for the Design

Calculator

Initialize Input Calc Output

Problem – Design a four function calculator using the TMS570 microcontorller.

1. Functionally decompose the problem into components.

2. Create a hierarchy chart that show the relationship between the components/functions.

Texas A&M Univesity 13

Four Function Integer Calculator

Calculator

Initialize Input Calc Output Exit

getoperand getoperator

getchar

chkchar

getchar

chkchar

operanderror operatorerror

Hierarchy Chart

Texas A&M Univesity 14

Functional Design

A functional design typically includes two components

Functional RequirementsPerformance Requirements

A functional requirement is typically stated in functional terms

For the calculator design a function would be - Input

Texas A&M Univesity 15

Functional Requirement - Input

The calculator must accept integer input expressed as ASCII characters from a keyboard or sixteen key keypad.The format of the input is as follows

>Calculator>1+2=3>

.

Where the bold characters areentered by the operator and allothers are displayed by the program

Presenter
Presentation Notes
Pick up on the input format and discuss the syntax > [operand] operator [operand] terminal character Relate the syntax to the hierarchy chart.

Texas A&M Univesity 16

Input Syntax

>1+2=3 The bold characters are entered by the operator.

The format is as follows:> 1 + 2 =

Prompt Operand Operator Operand Terminator

Texas A&M Univesity 17

Input Hierarchy Chart

Input

getoperand getoperator inputerror

getchar chkchar operanderror getchar checkoper opererror

Texas A&M Univesity 18

Flow Chart - getoperand

Here is our first try.Will this design do the job?

Texas A&M Univesity 19

Problem - getoperand

It only handles single character operands!It does not handle operators?Error handling?This subroutine needs to be refined.

Texas A&M Univesity 20

Assembly Language Code

Where do you start coding?Higher level functions or lower level function? High Level

What is the purpose of high level functions?

To perform program ControlWhat is the purpose of low level functions?

To get the work done

Texas A&M Univesity 21

Function LevelCalculator

Initialize Input Output Exit

getoperand getoperator

getchar

chkchar

getchar

chkchar

operanderror operatorerror

0

1

2

3

Texas A&M Univesity 22

Calculator Level 0

Calculator FunctionalityCode format

Calculator LoopInput

bl INITLOOP bl INPUT

bl CALCbl OUTPUTb LOOP

INPUT bl GETOPERANDbl GETOPERATORbl GETOPERANDmov pc,lr

Texas A&M Univesity 23

What is down the road?

Exam 1 two weeks from today. Next Friday, one week before the exam

Problem Set 1 AssignedReview Sheet

Expand knowledge of Instruction SetExpand assembly language programming skill and knowledge

Texas A&M Univesity 24

What is next?

Expand the calculator code.Prepare by developing your version.We will look at the details.

Hierarchy ChartFlow ChartsCode

Texas A&M Univesity 25

References

Knaggs, P., Welsh, S. ARM Assembly Language Programming, July 2008.Hohl, William, ARM Assembly Language: Fundamentals and Techniques, CRC Press, 2009.

Texas A&M Univesity 26

Revised - getoperand

Is this any better?

Texas A&M Univesity 27

Is this it?