SlideShare une entreprise Scribd logo
1  sur  26
Programming Basic Computer
• The list of instructions or statements that
directs the computer hardware to perform a
specific task is called a program.
• There are many programming languages but,
the computer basically understands programs
that are given in binary (0s, 1s) form. This
implies that all other programs should be
translated to binary before they can be
executed by the computer..
Classification of Programs
• Binary Code: These are instruction and data that are in 0s
and 1s. They are stored in the computer's main memory as
they do not need any conversions.
• Octal / Hexadecimal code: These are codes or instructions
that are in octal or hexadecimal representation.
• Symbolic Code: This type of programming uses symbols
(numbers, letters or special characters) in place of binary
code.
• High level programming language: These are codes that
are directed at solving problems and not the details of
computer hardware behaviours. e.g. Java, C#, Pascal etc.
They need special software called interpreter or compiler
to convert them into binary code
Machine Language
• These are programs that are written in binary
and stored directly in memory. The octal (3
bits) or hexadecimal (4 bits) that can be easily
converted to binary can also be referred to as
machine language.
Assembly Language
• This uses symbols (English language words) to
write instructions. This is also a low level
language because of the one-to-one
relationship between symbolic instruction and
its binary equivalent. The symbols are referred
to as mnemonics. An assembler is a special
software that converts assembly language
program into binary language program.
Basic symbols (mnemonics) of
assembly language
Symbol Example Explanation
AND AND A Perform AND logic operation on A with value of AC
ADD ADD A Add the value of variable A to AC, and carry bit to E flip flop
LDA LDA M Load value of M into AC
STA STA M Store value of AC in M
BUN BUN TT Branch unconditionally to location TT
BSA BSA TT Save the return address in location TT and branch to TT+1
ISZ ISZ T Increment T and skip next instruction (if T = 0)
CLA CLA Clear Accumulator (AC)
CLE CLE Clear E
CMA CMA Complement AC (first complement)
INC INC Increment AC
SPA SPA Skip next instruction if AC is positive
SNA SNA Skip next instruction if AC is negative
HLT HLT Halt computer
Mnemonics of Assembly Language
Mnemonics Example Explanation
INP INP Get information from some input device
OUT OUT Put information to some output device
SKI SKI Skip next instruction if input flag is ON
SKO SKO Skip next instruction if output flag is ON
ION ION Turn interrupt ON
IOF IOF Turn interrupt OFF
CALL CALL SUB Call subroutine which starts at location SUB
RET RET Return to main program
MOV MOV A, B Transfer the value of register B to register A
Pseudo instruction (Assembler
Directive)
• These are false (pseudo) instructions that do not have
equivalent binary form but serve various functions. They do
not refer to an operation that will be performed by the
program during execution, rather it is a message to the
assembler to help the assembler in the assembly process.
E.g.
• ORG T, T is the memory location where the first instruction
of the program must be stored.
• END, Specifies the end of the program
• DEC T, T is a decimal number that needs to be converted
into binary by the assembler
• HEX T, T is a hexadecimal number that needs to be
converted into its equivalent binary using 4bits.
Rules of the Assembly Language
• Each line of code must be divided into four fields.
i.e. Label, instruction, operand & comment.
• Label: This is a one to three alphanumeric
characters (symbolic address) that specifies the
location of the instruction in memory. It should
be terminated with a comma (,) to enable the
assembler recognize it as a label. The first
character should be an alphabet and the rest
either alphabets or numerals. A line with ORG or
END should not have a label.
Rules of the Assembly Language
• A symbolic address in the instruction field
should specify the memory location of an
operand. This symbolic address must appear
again as a label, later in the program.
• Instruction field. This specifies a mnemonic
(pseudo) instruction.
Rules of the Assembly Language
• Comment: Explains what each line of code
does for easy understanding and explanation.
Each comment must be preceded by /. This
helps the assembler recognize the beginning
of a program. It can be left empty.
Programming in Assembly Language
• Write a program in assembly language to store
15 at memory location T
Code Comment
ORG 0 /Origin of the program in location zero
LDA A /Load operand (15) from A
STA T /Store operand (15) in memory location T
HLT /Halt computer
A, DEC 15 /Decimal operand with value 15
T DEC 0 /Value 15 will be stored at T
END /End of symbolic program
Programming in Assembly Language
• Write a program in assembly language to add
two decimal numbers (14 and -7) in memory
locations A and B.
NB. We first have to bring the first operand to
AC. Using the ADD instruction, we add the
second operand with the content of AC. The
result is then stored in AC. However to store
the result we use STA.
Programming in Assembly Language
• . Label Code Description
ORG 0 /Origin of program in location zero
BUN T /Branch unconditionally to location T
LDA A /Load operand in accumulator from memory
location A
ADD B /Add operand from memory location B
STA SUM /Store the sum in location SUM
HLT /Halt Computer
A DEC 14 /Decimal operand with value 14
B DEC -7 /Decimal operand with value -7
SUM DEC 0 /Sum of A and B will be stored in AC, initial value of
SUM is 0
END /End of symbolic program.
Flow chart
• Flow chart for adding two decimal numbers
Specify the location where the program must be stored
in memory
Specify the memory location of first operand
Specify the memory location of second operand
Add second operand with first operand , already in AC
Specify the memory location where the result from AC
is to be stored
Load the first operand in AC
Assembly language to subtract two
numbers A – B (14 - 10)
Label Code Description
ORG 100 /Origin of program is 100
LDA SUB /Load subtrahend to AC (B)
CMA /Complement AC (-B)
INC /Increment AC
ADD MIN /Add minuend to AC (A)
STA DIF /Store the difference in memory location DIF
HLT /Halt computer
MIN, DEC 14 /Minuend with decimal 14 (A)
SUB DEC 10 /Subtrahend with decimal 10 (B)
DIF DEC 0 /Result of the difference is stored here
END /End of symbolic program.
Flow chart for subtracting two
numbers A – B = A + (-B)
Specify the memory location where the program must be stored
Specify memory location of subtrahend (B)
Load the subtrahend in AC
Complement value stored in AC
Increment value in AC by 1 (get - B)
Specify location where minuend is stored in memory (A)
Add the minuend to value in AC (A +(-B))
Specify the location where the result will be stored in memory
Calculating
2s complement
The negative of a
number is obtained
by calculating its
2s complement. This is
done by adding 1 to its
1s complement
Assembly language- Looping
• Program loop (looping) is a sequence of instructions
that are executed repeatedly, each time with a
different set of data and the new result stored. E.g.
2.....
Int x, y;
X = 10; y = 20;
If (x<y)
system.out.println(“x is
less than y”);
x = x +2;
If (x == y)
System.out.println(“now x
is equal to y”);
}
}
1)........
Int x;
X = 3;
If (x < 10)
x = x +1;
else
System.out.println(x);
}
}
3...
int x;
for(x=0; x<10; x++)
System.out.println (“x is:”+ x);
}
}
Program to add 50 numbers
• To add 50 numbers we will have to use
looping by repeatedly performing addition (50
times) with each of the 50 operands and
storing the result in AC each time. We assume
that the operands are stored in consecutive
memory location so that we can get the
operand by incrementing the address
Assembly language program to add 50 numbers
Line no Label Code Description
1 ORG 50 /Origin of program is HEX 50
2 LDA ADS /Load address of first operand
3 STA PTR /Store address in memory location called (PTR) pointer
4 LDA NBR /Load -50 into AC
5 STA CTR /Store the value in AC at CTR (counter)
6 CLA /Clear accumulator
7 LOP, ADD PTR I /Add an operand to AC
8 ISZ PTR /Increment pointer
9 ISZ CTR /Increment counter
10 BUN LOP /Repeat loop again, AC gets nos added and store result
11 STR SUM /Store sum
12 HLT /Halt computer
Assembly language program to add 50 numbers
Line no. Label Code Description
13 ADS, HEX 50 /Address of first operand
14 PTR, HEX 0 /Location reserved for pointer
15 NBR, DEC -50 /Initialise counter
16 CTR, HEX 0 /Location reserved for counter
17 SUM, HEX 0 /Sum is stored here
18 ORG 100 /Origin of operands is from memory location 100
19 DEC 30 /First operand (i.e. 30)
.
.
68 DEC 14 /Last operand (50th number is 14)
69 END /End of symbolic program
Flow chart for adding 100 numbers
• .
Specify the memory location where program is to be stored
Specify the memory location where the address of 1st operand is stored
Load this address into AC
Store address (in AC) in a memory location. Let the location be PTR
Similarly, store -50 (counter variable) in a memory loc. called CTR
Set AC 0
Take address from PTR. Fetch the operand stored at
this address and add it to the value in AC
Increment PTR by 1
Increment CTR by 1
Is CTR = 0 ?
Store the value in AC at location named SUM
No
Yes
Compute X+Y and store the result at Z
(OR) Logic operations.
Label Code Description
ORG 0 /Origin of program at memory location 0
LDA X /Load first operand a
CMA /Complement A to get Ā
STA TMP /Store Ā in a temporary location TMP
LDA Y /Load second operand B
CMA /Complement B to get B̄
AND TMP /AND with Ā to get Ā.B̄
CMA /Complement (Ā.B̄) to get (A + B)
HLT /Halt computer
X, 1011 /First operand is stored here
Y, 1000 /Second operand stored here
TMP, 0000 /Temporary location to store Ā
END
Flow chart for logic OR operation
Load X into AC
Complement value in AC
Store the value of AC in TMP
Load Y into AC
Complement value in AC
AND value with TMP
Complement value in AC
Store value of AC in Z
Imperative, Declarative and Directive
Statements
• Imperative statement. Indicates actions to be performed
during execution of the assembled program. E.g.
LDA A, STA, ADD, ISZ C
• Declarative statement. Declares constants or storage
locations or area in a program. E.g
T DS 30
declares a storage area of 30 words and indicates that the
storage area must be called T. T is the first word of the
operand. To access the 6th word for example, use T + 5.
Alternative an index can be used. T(k) where k is the index
number of item to be accessed. E.g T(6) the seventh
number as it starts from 0 i.e. T(0) is the first element.
Directive
• Assembler directive statement, directs the
assembler to take certain actions during the
process of assembling a program. E.g. ORG
’10’ indicates that the first word of the
program must be placed at memory location
‘10’. Also END indicates that no more
assembly language statements remain to be
processed.
Program to show all codes
.
Label Code comments
ORG 0 (Directive) /Store program at location 0
LDA A (Imperative) /Load the value stored at memory location
A
STA B (Imperative) /Store the value at A in the location B
A DC ‘1500’ (Declarative) /Declare a constant 1500 named A
B DS 1 (Declarative) /Declare a storage location called ‘B’
capable of storing 1 word
END (Directive) /End program

