SlideShare a Scribd company logo
1
Programming the Basic Computer
Computer Organization
PROGRAMMING THE BASIC COMPUTER
Introduction
Machine Language
Assembly Language
Assembler
Program Loops
Programming Arithmetic and Logic Operations
Subroutines
Input-Output Programming
2
Programming the Basic Computer
Computer Organization
6.1. INTRODUCTION
Symbol Hexa code Description
Those concerned with computer architecture should have a knowledge
of both hardware and software because the two branches influence
each other.
m: effective address
M: memory word (operand)
found at m
Introduction
AND 0 or 8 AND M to AC
ADD 1 or 9 Add M to AC, carry to E
LDA 2 or A Load AC from M
STA 3 or B Store AC in M
BUN 4 or C Branch unconditionally to m
BSA 5 or D Save return address in m and branch to m+1
ISZ 6 or E Increment M and skip if zero
CLA 7800 Clear AC
CLE 7400 Clear E
CMA 7200 Complement AC
CME 7100 Complement E
CIR 7080 Circulate right E and AC
CIL 7040 Circulate left E and AC
INC 7020 Increment AC, carry to E
SPA 7010 Skip if AC is positive
SNA 7008 Skip if AC is negative
SZA 7004 Skip if AC is zero
SZE 7002 Skip if E is zero
HLT 7001 Halt computer
INP F800 Input information and clear flag
OUT F400 Output information and clear flag
SKI F200 Skip if input flag is on
SKO F100 Skip if output flag is on
ION F080 Turn interrupt on
IOF F040 Turn interrupt off
Instruction Set of the Basic Computer
3
Programming the Basic Computer
Computer Organization
6.2. MACHINE LANGUAGE
Program:
is a list of instructions or statements for directing the computer to
perform a required data processing task
Various types of programming languages
- Hierarchy of programming languages
• Machine-language
- Binary code
- Octal or hexadecimal code
• Assembly-language (Assembler)
- Symbolic code
• High-level language (Compiler)
Machine Language
4
Programming the Basic Computer
Computer Organization
COMPARISON OF PROGRAMMING LANGUAGES
Machine Language
Add two numbers in C/C++
Int A,B,C;
Cin >> A;
Cin >> B;
C = A + B;
ORG 0 /Origin of program is location 0
LDA A /Load operand from location A
ADD B /Add operand from location B
STA C /Store sum in location C
HLT /Halt computer
A, DEC 83 /Decimal operand
B, DEC -23 /Decimal operand
C, DEC 0 /Sum stored in location C
END /End of symbolic program
• Assembly-Language Program
000 LDA 004 Load 1st operand into AC
001 ADD 005 Add 2nd operand to AC
002 STA 006 Store sum in location 006
003 HLT Halt computer
004 0053 1st operand
005 FFE9 2nd operand (negative)
006 0000 Store sum here
• Program with Symbolic OP-Code
000 2004
001 1005
002 3006
003 7001
004 0053
005 FFE9
006 0000
• Hex program
5
Programming the Basic Computer
Computer Organization
COMPARISON OF PROGRAMMING LANGUAGES
Machine Language
000 LDA 004 Load 1st operand into AC
001 ADD 005 Add 2nd operand to AC
002 STA 006 Store sum in location 006
003 HLT Halt computer
004 0053 1st operand
005 FFE9 2nd operand (negative)
006 0000 Store sum here
• Program with Symbolic OP-Code
000 2004
001 1005
002 3006
003 7001
004 0053
005 FFE9
006 0000
• Hex program
0 0010 0000 0000 0100
1 0001 0000 0000 0101
10 0011 0000 0000 0110
11 0111 0000 0000 0001
100 0000 0000 0101 0011
101 1111 1111 1110 1001
110 0000 0000 0000 0000
• Binary Program to Add Two Numbers
6
Programming the Basic Computer
Computer Organization
6.3. ASSEMBLY LANGUAGE
Syntax of the BC assembly language:
Each line is arranged in three columns called fields:
Assembly Language
2. Instruction field
- Specifies a machine or a pseudo instruction
- May specify one of the
* Memory reference instructions (MRI)
MRI consists of two or three symbols separated by spaces.
ADD OPR (direct address MRI)
ADD PTR I (indirect address MRI)
* Register reference or input-output instructions
Non-MRI does not have an address part
* Pseudo instruction with or without an operand
- Symbolic address used in the instruction field must be defined as a label
3. Comment field
- May be empty or may include a comment
1. Label field
- May be empty or may specify a symbolic address of up to 3 characters
- Terminated by a comma
7
Programming the Basic Computer
Computer Organization
PSEUDO-INSTRUCTIONS
ORG N
Hexadecimal number N is the memory location
for the instruction or operand listed in the following line
END
Denotes the end of symbolic program
DEC N
Signed decimal number N to be converted to binary
HEX N
Hexadecimal number N to be converted to binary
Example: Assembly language program to subtract two numbers
ORG 100
LDA SUB
CMA
INC
ADD MIN
STA DIF
HLT
DEC 83
DEC -23
HEX 0
END
/ Origin of program is location 100
/ Load subtrahend to AC
/ Complement AC
/ Increment AC
/ Add minuend to AC
/ Store difference
/ Halt computer
/ Minuend
/ Subtrahend
/ Difference stored here
/ End of symbolic program
MIN,
SUB,
DIF,
Assembly Language
8
Programming the Basic Computer
Computer Organization
TRANSLATION TO BINARY
ORG 100
LDA SUB
CMA
INC
ADD MIN
STA DIF
HLT
DEC 83
DEC -23
HEX 0
END
MIN,
SUB,
DIF,
100 2107
101 7200
102 7020
103 1106
104 3108
105 7001
106 0053
107 FFE9
108 0000
Symbolic Program
Location Content
Hexadecimal Code
Assembly Language
Address symbol Hex address
MIN 106
SUB 107
DIF 108
Address-Symbol Table
9
Programming the Basic Computer
Computer Organization
6.4. ASSEMBLER - FIRST PASS -
Assembler
Source Program - Symbolic Assembly Language Program
Object Program - Binary Machine Language Program
Assembler
First pass First pass
LC  0
Scan next line of code Set LC
Label
no
yes
yes
no
ORG
Store symbol
in address-
symbol table
together with
value of LC
END
Increment LC
Go to
second
pass
no
yes
Two pass assembler
1st pass: generates a table that correlates all user defined
(address) symbols with their binary equivalent value
2nd pass: binary translation
10
Programming the Basic Computer
Computer Organization
ASSEMBLER - SECOND PASS -
Machine instructions are
translated by means of
table-lookup procedures:
1. Pseudo-Instruction Table
2. MRI Table
3. Non-MRI Table
4. Address Symbol Table
Assembler
Second pass
LC  0
Scan next line of code
Set LC
yes
yes
ORG
Pseudo
instr.
yes
END
no
Done
yes
MRI
no
Valid
non-MRI
instr.
no
Convert
operand
to binary
and store
in location
given by LC
no
DEC or
HEX
Error in
line of
code
Store binary
equivalent of
instruction
in location
given by LC
yes
no
Get operation code
and set bits 2-4
Search address-
symbol table for
binary equivalent
of symbol address
and set bits 5-16
I
Set
first
bit to 0
Set
first
bit to 1
yes no
Assemble all parts of
binary instruction and
store in location given by LC
Increment LC
Second Pass
11
Programming the Basic Computer
Computer Organization
6.5. PROGRAM LOOPS
Program Loops
Loop: A sequence of instructions that are executed many times,
each with a different set of data
ORG 100
LDA ADS
STA PTR
LDA NBR
STA CTR
CLA
ADD PTR I
ISZ PTR
ISZ CTR
BUN LOP
STA SUM
HLT
HEX 150
HEX 0
DEC -100
HEX 0
HEX 0
ORG 150
DEC 75
DEC 23
END
/ Origin of program is HEX 100
/ Load first address of operand
/ Store in pointer
/ Load -100
/ Store in counter
/ Clear AC
/ Add an operand to AC
/ Increment pointer
/ Increment counter
/ Repeat loop again
/ Store sum
/ Halt
/ First address of operands
/ Reserved for a pointer
/ Initial value for a counter
/ Reserved for a counter
/ Sum is stored here
/ Origin of operands is HEX 150
/ First operand
/ Last operand
/ End of symbolic program
LOP,
ADS,
PTR,
NBR,
CTR,
SUM,
.
.
.
Add 100 numbers:
DIMENSION A(100)
INTEGER SUM, A
SUM = 0
DO 3 J = 1, 100
SUM = SUM + A(J)
3
Fortran program to add 100 numbers:
12
Programming the Basic Computer
Computer Organization
6.5. PROGRAM LOOPS
DIMENSION A(100)
INTEGER SUM, A
SUM = 0
DO 3 J = 1, 100
SUM = SUM + A(J)
3
Program Loops
Loop: A sequence of instructions that are executed many times,
each with a different set of data
Fortran program to add 100 numbers:
ORG 100
LDA ADS
STA PTR
LDA NBR
STA CTR
CLA
ADD PTR I
ISZ PTR
ISZ CTR
BUN LOP
STA SUM
HLT
HEX 150
HEX 0
DEC -100
HEX 0
HEX 0
ORG 150
DEC 75
DEC 23
END
/ Origin of program is HEX 100
/ Load first address of operand
/ Store in pointer
/ Load -100
/ Store in counter
/ Clear AC
/ Add an operand to AC
/ Increment pointer
/ Increment counter
/ Repeat loop again
/ Store sum
/ Halt
/ First address of operands
/ Reserved for a pointer
/ Initial value for a counter
/ Reserved for a counter
/ Sum is stored here
/ Origin of operands is HEX 150
/ First operand
/ Last operand
/ End of symbolic program
LOP,
ADS,
PTR,
NBR,
CTR,
SUM,
.
.
.
Add 100 numbers:
13
Programming the Basic Computer
Computer Organization
6.5. PROGRAM LOOPS
DIMENSION A(100)
INTEGER SUM, A
SUM = 0
DO 3 J = 1, 100
SUM = SUM + A(J)
3
Program Loops
Loop: A sequence of instructions that are executed many times,
each with a different set of data
Fortran program to add 100 numbers:
ORG 100
LDA ADS
STA PTR
LDA NBR
STA CTR
CLA
ADD PTR I
ISZ PTR
ISZ CTR
BUN LOP
STA SUM
HLT
HEX 150
HEX 0
DEC -100
HEX 0
HEX 0
ORG 150
DEC 75
DEC 23
END
/ Origin of program is HEX 100
/ Load first address of operand
/ Store in pointer
/ Load -100
/ Store in counter
/ Clear AC
/ Add an operand to AC
/ Increment pointer
/ Increment counter
/ Repeat loop again
/ Store sum
/ Halt
/ First address of operands
/ Reserved for a pointer
/ Initial value for a counter
/ Reserved for a counter
/ Sum is stored here
/ Origin of operands is HEX 150
/ First operand
/ Last operand
/ End of symbolic program
LOP,
ADS,
PTR,
NBR,
CTR,
SUM,
.
.
.
Add 100 numbers:
14
Programming the Basic Computer
Computer Organization
6.5. PROGRAM LOOPS
DIMENSION A(100)
INTEGER SUM, A
SUM = 0
DO 3 J = 1, 100
SUM = SUM + A(J)
3
Program Loops
Loop: A sequence of instructions that are executed many times,
each with a different set of data
Fortran program to add 100 numbers:
ORG 100
LDA ADS
STA PTR
LDA NBR
STA CTR
CLA
ADD PTR I
ISZ PTR
ISZ CTR
BUN LOP
STA SUM
HLT
HEX 150
HEX 0
DEC -100
HEX 0
HEX 0
ORG 150
DEC 75
DEC 23
END
/ Origin of program is HEX 100
/ Load first address of operand
/ Store in pointer
/ Load -100
/ Store in counter
/ Clear AC
/ Add an operand to AC
/ Increment pointer
/ Increment counter
/ Repeat loop again
/ Store sum
/ Halt
/ First address of operands
/ Reserved for a pointer
/ Initial value for a counter
/ Reserved for a counter
/ Sum is stored here
/ Origin of operands is HEX 150
/ First operand
/ Last operand
/ End of symbolic program
LOP,
ADS,
PTR,
NBR,
CTR,
SUM,
.
.
.
Add 100 numbers:
15
Programming the Basic Computer
Computer Organization
6.5. PROGRAM LOOPS
DIMENSION A(100)
INTEGER SUM, A
SUM = 0
DO 3 J = 1, 100
SUM = SUM + A(J)
3
Program Loops
Loop: A sequence of instructions that are executed many times,
each with a different set of data
Fortran program to add 100 numbers:
ORG 100
LDA ADS
STA PTR
LDA NBR
STA CTR
CLA
ADD PTR I
ISZ PTR
ISZ CTR
BUN LOP
STA SUM
HLT
HEX 150
HEX 0
DEC -100
HEX 0
HEX 0
ORG 150
DEC 75
DEC 23
END
/ Origin of program is HEX 100
/ Load first address of operand
/ Store in pointer
/ Load -100
/ Store in counter
/ Clear AC
/ Add an operand to AC
/ Increment pointer
/ Increment counter
/ Repeat loop again
/ Store sum
/ Halt
/ First address of operands
/ Reserved for a pointer
/ Initial value for a counter
/ Reserved for a counter
/ Sum is stored here
/ Origin of operands is HEX 150
/ First operand
/ Last operand
/ End of symbolic program
LOP,
ADS,
PTR,
NBR,
CTR,
SUM,
.
.
.
Add 100 numbers:
16
Programming the Basic Computer
Computer Organization
PROGRAMMING ARITHMETIC AND LOGIC OPERATIONS
- Software Implementation
- Implementation of an operation with a program
using machine instruction set
- Usually when the operation is not included
in the instruction set
- Hardware Implementation
- Implementation of an operation in a computer
with one machine instruction
Software Implementation example:
* Multiplication
- For simplicity, unsigned positive numbers
- 8-bit numbers -> 16-bit product
Programming Arithmetic and Logic Operations
Implementation of Arithmetic and Logic Operations
17
Programming the Basic Computer
Computer Organization
FLOWCHART OF A PROGRAM - Multiplication -
X holds the multiplicand
Y holds the multiplier
P holds the product
Example with four significant digits
0000 1111
0000 1011 0000 0000
0000 1111 0000 1111
0001 1110 0010 1101
0000 0000 0010 1101
0111 1000 1010 0101
1010 0101
Programming Arithmetic and Logic Operations
cil
CTR  - 8
P  0
E  0
AC  Y
Y  AC
cir EAC
E
P  P + X
E  0
AC  X
cil EAC
X  AC
CTR  CTR + 1
=1
=0
CTR
=0
Stop
 0
