SlideShare uma empresa Scribd logo
1 de 26
Baixar para ler offline
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

Mais conteúdo relacionado

Mais procurados

General register organization (computer organization)
General register organization  (computer organization)General register organization  (computer organization)
General register organization (computer organization)rishi ram khanal
 
Part I:Introduction to assembly language
Part I:Introduction to assembly languagePart I:Introduction to assembly language
Part I:Introduction to assembly languageAhmed M. Abed
 
Subroutine & string in 8086 Microprocessor
Subroutine & string in 8086 MicroprocessorSubroutine & string in 8086 Microprocessor
Subroutine & string in 8086 MicroprocessorMustafa AL-Timemmie
 
Chapter 3 instruction set-of-8085
Chapter 3 instruction set-of-8085Chapter 3 instruction set-of-8085
Chapter 3 instruction set-of-8085Shubham Singh
 
Register transfer language
Register transfer languageRegister transfer language
Register transfer languageSanjeev Patel
 
Operand and Opcode | Computer Science
Operand and Opcode | Computer ScienceOperand and Opcode | Computer Science
Operand and Opcode | Computer ScienceTransweb Global Inc
 
Register transfer and micro-operation
Register transfer and micro-operationRegister transfer and micro-operation
Register transfer and micro-operationNikhil Pandit
 
Assembly Language Programming Of 8085
Assembly Language Programming Of 8085Assembly Language Programming Of 8085
Assembly Language Programming Of 8085techbed
 
Addressing mode Computer Architecture
Addressing mode  Computer ArchitectureAddressing mode  Computer Architecture
Addressing mode Computer ArchitectureHaris456
 
Counters &amp; time delay
Counters &amp; time delayCounters &amp; time delay
Counters &amp; time delayHemant Chetwani
 
Addressing mode
Addressing modeAddressing mode
Addressing modeilakkiya
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...Bilal Amjad
 
Computer architecture instruction formats
Computer architecture instruction formatsComputer architecture instruction formats
Computer architecture instruction formatsMazin Alwaaly
 

Mais procurados (20)

General register organization (computer organization)
General register organization  (computer organization)General register organization  (computer organization)
General register organization (computer organization)
 
Programming with 8085
Programming with 8085Programming with 8085
Programming with 8085
 
Part I:Introduction to assembly language
Part I:Introduction to assembly languagePart I:Introduction to assembly language
Part I:Introduction to assembly language
 
First pass of assembler
First pass of assemblerFirst pass of assembler
First pass of assembler
 
Subroutine & string in 8086 Microprocessor
Subroutine & string in 8086 MicroprocessorSubroutine & string in 8086 Microprocessor
Subroutine & string in 8086 Microprocessor
 
Chapter 3 instruction set-of-8085
Chapter 3 instruction set-of-8085Chapter 3 instruction set-of-8085
Chapter 3 instruction set-of-8085
 
8086 alp
8086 alp8086 alp
8086 alp
 
Register transfer language
Register transfer languageRegister transfer language
Register transfer language
 
Operand and Opcode | Computer Science
Operand and Opcode | Computer ScienceOperand and Opcode | Computer Science
Operand and Opcode | Computer Science
 
Registers
RegistersRegisters
Registers
 
Register transfer and micro-operation
Register transfer and micro-operationRegister transfer and micro-operation
Register transfer and micro-operation
 
SHLD and LHLD instruction
SHLD and LHLD instructionSHLD and LHLD instruction
SHLD and LHLD instruction
 
Assembly Language Programming Of 8085
Assembly Language Programming Of 8085Assembly Language Programming Of 8085
Assembly Language Programming Of 8085
 
Addressing mode Computer Architecture
Addressing mode  Computer ArchitectureAddressing mode  Computer Architecture
Addressing mode Computer Architecture
 
Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutine
 
Counters &amp; time delay
Counters &amp; time delayCounters &amp; time delay
Counters &amp; time delay
 
Addressing mode
Addressing modeAddressing mode
Addressing mode
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
 
Computer architecture instruction formats
Computer architecture instruction formatsComputer architecture instruction formats
Computer architecture instruction formats
 
Ccp
CcpCcp
Ccp
 

Semelhante a Programming basic computer

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
 
Assembler Programming
Assembler ProgrammingAssembler Programming
Assembler ProgrammingOmar Sanchez
 

Semelhante a Programming basic computer (20)

CH06 (1).PPT
CH06 (1).PPTCH06 (1).PPT
CH06 (1).PPT
 
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
 
Al2ed chapter15
Al2ed chapter15Al2ed chapter15
Al2ed chapter15
 
Assembler Programming
Assembler ProgrammingAssembler Programming
Assembler Programming
 

Último

Babel Compiler - Transforming JavaScript for All Browsers.pptx
Babel Compiler - Transforming JavaScript for All Browsers.pptxBabel Compiler - Transforming JavaScript for All Browsers.pptx
Babel Compiler - Transforming JavaScript for All Browsers.pptxYounusS2
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfDaniel Santiago Silva Capera
 
PicPay - GenAI Finance Assistant - ChatGPT for Customer Service
PicPay - GenAI Finance Assistant - ChatGPT for Customer ServicePicPay - GenAI Finance Assistant - ChatGPT for Customer Service
PicPay - GenAI Finance Assistant - ChatGPT for Customer ServiceRenan Moreira de Oliveira
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPathCommunity
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UbiTrack UK
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024D Cloud Solutions
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...Aggregage
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.YounusS2
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesDavid Newbury
 
Introduction to Quantum Computing
Introduction to Quantum ComputingIntroduction to Quantum Computing
Introduction to Quantum ComputingGDSC PJATK
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7DianaGray10
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesMd Hossain Ali
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URLRuncy Oommen
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024SkyPlanner
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1DianaGray10
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAshyamraj55
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioChristian Posta
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxGDSC PJATK
 
Cloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial DataCloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial DataSafe Software
 

Último (20)

Babel Compiler - Transforming JavaScript for All Browsers.pptx
Babel Compiler - Transforming JavaScript for All Browsers.pptxBabel Compiler - Transforming JavaScript for All Browsers.pptx
Babel Compiler - Transforming JavaScript for All Browsers.pptx
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
 
PicPay - GenAI Finance Assistant - ChatGPT for Customer Service
PicPay - GenAI Finance Assistant - ChatGPT for Customer ServicePicPay - GenAI Finance Assistant - ChatGPT for Customer Service
PicPay - GenAI Finance Assistant - ChatGPT for Customer Service
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation Developers
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond Ontologies
 
Introduction to Quantum Computing
Introduction to Quantum ComputingIntroduction to Quantum Computing
Introduction to Quantum Computing
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URL
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and Istio
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptx
 
Cloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial DataCloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial Data
 

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

Notas do Editor

  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 ...........................