Contenu connexe

Tendances

Interrupts on 8086 microprocessor by vijay kumar.k
Interrupts on 8086 microprocessor by vijay kumar.kInterrupts on 8086 microprocessor by vijay kumar.k
Interrupts on 8086 microprocessor by vijay kumar.kVijay Kumar
 
Register organization, stack
Register organization, stackRegister organization, stack
Register organization, stackAsif Iqbal
 
Architecture of 8086 Microprocessor
Architecture of 8086 Microprocessor  Architecture of 8086 Microprocessor
Architecture of 8086 Microprocessor Mustapha Fatty
 
COMPUTER INSTRUCTIONS & TIMING & CONTROL.
COMPUTER INSTRUCTIONS & TIMING & CONTROL.COMPUTER INSTRUCTIONS & TIMING & CONTROL.
COMPUTER INSTRUCTIONS & TIMING & CONTROL.ATUL KUMAR YADAV
 
Computer architecture and organization
Computer architecture and organizationComputer architecture and organization
Computer architecture and organizationTushar B Kute
 
8086 microprocessor-architecture
8086 microprocessor-architecture8086 microprocessor-architecture
8086 microprocessor-architectureprasadpawaskar
 
Micro programmed control
Micro programmed  controlMicro programmed  control
Micro programmed controlShashank Singh
 