X =
Y =
P
18
Programming the Basic Computer
Computer Organization
ASSEMBLY LANGUAGE PROGRAM - Multiplication -
ORG 100
CLE
LDA Y
CIR
STA Y
SZE
BUN ONE
BUN ZRO
LDA X
ADD P
STA P
CLE
LDA X
CIL
STA X
ISZ CTR
BUN LOP
HLT
DEC -8
HEX 000F
HEX 000B
HEX 0
END
/ Clear E
/ Load multiplier
/ Transfer multiplier bit to E
/ Store shifted multiplier
/ Check if bit is zero
/ Bit is one; goto ONE
/ Bit is zero; goto ZRO
/ Load multiplicand
/ Add to partial product
/ Store partial product
/ Clear E
/ Load multiplicand
/ Shift left
/ Store shifted multiplicand
/ Increment counter
/ Counter not zero; repeat loop
/ Counter is zero; halt
/ This location serves as a counter
/ Multiplicand stored here
/ Multiplier stored here
/ Product formed here
LOP,
ONE,
ZRO,
CTR,
X,
Y,
P,
Programming Arithmetic and Logic Operations
cil
CTR  - 8
P  0
E  0
AC  Y
Y  AC
cir EAC
E
P  P + X
E  0
AC  X
cil EAC
X  AC
CTR  CTR + 1
=1
=0
CTR
=0
Stop
 0
