Business Programming I - PowerPoint PPT Presentation

About This Presentation
Title:

Business Programming I

Description:

In Billy-O, we used line labels like TOP or MID so we could jump to a new ... Let's replace the INP statements of Billy-O with an ACCEPT statement and the OUT ... – PowerPoint PPT presentation

Number of Views:35
Avg rating:3.0/5.0
Slides: 18
Provided by: jimp53
Category:

less

Transcript and Presenter's Notes

Title: Business Programming I


1
Business Programming I
  • Fall 2000
  • By
  • Jim Payne

2
A New Programming Language
  • In our previous sessions, we have learned to
    develop assembler language program solutions for
    simple arithmetic problems.
  • Today, we will begin the process of developing
    a brand new programming language.

3
A New Programming Language
  • Goals for our new high-level language
  • 1) Combine several assembler instructions
    into one high-level instruction.
  • 2) Allow for numeric and alphanumeric
    variables.
  • 3) Begin to trust the internal operations of
    the computer.
  • 4) Improve Input and Output flexibility.

4
Replace Line Labels with Line s
  • In Billy-O, we used line labels like TOP or MID
    so we could jump to a new label. (e.g BRU TOP)
  • Lets replace those labels with line numbers
    on each statement and the branching instructions
    with GOTO instructions. (e.g. 200 GOTO 100)

5
Input/Output Statements
  • Lets replace the INP statements of Billy-O
    with an ACCEPT statement and the OUT statements
    with DISPLAY statements.
  • General Form
  • ACCEPT variable,variable,
  • DISPLAY variable,variable,

6
COMPUTE statement
  • Lets create a very powerful new statement
    called the COMPUTE statement. It can replace
    several assembler statements with one.
  • COMPUTE D A B C
  • REPLACES LDA B, MPY C, ADD A, STA D

7
Conditional Branching
  • Lets make our If logic more user friendly.
    When we wanted to count those exam scores gt 60,
    we did things like ADC 60, BNA TOP, etc.
  • Lets replace that with an IF or Decision
    structure.
  • IF SCR gt 60
  • COMPUTE COP COP 1
  • ELSE
  • COMPUTE COF COF 1
  • ENDIF

8
Variable Types

Up to now, we have used only numeric type
variables. In the future, we will need variables
for handling text inputs. For now, lets just
agree to put a after any variable name that
might contain non-numeric information. i.e.
ACCEPT NAME, AGE DATA John Brown, 23
9
New Instruction Set
10
Bertha Method
STEPS (In Pseudocode Form) Pick up a card from
the in basket. If score 999, do what? Else
do what? NOT EQUAL 999 Add score to Sum of
Scores, Add 1 to Counter of Scores. If score gt
60, Add 1 to Counter of Passing. Then go read
next score. EQUAL 999 Compute Average Score
Sum of Scores / Counter of Scores. Print out
report answers. Quit Processing
11
Variable Naming
SCR Individual Score SOS Sum of Scores COS
Counter of Scores COP Counter of Passing AVG
Average Score SOS / COS
12
Pseudocode
Flowchart of Logic
Input a value for SCR If SCR 999 Compute
AVG SOS / COS Print Results and
Quit Else Compute SOS SOS SCR
Compute COS COS 1 If SCR gt 60
Compute COP COP 1 EndIf Endif Go to
Top of Program
13
Billy-O Program
New Program
TOP INP SCR LDA SCR ADC -999 BZA MID LDA SOS
ADD SCR STA SOS LDA COS ADC 1 STA COS LDA SCR
ADC -60 BNA TOP LDA COP ADC 1 STA COP BRU T
OP MID LDA SOS DIV COS STA AVG OUT AVG OUT COS
OUT COP HLT
SOS NUM 0 COS NUM 0 COP NUM 0 END
  • ACCEPT SCR
  • 110 IF SCR 999
  • 120 GOTO 220
  • 130 ELSE
  • 140 COMPUTE SOS SOS SCR
  • COMPUTE COS COS 1
  • 160 IF SCR gt 60
  • COMPUTE COP COP 1
  • 180 ELSE
  • 190 ENDIF
  • GOTO 100
  • 210 ENDIF
  • COMPUTE AVG SOS / COS
  • 230 DISPLAY AVG, COS, COP
  • 240 END

14
Flowchart
New Program
  • ACCEPT SCR
  • 110 IF SCR 999
  • 120 GOTO 220
  • 130 ELSE
  • 140 COMPUTE SOS SOS SCR
  • COMPUTE COS COS 1
  • 160 IF SCR gt 60
  • COMPUTE COP COP 1
  • 180 ELSE
  • 190 ENDIF
  • GOTO 100
  • 210 END-IF
  • COMPUTE AVG SOS / COS
  • 230 DISPLAY AVG, COS, COP
  • 240 END

15
Original Pseudocode
New Program Code
  • ACCEPT SCR
  • 110 IF SCR 999
  • 120 GOTO 220
  • 130 ELSE
  • 140 COMPUTE SOS SOS SCR
  • COMPUTE COS COS 1
  • 160 IF SCR gt 60
  • COMPUTE COP COP 1
  • 180 ELSE
  • 190 ENDIF
  • GOTO 100
  • 210 END-IF
  • COMPUTE AVG SOS / COS
  • 230 DISPLAY AVG, COS, COP
  • 240 END

Input a value for SCR If SCR 999 Compute
AVG SOS / COS Print Results and
Quit Else Compute SOS SOS SCR
Compute COS COS 1 If SCR gt 60
Compute COP COP 1 EndIf Endif Go to
Top of Program
16
High-Level Language to Machine Code
COMPUTE C A B
High-Level Language
Compilers Interpreters -Translators
LDA A MPY B STA C
11011010010010001010101001
Assembler Language
Machine Language
17
Go TU !!!
Write a Comment
User Comments (0)
About PowerShow.com