Input Output Operations
Input Output OperationsInput Output Operations
Input Output Operationskdisthere
 
PAI Unit 2 Protection in 80386 segmentation
PAI Unit 2 Protection in 80386 segmentationPAI Unit 2 Protection in 80386 segmentation
PAI Unit 2 Protection in 80386 segmentationKanchanPatil34
 
Computer architecture pipelining
Computer architecture pipeliningComputer architecture pipelining
Computer architecture pipeliningMazin Alwaaly
 
General register organization (computer organization)
General register organization  (computer organization)General register organization  (computer organization)
General register organization (computer organization)rishi ram khanal
 
Memory Segmentation of 8086
Memory Segmentation of 8086Memory Segmentation of 8086
Memory Segmentation of 8086Nikhil Kumar
 
MICROCONTROLLER 8051- Architecture & Pin Configuration
MICROCONTROLLER 8051- Architecture & Pin Configuration MICROCONTROLLER 8051- Architecture & Pin Configuration
MICROCONTROLLER 8051- Architecture & Pin Configuration AKHIL MADANKAR
 
Microprogram Control
Microprogram Control Microprogram Control
Microprogram Control Anuj Modi
 
Processor Organization and Architecture
Processor Organization and ArchitectureProcessor Organization and Architecture
Processor Organization and ArchitectureVinit Raut
 