19
Programming the Basic Computer
Computer Organization
ASSEMBLY LANGUAGE PROGRAM
- Double Precision Addition -
LDA AL
ADD BL
STA CL
CLA
CIL
ADD AH
ADD BH
STA CH
HLT
AL, ---
AH, ---
BL, ---
BH, ---
CL, ---
CH, ---
/ Load A low
/ Add B low, carry in E
/ Store in C low
/ Clear AC
/ Circulate to bring carry into AC(16)
/ Add A high and carry
/ Add B high
/ Store in C high
/ Location of operands
Programming Arithmetic and Logic Operations
20
Programming the Basic Computer
Computer Organization
ASSEMBLY LANGUAGE PROGRAM
- Logic and Shift Operations -
• Logic operations
- BC instructions : AND, CMA, CLA
LDA A
CMA
STA TMP
LDA B
CMA
AND TMP
CMA
/ Load 1st operand
/ Complement to get A’
/ Store in a temporary location
/ Load 2nd operand B
/ Complement to get B’
/ AND with A’ to get A’ AND B’
/ Complement again to get A OR B
• Shift operations - BC has Circular Shift only
CLE
SPA
CME
CIR
/ Clear E to 0
/ Skip if AC is positive
/ AC is negative
/ Circulate E and AC
CLE
CIR
Programming Arithmetic and Logic Operations
- Program for OR operation
- Arithmetic right-shift operation
- Logical shift-right operation - Logical shift-left operation
CLE
CIL
21
Programming the Basic Computer
Computer Organization
6.7. SUBROUTINES
ORG 100
LDA X
BSA SH4
STA X
LDA Y
BSA SH4
STA Y
HLT
HEX 1234
HEX 4321
HEX 0
CIL
CIL
CIL
CIL
AND MSK
BUN SH4 I
HEX FFF0
END
/ Main program
/ Load X
/ Branch to subroutine
/ Store shifted number
/ Load Y
/ Branch to subroutine again
/ Store shifted number
/ Subroutine to shift left 4 times
/ Store return address here
/ Circulate left once
/ Circulate left fourth time
/ Set AC(13-16) to zero
/ Return to main program
/ Mask operand
X,
Y,
SH4,
MSK,
100
101
102
103
104
105
106
107
108
109
10A
10B
10C
10D
10E
10F
110
Loc.
Subroutines
- A set of common instructions that can be used in a program many times.
- Subroutine linkage : a procedure for branching
to a subroutine and returning to the main program
Subroutine
Example
return address
0 BSA 109
Next instruction
Subroutine
101
102
109
10A
1 BUN 109
Memory
10F
22
Programming the Basic Computer
Computer Organization
SUBROUTINE PARAMETERS AND DATA LINKAGE
ORG 200
LDA X
BSA OR
HEX 3AF6
STA Y
HLT
HEX 7B95
HEX 0
HEX 0
CMA
STA TMP
LDA OR I
CMA
AND TMP
CMA
ISZ OR
BUN OR I
HEX 0
END
/ Load 1st operand into AC
/ Branch to subroutine OR
/ 2nd operand stored here
/ Subroutine returns here
/ 1st operand stored here
/ Result stored here
/ Subroutine OR
/ Complement 1st operand
/ Store in temporary location
/ Load 2nd operand
/ Complement 2nd operand
/ AND complemented 1st operand
/ Complement again to get OR
/ Increment return address
/ Return to main program
/ Temporary storage
X,
Y,
OR,
TMP,
200
201
202
203
204
205
206
207
208
209
20A
20B
20C
20D
20E
20F
210
Loc.
Example: Subroutine performing LOGICAL OR operation; Need two parameters
Subroutines
Linkage of Parameters and Data between the Main Program and a Subroutine
- via Registers
- via Memory locations
23
Programming the Basic Computer
Computer Organization
SUBROUTINE - Moving a Block of Data -
BSA MVE
HEX 100
HEX 200
DEC -16
HLT
HEX 0
LDA MVE I
STA PT1
ISZ MVE
LDA MVE I
STA PT2
ISZ MVE
LDA MVE I
STA CTR
ISZ MVE
LDA PT1 I
STA PT2 I
ISZ PT1
ISZ PT2
ISZ CTR
BUN LOP
BUN MVE I
--
--
--
/ Main program
/ Branch to subroutine
/ 1st address of source data
/ 1st address of destination data
/ Number of items to move
/ Subroutine MVE
/ Bring address of source
/ Store in 1st pointer
/ Increment return address
/ Bring address of destination
/ Store in 2nd pointer
/ Increment return address
/ Bring number of items
/ Store in counter
/ Increment return address
/ Load source item
/ Store in destination
/ Increment source pointer
/ Increment destination pointer
/ Increment counter
/ Repeat 16 times
/ Return to main program
MVE,
LOP,
PT1,
PT2,
CTR,
• Fortran subroutine
SUBROUTINE MVE (SOURCE, DEST, N)
DIMENSION SOURCE(N), DEST(N)
DO 20 I = 1, N
DEST(I) = SOURCE(I)
RETURN
END
20
Subroutines
24
Programming the Basic Computer
Computer Organization
6.8. INPUT OUTPUT PROGRAM
Program to Input one Character (Byte)
SKI
BUN CIF
INP
OUT
STA CHR
HLT
--
/ Check input flag
/ Flag=0, branch to check again
/ Flag=1, input character
/ Display to ensure correctness
/ Store character
/ Store character here
CIF,
CHR,
Input Output Program
LDA CHR
SKO
BUN COF
OUT
HLT
HEX 0057
/ Load character into AC
/ Check output flag
/ Flag=0, branch to check again
/ Flag=1, output character
/ Character is "W"
COF,
CHR,
Program to Output a Character
25
Programming the Basic Computer
Computer Organization
CHARACTER MANIPULATION
--
SKI
BUN FST
INP
OUT
BSA SH4
BSA SH4
SKI
BUN SCD
INP
OUT
BUN IN2 I
/ Subroutine entry
/ Input 1st character
/ Logical Shift left 4 bits
/ 4 more bits
/ Input 2nd character
/ Return
IN2,
FST,
SCD,
Subroutine to Input 2 Characters and pack into a word
Input Output Program
26
Programming the Basic Computer
Computer Organization
PROGRAM INTERRUPT
Tasks of Interrupt Service Routine
- Save the Status of CPU
Contents of processor registers and Flags
- Identify the source of Interrupt
Check which flag is set
- Service the device whose flag is set
(Input Output Subroutine)
- Restore contents of processor registers and flags
- Turn the interrupt facility on
- Return to the running program
Load PC of the interrupted program
Input Output Program
27
Programming the Basic Computer
Computer Organization
INTERRUPT SERVICE ROUTINE
-
BUN SRV
CLA
ION
LDA X
ADD Y
STA Z
STA SAC
CIR
STA SE
SKI
BUN NXT
INP
OUT
STA PT1 I
ISZ PT1
SKO
BUN EXT
LDA PT2 I
OUT
ISZ PT2
LDA SE
CIL
LDA SAC
ION
BUN ZRO I
-
-
-
-
/ Return address stored here
/ Branch to service routine
/ Portion of running program
/ Turn on interrupt facility
/ Interrupt occurs here
/ Program returns here after interrupt
/ Interrupt service routine
/ Store content of AC
/ Move E into AC(1)
/ Store content of E
/ Check input flag
/ Flag is off, check next flag
/ Flag is on, input character
/ Print character
/ Store it in input buffer
/ Increment input pointer
/ Check output flag
/ Flag is off, exit
/ Load character from output buffer
/ Output character
/ Increment output pointer
/ Restore value of AC(1)
/ Shift it to E
/ Restore content of AC
/ Turn interrupt on
/ Return to running program
/ AC is stored here
/ E is stored here
/ Pointer of input buffer
/ Pointer of output buffer
ZRO,
SRV,
NXT,
EXT,
SAC,
SE,
PT1,
PT2,
0
1
100
101
102
103
104
200
Loc.
Input Output Program