Addressing modes of 8086
Addressing modes of 8086Addressing modes of 8086
Addressing modes of 8086Dr. AISHWARYA N
 
Branching instructions in 8086 microprocessor
Branching instructions in 8086 microprocessorBranching instructions in 8086 microprocessor
Branching instructions in 8086 microprocessorRabin BK
 

Tendances (20)

Interrupts on 8086 microprocessor by vijay kumar.k
Interrupts on 8086 microprocessor by vijay kumar.kInterrupts on 8086 microprocessor by vijay kumar.k
Interrupts on 8086 microprocessor by vijay kumar.k
 
Register organization, stack
Register organization, stackRegister organization, stack
Register organization, stack
 
Architecture of 8086 Microprocessor
Architecture of 8086 Microprocessor  Architecture of 8086 Microprocessor
Architecture of 8086 Microprocessor
 
COMPUTER INSTRUCTIONS & TIMING & CONTROL.
COMPUTER INSTRUCTIONS & TIMING & CONTROL.COMPUTER INSTRUCTIONS & TIMING & CONTROL.
COMPUTER INSTRUCTIONS & TIMING & CONTROL.
 
Computer architecture and organization
Computer architecture and organizationComputer architecture and organization
Computer architecture and organization
 
8086 microprocessor-architecture
8086 microprocessor-architecture8086 microprocessor-architecture
8086 microprocessor-architecture
 
Micro programmed control
Micro programmed  controlMicro programmed  control
Micro programmed control
 
Arm instruction set
Arm instruction setArm instruction set
Arm instruction set
 
Input Output Operations
Input Output OperationsInput Output Operations
Input Output Operations
 
PAI Unit 2 Protection in 80386 segmentation
PAI Unit 2 Protection in 80386 segmentationPAI Unit 2 Protection in 80386 segmentation
PAI Unit 2 Protection in 80386 segmentation
 
Computer architecture pipelining
Computer architecture pipeliningComputer architecture pipelining
Computer architecture pipelining
 
General register organization (computer organization)
General register organization  (computer organization)General register organization  (computer organization)
General register organization (computer organization)
 
Memory Segmentation of 8086
Memory Segmentation of 8086Memory Segmentation of 8086
Memory Segmentation of 8086
 
MICROCONTROLLER 8051- Architecture & Pin Configuration
MICROCONTROLLER 8051- Architecture & Pin Configuration MICROCONTROLLER 8051- Architecture & Pin Configuration
MICROCONTROLLER 8051- Architecture & Pin Configuration
 
8086 signals
8086 signals8086 signals
8086 signals
 
Microprogram Control
Microprogram Control Microprogram Control
Microprogram Control
 
Intel Pentium Pro
Intel Pentium ProIntel Pentium Pro
Intel Pentium Pro
 
Processor Organization and Architecture
Processor Organization and ArchitectureProcessor Organization and Architecture
Processor Organization and Architecture
 
Addressing modes of 8086
Addressing modes of 8086Addressing modes of 8086
Addressing modes of 8086
 
Branching instructions in 8086 microprocessor
Branching instructions in 8086 microprocessorBranching instructions in 8086 microprocessor
Branching instructions in 8086 microprocessor
 

Similaire à Programming basic computer

Programming the basic computer
Programming the basic computerProgramming the basic computer
Programming the basic computerKamal Acharya
 
CH-3 CO-all-about-operating-system(Update).pptx
CH-3 CO-all-about-operating-system(Update).pptxCH-3 CO-all-about-operating-system(Update).pptx
CH-3 CO-all-about-operating-system(Update).pptxXyzXyz338506
 
Bca 2nd sem-u-3.1-basic computer programming and micro programmed control
Bca 2nd sem-u-3.1-basic computer programming and micro programmed controlBca 2nd sem-u-3.1-basic computer programming and micro programmed control
Bca 2nd sem-u-3.1-basic computer programming and micro programmed controlRai University
 
B.sc cs-ii-u-3.1-basic computer programming and micro programmed control
B.sc cs-ii-u-3.1-basic computer programming and micro programmed controlB.sc cs-ii-u-3.1-basic computer programming and micro programmed control
B.sc cs-ii-u-3.1-basic computer programming and micro programmed controlRai University
 
basic computer programming and micro programmed control
basic computer programming and micro programmed controlbasic computer programming and micro programmed control
basic computer programming and micro programmed controlRai University
 
Mca i-u-3-basic computer programming and micro programmed control
Mca i-u-3-basic computer programming and micro programmed controlMca i-u-3-basic computer programming and micro programmed control
Mca i-u-3-basic computer programming and micro programmed controlRai University
 
Computer Organization and 8085 microprocessor notes
Computer Organization and 8085 microprocessor notesComputer Organization and 8085 microprocessor notes
Computer Organization and 8085 microprocessor notesLakshmi Sarvani Videla
 
Unit 3 assembler and processor
Unit 3   assembler and processorUnit 3   assembler and processor
Unit 3 assembler and processorAbha Damani
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Bilal Amjad
 
Part III: Assembly Language
Part III: Assembly LanguagePart III: Assembly Language
Part III: Assembly LanguageAhmed M. Abed
 
Computer Organization - Programming the basic computer : Machine Language, As...
Computer Organization - Programming the basic computer : Machine Language, As...Computer Organization - Programming the basic computer : Machine Language, As...
Computer Organization - Programming the basic computer : Machine Language, As...Maitri Thakkar
 
Microprocessor chapter 9 - assembly language programming
Microprocessor  chapter 9 - assembly language programmingMicroprocessor  chapter 9 - assembly language programming
Microprocessor chapter 9 - assembly language programmingWondeson Emeye
 

Similaire à Programming basic computer (20)

CH06 (1).PPT
CH06 (1).PPTCH06 (1).PPT
CH06 (1).PPT
 
Programming the basic computer
Programming the basic computerProgramming the basic computer
Programming the basic computer
 
CH-3 CO-all-about-operating-system(Update).pptx
CH-3 CO-all-about-operating-system(Update).pptxCH-3 CO-all-about-operating-system(Update).pptx
CH-3 CO-all-about-operating-system(Update).pptx
 
Bca 2nd sem-u-3.1-basic computer programming and micro programmed control
Bca 2nd sem-u-3.1-basic computer programming and micro programmed controlBca 2nd sem-u-3.1-basic computer programming and micro programmed control
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
B.sc cs-ii-u-3.1-basic computer programming and micro programmed controlB.sc cs-ii-u-3.1-basic computer programming and micro programmed control
B.sc cs-ii-u-3.1-basic computer programming and micro programmed control
 
basic computer programming and micro programmed control
basic computer programming and micro programmed controlbasic computer programming and micro programmed control
basic computer programming and micro programmed control
 
Mca i-u-3-basic computer programming and micro programmed control
Mca i-u-3-basic computer programming and micro programmed controlMca i-u-3-basic computer programming and micro programmed control
Mca i-u-3-basic computer programming and micro programmed control
 