More Related Content

PPTX
Computer Organization
PPT
Bca 2nd sem-u-3.1-basic computer programming and micro programmed control
PPT
B.sc cs-ii-u-3.1-basic computer programming and micro programmed control
PPTX
Programming the basic computer
PPT
Mca i-u-3-basic computer programming and micro programmed control
PPT
basic computer programming and micro programmed control
PPTX
Programming basic computer
PDF
Programming the Basic Computer and Assembler
Computer Organization
Bca 2nd sem-u-3.1-basic computer programming and micro programmed control
B.sc cs-ii-u-3.1-basic computer programming and micro programmed control
Programming the basic computer
Mca i-u-3-basic computer programming and micro programmed control
basic computer programming and micro programmed control
Programming basic computer
Programming the Basic Computer and Assembler

Similar to CH06 (1).PPT (20)

PPTX
CH-3 CO-all-about-operating-system(Update).pptx
PPT
8051assembly language
PPTX
Computer Organization - Programming the basic computer : Machine Language, As...
PPT
12 mt06ped008
PPTX
UNit-4.pptx programming the basic computer
PPTX
Introduction to Assembly Language & various basic things
PPTX
EC8691-MPMC-PPT.pptx
PPTX
SPOS UNIT1 PPTS (1).pptx
PDF
Examinable Question and answer system programming
DOCX
Assembly Language Paper.docx
PPTX
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
PPT
Assembly Language Basics
RTF
Microprocessor File
PPTX
DOC
Microprocessor Basics - 8085 Ch-4
PPTX
Intro to assembly language
PPT
Assembly language programming implemenation
DOCX
64-bit Assembly language program to Accept and display numbers.docx
PPT
8085 instruction set and Programming
PDF
computer architecture Lecture 8 for computer science
CH-3 CO-all-about-operating-system(Update).pptx
8051assembly language
Computer Organization - Programming the basic computer : Machine Language, As...
12 mt06ped008
UNit-4.pptx programming the basic computer
Introduction to Assembly Language & various basic things
EC8691-MPMC-PPT.pptx
SPOS UNIT1 PPTS (1).pptx
Examinable Question and answer system programming
Assembly Language Paper.docx
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Basics
Microprocessor File
Microprocessor Basics - 8085 Ch-4
Intro to assembly language
Assembly language programming implemenation
64-bit Assembly language program to Accept and display numbers.docx
8085 instruction set and Programming
computer architecture Lecture 8 for computer science
Ad