Wk1to4
Wk1to4Wk1to4
Wk1to4
 
Alp 05
Alp 05Alp 05
Alp 05
 
Alp 05
Alp 05Alp 05
Alp 05
 
Alp 05
Alp 05Alp 05
Alp 05
 
Computer Organization
Computer Organization Computer Organization
Computer Organization
 
Computer Organization and 8085 microprocessor notes
Computer Organization and 8085 microprocessor notesComputer Organization and 8085 microprocessor notes
Computer Organization and 8085 microprocessor notes
 
Unit 3 assembler and processor
Unit 3   assembler and processorUnit 3   assembler and processor
Unit 3 assembler and processor
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
 
12 mt06ped008
12 mt06ped008 12 mt06ped008
12 mt06ped008
 
Part III: Assembly Language
Part III: Assembly LanguagePart III: Assembly Language
Part III: Assembly Language
 
Computer Organization - Programming the basic computer : Machine Language, As...
Computer Organization - Programming the basic computer : Machine Language, As...Computer Organization - Programming the basic computer : Machine Language, As...
Computer Organization - Programming the basic computer : Machine Language, As...
 
UNIT-3.pptx
UNIT-3.pptxUNIT-3.pptx
UNIT-3.pptx
 
Microprocessor chapter 9 - assembly language programming
Microprocessor  chapter 9 - assembly language programmingMicroprocessor  chapter 9 - assembly language programming
Microprocessor chapter 9 - assembly language programming
 

Dernier

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 

Dernier (20)

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 

Programming basic computer

  • 1. Programming Basic Computer • The list of instructions or statements that directs the computer hardware to perform a specific task is called a program. • There are many programming languages but, the computer basically understands programs that are given in binary (0s, 1s) form. This implies that all other programs should be translated to binary before they can be executed by the computer..
  • 2. Classification of Programs • Binary Code: These are instruction and data that are in 0s and 1s. They are stored in the computer's main memory as they do not need any conversions. • Octal / Hexadecimal code: These are codes or instructions that are in octal or hexadecimal representation. • Symbolic Code: This type of programming uses symbols (numbers, letters or special characters) in place of binary code. • High level programming language: These are codes that are directed at solving problems and not the details of computer hardware behaviours. e.g. Java, C#, Pascal etc. They need special software called interpreter or compiler to convert them into binary code
  • 3. Machine Language • These are programs that are written in binary and stored directly in memory. The octal (3 bits) or hexadecimal (4 bits) that can be easily converted to binary can also be referred to as machine language.
  • 4. Assembly Language • This uses symbols (English language words) to write instructions. This is also a low level language because of the one-to-one relationship between symbolic instruction and its binary equivalent. The symbols are referred to as mnemonics. An assembler is a special software that converts assembly language program into binary language program.
  • 5. Basic symbols (mnemonics) of assembly language Symbol Example Explanation AND AND A Perform AND logic operation on A with value of AC ADD ADD A Add the value of variable A to AC, and carry bit to E flip flop LDA LDA M Load value of M into AC STA STA M Store value of AC in M BUN BUN TT Branch unconditionally to location TT BSA BSA TT Save the return address in location TT and branch to TT+1 ISZ ISZ T Increment T and skip next instruction (if T = 0) CLA CLA Clear Accumulator (AC) CLE CLE Clear E CMA CMA Complement AC (first complement) INC INC Increment AC SPA SPA Skip next instruction if AC is positive SNA SNA Skip next instruction if AC is negative HLT HLT Halt computer
  • 6. Mnemonics of Assembly Language Mnemonics Example Explanation INP INP Get information from some input device OUT OUT Put information to some output device SKI SKI Skip next instruction if input flag is ON SKO SKO Skip next instruction if output flag is ON ION ION Turn interrupt ON IOF IOF Turn interrupt OFF CALL CALL SUB Call subroutine which starts at location SUB RET RET Return to main program MOV MOV A, B Transfer the value of register B to register A
  • 7. Pseudo instruction (Assembler Directive) • These are false (pseudo) instructions that do not have equivalent binary form but serve various functions. They do not refer to an operation that will be performed by the program during execution, rather it is a message to the assembler to help the assembler in the assembly process. E.g. • ORG T, T is the memory location where the first instruction of the program must be stored. • END, Specifies the end of the program • DEC T, T is a decimal number that needs to be converted into binary by the assembler • HEX T, T is a hexadecimal number that needs to be converted into its equivalent binary using 4bits.
  • 8. Rules of the Assembly Language • Each line of code must be divided into four fields. i.e. Label, instruction, operand & comment. • Label: This is a one to three alphanumeric characters (symbolic address) that specifies the location of the instruction in memory. It should be terminated with a comma (,) to enable the assembler recognize it as a label. The first character should be an alphabet and the rest either alphabets or numerals. A line with ORG or END should not have a label.
  • 9. Rules of the Assembly Language • A symbolic address in the instruction field should specify the memory location of an operand. This symbolic address must appear again as a label, later in the program. • Instruction field. This specifies a mnemonic (pseudo) instruction.
  • 10. Rules of the Assembly Language • Comment: Explains what each line of code does for easy understanding and explanation. Each comment must be preceded by /. This helps the assembler recognize the beginning of a program. It can be left empty.
  • 11. Programming in Assembly Language • Write a program in assembly language to store 15 at memory location T Code Comment ORG 0 /Origin of the program in location zero LDA A /Load operand (15) from A STA T /Store operand (15) in memory location T HLT /Halt computer A, DEC 15 /Decimal operand with value 15 T DEC 0 /Value 15 will be stored at T END /End of symbolic program
  • 12. Programming in Assembly Language • Write a program in assembly language to add two decimal numbers (14 and -7) in memory locations A and B. NB. We first have to bring the first operand to AC. Using the ADD instruction, we add the second operand with the content of AC. The result is then stored in AC. However to store the result we use STA.
  • 13. Programming in Assembly Language • . Label Code Description ORG 0 /Origin of program in location zero BUN T /Branch unconditionally to location T LDA A /Load operand in accumulator from memory location A ADD B /Add operand from memory location B STA SUM /Store the sum in location SUM HLT /Halt Computer A DEC 14 /Decimal operand with value 14 B DEC -7 /Decimal operand with value -7 SUM DEC 0 /Sum of A and B will be stored in AC, initial value of SUM is 0 END /End of symbolic program.
  • 14. Flow chart • Flow chart for adding two decimal numbers Specify the location where the program must be stored in memory Specify the memory location of first operand Specify the memory location of second operand Add second operand with first operand , already in AC Specify the memory location where the result from AC is to be stored Load the first operand in AC
  • 15. Assembly language to subtract two numbers A – B (14 - 10) Label Code Description ORG 100 /Origin of program is 100 LDA SUB /Load subtrahend to AC (B) CMA /Complement AC (-B) INC /Increment AC ADD MIN /Add minuend to AC (A) STA DIF /Store the difference in memory location DIF HLT /Halt computer MIN, DEC 14 /Minuend with decimal 14 (A) SUB DEC 10 /Subtrahend with decimal 10 (B) DIF DEC 0 /Result of the difference is stored here END /End of symbolic program.
  • 16. Flow chart for subtracting two numbers A – B = A + (-B) Specify the memory location where the program must be stored Specify memory location of subtrahend (B) Load the subtrahend in AC Complement value stored in AC Increment value in AC by 1 (get - B) Specify location where minuend is stored in memory (A) Add the minuend to value in AC (A +(-B)) Specify the location where the result will be stored in memory Calculating 2s complement The negative of a number is obtained by calculating its 2s complement. This is done by adding 1 to its 1s complement
  • 17. Assembly language- Looping • Program loop (looping) is a sequence of instructions that are executed repeatedly, each time with a different set of data and the new result stored. E.g. 2..... Int x, y; X = 10; y = 20; If (x<y) system.out.println(“x is less than y”); x = x +2; If (x == y) System.out.println(“now x is equal to y”); } } 1)........ Int x; X = 3; If (x < 10) x = x +1; else System.out.println(x); } } 3... int x; for(x=0; x<10; x++) System.out.println (“x is:”+ x); } }
  • 18. Program to add 50 numbers • To add 50 numbers we will have to use looping by repeatedly performing addition (50 times) with each of the 50 operands and storing the result in AC each time. We assume that the operands are stored in consecutive memory location so that we can get the operand by incrementing the address
  • 19. Assembly language program to add 50 numbers Line no Label Code Description 1 ORG 50 /Origin of program is HEX 50 2 LDA ADS /Load address of first operand 3 STA PTR /Store address in memory location called (PTR) pointer 4 LDA NBR /Load -50 into AC 5 STA CTR /Store the value in AC at CTR (counter) 6 CLA /Clear accumulator 7 LOP, ADD PTR I /Add an operand to AC 8 ISZ PTR /Increment pointer 9 ISZ CTR /Increment counter 10 BUN LOP /Repeat loop again, AC gets nos added and store result 11 STR SUM /Store sum 12 HLT /Halt computer
  • 20. Assembly language program to add 50 numbers Line no. Label Code Description 13 ADS, HEX 50 /Address of first operand 14 PTR, HEX 0 /Location reserved for pointer 15 NBR, DEC -50 /Initialise counter 16 CTR, HEX 0 /Location reserved for counter 17 SUM, HEX 0 /Sum is stored here 18 ORG 100 /Origin of operands is from memory location 100 19 DEC 30 /First operand (i.e. 30) . . 68 DEC 14 /Last operand (50th number is 14) 69 END /End of symbolic program
  • 21. Flow chart for adding 100 numbers • . Specify the memory location where program is to be stored Specify the memory location where the address of 1st operand is stored Load this address into AC Store address (in AC) in a memory location. Let the location be PTR Similarly, store -50 (counter variable) in a memory loc. called CTR Set AC 0 Take address from PTR. Fetch the operand stored at this address and add it to the value in AC Increment PTR by 1 Increment CTR by 1 Is CTR = 0 ? Store the value in AC at location named SUM No Yes
  • 22. Compute X+Y and store the result at Z (OR) Logic operations. Label Code Description ORG 0 /Origin of program at memory location 0 LDA X /Load first operand a CMA /Complement A to get Ā STA TMP /Store Ā in a temporary location TMP LDA Y /Load second operand B CMA /Complement B to get B̄ AND TMP /AND with Ā to get Ā.B̄ CMA /Complement (Ā.B̄) to get (A + B) HLT /Halt computer X, 1011 /First operand is stored here Y, 1000 /Second operand stored here TMP, 0000 /Temporary location to store Ā END
  • 23. Flow chart for logic OR operation Load X into AC Complement value in AC Store the value of AC in TMP Load Y into AC Complement value in AC AND value with TMP Complement value in AC Store value of AC in Z
  • 24. Imperative, Declarative and Directive Statements • Imperative statement. Indicates actions to be performed during execution of the assembled program. E.g. LDA A, STA, ADD, ISZ C • Declarative statement. Declares constants or storage locations or area in a program. E.g T DS 30 declares a storage area of 30 words and indicates that the storage area must be called T. T is the first word of the operand. To access the 6th word for example, use T + 5. Alternative an index can be used. T(k) where k is the index number of item to be accessed. E.g T(6) the seventh number as it starts from 0 i.e. T(0) is the first element.
  • 25. Directive • Assembler directive statement, directs the assembler to take certain actions during the process of assembling a program. E.g. ORG ’10’ indicates that the first word of the program must be placed at memory location ‘10’. Also END indicates that no more assembly language statements remain to be processed.
  • 26. Program to show all codes . Label Code comments ORG 0 (Directive) /Store program at location 0 LDA A (Imperative) /Load the value stored at memory location A STA B (Imperative) /Store the value at A in the location B A DC ‘1500’ (Declarative) /Declare a constant 1500 named A B DS 1 (Declarative) /Declare a storage location called ‘B’ capable of storing 1 word END (Directive) /End program

Notes de l'éditeur

  1. Assembler is a software that converts assembly language program into binary language program
  2. Why is a label terminated with a comma.
  3. STRONT CONTESTANT FOR ...........................