Recently uploaded (20)

PPTX
Power Point - Lesson 3_2.pptx grad school presentation
PPTX
presentation_pfe-universite-molay-seltan.pptx
PPT
415456121-Jiwratrwecdtwfdsfwgdwedvwe dbwsdjsadca-EVN.ppt
PDF
Sims 4 Historia para lo sims 4 para jugar
PDF
The New Creative Director: How AI Tools for Social Media Content Creation Are...
PPTX
Database Information System - Management Information System
PDF
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
PDF
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
PPTX
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
PPTX
Mathew Digital SEO Checklist Guidlines 2025
PPTX
SAP Ariba Sourcing PPT for learning material
PPT
Design_with_Watersergyerge45hrbgre4top (1).ppt
PPTX
Digital Literacy And Online Safety on internet
PPTX
t_and_OpenAI_Combined_two_pressentations
PPTX
Module 1 - Cyber Law and Ethics 101.pptx
PDF
mera desh ae watn.(a source of motivation and patriotism to the youth of the ...
PPTX
newyork.pptxirantrafgshenepalchinachinane
PPT
Ethics in Information System - Management Information System
PPT
250152213-Excitation-SystemWERRT (1).ppt
PPTX
Introduction to cybersecurity and digital nettiquette
Power Point - Lesson 3_2.pptx grad school presentation
presentation_pfe-universite-molay-seltan.pptx
415456121-Jiwratrwecdtwfdsfwgdwedvwe dbwsdjsadca-EVN.ppt
Sims 4 Historia para lo sims 4 para jugar
The New Creative Director: How AI Tools for Social Media Content Creation Are...
Database Information System - Management Information System
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
Mathew Digital SEO Checklist Guidlines 2025
SAP Ariba Sourcing PPT for learning material
Design_with_Watersergyerge45hrbgre4top (1).ppt
Digital Literacy And Online Safety on internet
t_and_OpenAI_Combined_two_pressentations
Module 1 - Cyber Law and Ethics 101.pptx
mera desh ae watn.(a source of motivation and patriotism to the youth of the ...
newyork.pptxirantrafgshenepalchinachinane
Ethics in Information System - Management Information System
250152213-Excitation-SystemWERRT (1).ppt
Introduction to cybersecurity and digital nettiquette
Ad

CH06 (1).PPT

  • 1. 1 Programming the Basic Computer Computer Organization PROGRAMMING THE BASIC COMPUTER Introduction Machine Language Assembly Language Assembler Program Loops Programming Arithmetic and Logic Operations Subroutines Input-Output Programming
  • 2. 2 Programming the Basic Computer Computer Organization 6.1. INTRODUCTION Symbol Hexa code Description Those concerned with computer architecture should have a knowledge of both hardware and software because the two branches influence each other. m: effective address M: memory word (operand) found at m Introduction AND 0 or 8 AND M to AC ADD 1 or 9 Add M to AC, carry to E LDA 2 or A Load AC from M STA 3 or B Store AC in M BUN 4 or C Branch unconditionally to m BSA 5 or D Save return address in m and branch to m+1 ISZ 6 or E Increment M and skip if zero CLA 7800 Clear AC CLE 7400 Clear E CMA 7200 Complement AC CME 7100 Complement E CIR 7080 Circulate right E and AC CIL 7040 Circulate left E and AC INC 7020 Increment AC, carry to E SPA 7010 Skip if AC is positive SNA 7008 Skip if AC is negative SZA 7004 Skip if AC is zero SZE 7002 Skip if E is zero HLT 7001 Halt computer INP F800 Input information and clear flag OUT F400 Output information and clear flag SKI F200 Skip if input flag is on SKO F100 Skip if output flag is on ION F080 Turn interrupt on IOF F040 Turn interrupt off Instruction Set of the Basic Computer
  • 3. 3 Programming the Basic Computer Computer Organization 6.2. MACHINE LANGUAGE Program: is a list of instructions or statements for directing the computer to perform a required data processing task Various types of programming languages - Hierarchy of programming languages • Machine-language - Binary code - Octal or hexadecimal code • Assembly-language (Assembler) - Symbolic code • High-level language (Compiler) Machine Language
  • 4. 4 Programming the Basic Computer Computer Organization COMPARISON OF PROGRAMMING LANGUAGES Machine Language Add two numbers in C/C++ Int A,B,C; Cin >> A; Cin >> B; C = A + B; ORG 0 /Origin of program is location 0 LDA A /Load operand from location A ADD B /Add operand from location B STA C /Store sum in location C HLT /Halt computer A, DEC 83 /Decimal operand B, DEC -23 /Decimal operand C, DEC 0 /Sum stored in location C END /End of symbolic program • Assembly-Language Program 000 LDA 004 Load 1st operand into AC 001 ADD 005 Add 2nd operand to AC 002 STA 006 Store sum in location 006 003 HLT Halt computer 004 0053 1st operand 005 FFE9 2nd operand (negative) 006 0000 Store sum here • Program with Symbolic OP-Code 000 2004 001 1005 002 3006 003 7001 004 0053 005 FFE9 006 0000 • Hex program
  • 5. 5 Programming the Basic Computer Computer Organization COMPARISON OF PROGRAMMING LANGUAGES Machine Language 000 LDA 004 Load 1st operand into AC 001 ADD 005 Add 2nd operand to AC 002 STA 006 Store sum in location 006 003 HLT Halt computer 004 0053 1st operand 005 FFE9 2nd operand (negative) 006 0000 Store sum here • Program with Symbolic OP-Code 000 2004 001 1005 002 3006 003 7001 004 0053 005 FFE9 006 0000 • Hex program 0 0010 0000 0000 0100 1 0001 0000 0000 0101 10 0011 0000 0000 0110 11 0111 0000 0000 0001 100 0000 0000 0101 0011 101 1111 1111 1110 1001 110 0000 0000 0000 0000 • Binary Program to Add Two Numbers
  • 6. 6 Programming the Basic Computer Computer Organization 6.3. ASSEMBLY LANGUAGE Syntax of the BC assembly language: Each line is arranged in three columns called fields: Assembly Language 2. Instruction field - Specifies a machine or a pseudo instruction - May specify one of the * Memory reference instructions (MRI) MRI consists of two or three symbols separated by spaces. ADD OPR (direct address MRI) ADD PTR I (indirect address MRI) * Register reference or input-output instructions Non-MRI does not have an address part * Pseudo instruction with or without an operand - Symbolic address used in the instruction field must be defined as a label 3. Comment field - May be empty or may include a comment 1. Label field - May be empty or may specify a symbolic address of up to 3 characters - Terminated by a comma
  • 7. 7 Programming the Basic Computer Computer Organization PSEUDO-INSTRUCTIONS ORG N Hexadecimal number N is the memory location for the instruction or operand listed in the following line END Denotes the end of symbolic program DEC N Signed decimal number N to be converted to binary HEX N Hexadecimal number N to be converted to binary Example: Assembly language program to subtract two numbers ORG 100 LDA SUB CMA INC ADD MIN STA DIF HLT DEC 83 DEC -23 HEX 0 END / Origin of program is location 100 / Load subtrahend to AC / Complement AC / Increment AC / Add minuend to AC / Store difference / Halt computer / Minuend / Subtrahend / Difference stored here / End of symbolic program MIN, SUB, DIF, Assembly Language
  • 8. 8 Programming the Basic Computer Computer Organization TRANSLATION TO BINARY ORG 100 LDA SUB CMA INC ADD MIN STA DIF HLT DEC 83 DEC -23 HEX 0 END MIN, SUB, DIF, 100 2107 101 7200 102 7020 103 1106 104 3108 105 7001 106 0053 107 FFE9 108 0000 Symbolic Program Location Content Hexadecimal Code Assembly Language Address symbol Hex address MIN 106 SUB 107 DIF 108 Address-Symbol Table
  • 9. 9 Programming the Basic Computer Computer Organization 6.4. ASSEMBLER - FIRST PASS - Assembler Source Program - Symbolic Assembly Language Program Object Program - Binary Machine Language Program Assembler First pass First pass LC  0 Scan next line of code Set LC Label no yes yes no ORG Store symbol in address- symbol table together with value of LC END Increment LC Go to second pass no yes Two pass assembler 1st pass: generates a table that correlates all user defined (address) symbols with their binary equivalent value 2nd pass: binary translation
  • 10. 10 Programming the Basic Computer Computer Organization ASSEMBLER - SECOND PASS - Machine instructions are translated by means of table-lookup procedures: 1. Pseudo-Instruction Table 2. MRI Table 3. Non-MRI Table 4. Address Symbol Table Assembler Second pass LC  0 Scan next line of code Set LC yes yes ORG Pseudo instr. yes END no Done yes MRI no Valid non-MRI instr. no Convert operand to binary and store in location given by LC no DEC or HEX Error in line of code Store binary equivalent of instruction in location given by LC yes no Get operation code and set bits 2-4 Search address- symbol table for binary equivalent of symbol address and set bits 5-16 I Set first bit to 0 Set first bit to 1 yes no Assemble all parts of binary instruction and store in location given by LC Increment LC Second Pass
  • 11. 11 Programming the Basic Computer Computer Organization 6.5. PROGRAM LOOPS Program Loops Loop: A sequence of instructions that are executed many times, each with a different set of data ORG 100 LDA ADS STA PTR LDA NBR STA CTR CLA ADD PTR I ISZ PTR ISZ CTR BUN LOP STA SUM HLT HEX 150 HEX 0 DEC -100 HEX 0 HEX 0 ORG 150 DEC 75 DEC 23 END / Origin of program is HEX 100 / Load first address of operand / Store in pointer / Load -100 / Store in counter / Clear AC / Add an operand to AC / Increment pointer / Increment counter / Repeat loop again / Store sum / Halt / First address of operands / Reserved for a pointer / Initial value for a counter / Reserved for a counter / Sum is stored here / Origin of operands is HEX 150 / First operand / Last operand / End of symbolic program LOP, ADS, PTR, NBR, CTR, SUM, . . . Add 100 numbers: DIMENSION A(100) INTEGER SUM, A SUM = 0 DO 3 J = 1, 100 SUM = SUM + A(J) 3 Fortran program to add 100 numbers:
  • 12. 12 Programming the Basic Computer Computer Organization 6.5. PROGRAM LOOPS DIMENSION A(100) INTEGER SUM, A SUM = 0 DO 3 J = 1, 100 SUM = SUM + A(J) 3 Program Loops Loop: A sequence of instructions that are executed many times, each with a different set of data Fortran program to add 100 numbers: ORG 100 LDA ADS STA PTR LDA NBR STA CTR CLA ADD PTR I ISZ PTR ISZ CTR BUN LOP STA SUM HLT HEX 150 HEX 0 DEC -100 HEX 0 HEX 0 ORG 150 DEC 75 DEC 23 END / Origin of program is HEX 100 / Load first address of operand / Store in pointer / Load -100 / Store in counter / Clear AC / Add an operand to AC / Increment pointer / Increment counter / Repeat loop again / Store sum / Halt / First address of operands / Reserved for a pointer / Initial value for a counter / Reserved for a counter / Sum is stored here / Origin of operands is HEX 150 / First operand / Last operand / End of symbolic program LOP, ADS, PTR, NBR, CTR, SUM, . . . Add 100 numbers:
  • 13. 13 Programming the Basic Computer Computer Organization 6.5. PROGRAM LOOPS DIMENSION A(100) INTEGER SUM, A SUM = 0 DO 3 J = 1, 100 SUM = SUM + A(J) 3 Program Loops Loop: A sequence of instructions that are executed many times, each with a different set of data Fortran program to add 100 numbers: ORG 100 LDA ADS STA PTR LDA NBR STA CTR CLA ADD PTR I ISZ PTR ISZ CTR BUN LOP STA SUM HLT HEX 150 HEX 0 DEC -100 HEX 0 HEX 0 ORG 150 DEC 75 DEC 23 END / Origin of program is HEX 100 / Load first address of operand / Store in pointer / Load -100 / Store in counter / Clear AC / Add an operand to AC / Increment pointer / Increment counter / Repeat loop again / Store sum / Halt / First address of operands / Reserved for a pointer / Initial value for a counter / Reserved for a counter / Sum is stored here / Origin of operands is HEX 150 / First operand / Last operand / End of symbolic program LOP, ADS, PTR, NBR, CTR, SUM, . . . Add 100 numbers:
  • 14. 14 Programming the Basic Computer Computer Organization 6.5. PROGRAM LOOPS DIMENSION A(100) INTEGER SUM, A SUM = 0 DO 3 J = 1, 100 SUM = SUM + A(J) 3 Program Loops Loop: A sequence of instructions that are executed many times, each with a different set of data Fortran program to add 100 numbers: ORG 100 LDA ADS STA PTR LDA NBR STA CTR CLA ADD PTR I ISZ PTR ISZ CTR BUN LOP STA SUM HLT HEX 150 HEX 0 DEC -100 HEX 0 HEX 0 ORG 150 DEC 75 DEC 23 END / Origin of program is HEX 100 / Load first address of operand / Store in pointer / Load -100 / Store in counter / Clear AC / Add an operand to AC / Increment pointer / Increment counter / Repeat loop again / Store sum / Halt / First address of operands / Reserved for a pointer / Initial value for a counter / Reserved for a counter / Sum is stored here / Origin of operands is HEX 150 / First operand / Last operand / End of symbolic program LOP, ADS, PTR, NBR, CTR, SUM, . . . Add 100 numbers:
  • 15. 15 Programming the Basic Computer Computer Organization 6.5. PROGRAM LOOPS DIMENSION A(100) INTEGER SUM, A SUM = 0 DO 3 J = 1, 100 SUM = SUM + A(J) 3 Program Loops Loop: A sequence of instructions that are executed many times, each with a different set of data Fortran program to add 100 numbers: ORG 100 LDA ADS STA PTR LDA NBR STA CTR CLA ADD PTR I ISZ PTR ISZ CTR BUN LOP STA SUM HLT HEX 150 HEX 0 DEC -100 HEX 0 HEX 0 ORG 150 DEC 75 DEC 23 END / Origin of program is HEX 100 / Load first address of operand / Store in pointer / Load -100 / Store in counter / Clear AC / Add an operand to AC / Increment pointer / Increment counter / Repeat loop again / Store sum / Halt / First address of operands / Reserved for a pointer / Initial value for a counter / Reserved for a counter / Sum is stored here / Origin of operands is HEX 150 / First operand / Last operand / End of symbolic program LOP, ADS, PTR, NBR, CTR, SUM, . . . Add 100 numbers:
  • 16. 16 Programming the Basic Computer Computer Organization PROGRAMMING ARITHMETIC AND LOGIC OPERATIONS - Software Implementation - Implementation of an operation with a program using machine instruction set - Usually when the operation is not included in the instruction set - Hardware Implementation - Implementation of an operation in a computer with one machine instruction Software Implementation example: * Multiplication - For simplicity, unsigned positive numbers - 8-bit numbers -> 16-bit product Programming Arithmetic and Logic Operations Implementation of Arithmetic and Logic Operations
  • 17. 17 Programming the Basic Computer Computer Organization FLOWCHART OF A PROGRAM - Multiplication - X holds the multiplicand Y holds the multiplier P holds the product Example with four significant digits 0000 1111 0000 1011 0000 0000 0000 1111 0000 1111 0001 1110 0010 1101 0000 0000 0010 1101 0111 1000 1010 0101 1010 0101 Programming Arithmetic and Logic Operations cil CTR  - 8 P  0 E  0 AC  Y Y  AC cir EAC E P  P + X E  0 AC  X cil EAC X  AC CTR  CTR + 1 =1 =0 CTR =0 Stop  0 X = Y = P
  • 18. 18 Programming the Basic Computer Computer Organization ASSEMBLY LANGUAGE PROGRAM - Multiplication - ORG 100 CLE LDA Y CIR STA Y SZE BUN ONE BUN ZRO LDA X ADD P STA P CLE LDA X CIL STA X ISZ CTR BUN LOP HLT DEC -8 HEX 000F HEX 000B HEX 0 END / Clear E / Load multiplier / Transfer multiplier bit to E / Store shifted multiplier / Check if bit is zero / Bit is one; goto ONE / Bit is zero; goto ZRO / Load multiplicand / Add to partial product / Store partial product / Clear E / Load multiplicand / Shift left / Store shifted multiplicand / Increment counter / Counter not zero; repeat loop / Counter is zero; halt / This location serves as a counter / Multiplicand stored here / Multiplier stored here / Product formed here LOP, ONE, ZRO, CTR, X, Y, P, Programming Arithmetic and Logic Operations cil CTR  - 8 P  0 E  0 AC  Y Y  AC cir EAC E P  P + X E  0 AC  X cil EAC X  AC CTR  CTR + 1 =1 =0 CTR =0 Stop  0
  • 19. 19 Programming the Basic Computer Computer Organization ASSEMBLY LANGUAGE PROGRAM - Double Precision Addition - LDA AL ADD BL STA CL CLA CIL ADD AH ADD BH STA CH HLT AL, --- AH, --- BL, --- BH, --- CL, --- CH, --- / Load A low / Add B low, carry in E / Store in C low / Clear AC / Circulate to bring carry into AC(16) / Add A high and carry / Add B high / Store in C high / Location of operands Programming Arithmetic and Logic Operations
  • 20. 20 Programming the Basic Computer Computer Organization ASSEMBLY LANGUAGE PROGRAM - Logic and Shift Operations - • Logic operations - BC instructions : AND, CMA, CLA LDA A CMA STA TMP LDA B CMA AND TMP CMA / Load 1st operand / Complement to get A’ / Store in a temporary location / Load 2nd operand B / Complement to get B’ / AND with A’ to get A’ AND B’ / Complement again to get A OR B • Shift operations - BC has Circular Shift only CLE SPA CME CIR / Clear E to 0 / Skip if AC is positive / AC is negative / Circulate E and AC CLE CIR Programming Arithmetic and Logic Operations - Program for OR operation - Arithmetic right-shift operation - Logical shift-right operation - Logical shift-left operation CLE CIL
  • 21. 21 Programming the Basic Computer Computer Organization 6.7. SUBROUTINES ORG 100 LDA X BSA SH4 STA X LDA Y BSA SH4 STA Y HLT HEX 1234 HEX 4321 HEX 0 CIL CIL CIL CIL AND MSK BUN SH4 I HEX FFF0 END / Main program / Load X / Branch to subroutine / Store shifted number / Load Y / Branch to subroutine again / Store shifted number / Subroutine to shift left 4 times / Store return address here / Circulate left once / Circulate left fourth time / Set AC(13-16) to zero / Return to main program / Mask operand X, Y, SH4, MSK, 100 101 102 103 104 105 106 107 108 109 10A 10B 10C 10D 10E 10F 110 Loc. Subroutines - A set of common instructions that can be used in a program many times. - Subroutine linkage : a procedure for branching to a subroutine and returning to the main program Subroutine Example return address 0 BSA 109 Next instruction Subroutine 101 102 109 10A 1 BUN 109 Memory 10F
  • 22. 22 Programming the Basic Computer Computer Organization SUBROUTINE PARAMETERS AND DATA LINKAGE ORG 200 LDA X BSA OR HEX 3AF6 STA Y HLT HEX 7B95 HEX 0 HEX 0 CMA STA TMP LDA OR I CMA AND TMP CMA ISZ OR BUN OR I HEX 0 END / Load 1st operand into AC / Branch to subroutine OR / 2nd operand stored here / Subroutine returns here / 1st operand stored here / Result stored here / Subroutine OR / Complement 1st operand / Store in temporary location / Load 2nd operand / Complement 2nd operand / AND complemented 1st operand / Complement again to get OR / Increment return address / Return to main program / Temporary storage X, Y, OR, TMP, 200 201 202 203 204 205 206 207 208 209 20A 20B 20C 20D 20E 20F 210 Loc. Example: Subroutine performing LOGICAL OR operation; Need two parameters Subroutines Linkage of Parameters and Data between the Main Program and a Subroutine - via Registers - via Memory locations
  • 23. 23 Programming the Basic Computer Computer Organization SUBROUTINE - Moving a Block of Data - BSA MVE HEX 100 HEX 200 DEC -16 HLT HEX 0 LDA MVE I STA PT1 ISZ MVE LDA MVE I STA PT2 ISZ MVE LDA MVE I STA CTR ISZ MVE LDA PT1 I STA PT2 I ISZ PT1 ISZ PT2 ISZ CTR BUN LOP BUN MVE I -- -- -- / Main program / Branch to subroutine / 1st address of source data / 1st address of destination data / Number of items to move / Subroutine MVE / Bring address of source / Store in 1st pointer / Increment return address / Bring address of destination / Store in 2nd pointer / Increment return address / Bring number of items / Store in counter / Increment return address / Load source item / Store in destination / Increment source pointer / Increment destination pointer / Increment counter / Repeat 16 times / Return to main program MVE, LOP, PT1, PT2, CTR, • Fortran subroutine SUBROUTINE MVE (SOURCE, DEST, N) DIMENSION SOURCE(N), DEST(N) DO 20 I = 1, N DEST(I) = SOURCE(I) RETURN END 20 Subroutines
  • 24. 24 Programming the Basic Computer Computer Organization 6.8. INPUT OUTPUT PROGRAM Program to Input one Character (Byte) SKI BUN CIF INP OUT STA CHR HLT -- / Check input flag / Flag=0, branch to check again / Flag=1, input character / Display to ensure correctness / Store character / Store character here CIF, CHR, Input Output Program LDA CHR SKO BUN COF OUT HLT HEX 0057 / Load character into AC / Check output flag / Flag=0, branch to check again / Flag=1, output character / Character is "W" COF, CHR, Program to Output a Character
  • 25. 25 Programming the Basic Computer Computer Organization CHARACTER MANIPULATION -- SKI BUN FST INP OUT BSA SH4 BSA SH4 SKI BUN SCD INP OUT BUN IN2 I / Subroutine entry / Input 1st character / Logical Shift left 4 bits / 4 more bits / Input 2nd character / Return IN2, FST, SCD, Subroutine to Input 2 Characters and pack into a word Input Output Program
  • 26. 26 Programming the Basic Computer Computer Organization PROGRAM INTERRUPT Tasks of Interrupt Service Routine - Save the Status of CPU Contents of processor registers and Flags - Identify the source of Interrupt Check which flag is set - Service the device whose flag is set (Input Output Subroutine) - Restore contents of processor registers and flags - Turn the interrupt facility on - Return to the running program Load PC of the interrupted program Input Output Program
  • 27. 27 Programming the Basic Computer Computer Organization INTERRUPT SERVICE ROUTINE - BUN SRV CLA ION LDA X ADD Y STA Z STA SAC CIR STA SE SKI BUN NXT INP OUT STA PT1 I ISZ PT1 SKO BUN EXT LDA PT2 I OUT ISZ PT2 LDA SE CIL LDA SAC ION BUN ZRO I - - - - / Return address stored here / Branch to service routine / Portion of running program / Turn on interrupt facility / Interrupt occurs here / Program returns here after interrupt / Interrupt service routine / Store content of AC / Move E into AC(1) / Store content of E / Check input flag / Flag is off, check next flag / Flag is on, input character / Print character / Store it in input buffer / Increment input pointer / Check output flag / Flag is off, exit / Load character from output buffer / Output character / Increment output pointer / Restore value of AC(1) / Shift it to E / Restore content of AC / Turn interrupt on / Return to running program / AC is stored here / E is stored here / Pointer of input buffer / Pointer of output buffer ZRO, SRV, NXT, EXT, SAC, SE, PT1, PT2, 0 1 100 101 102 103 104 200 Loc. Input Output Program