1.2.4 Types Of Programming Language Flashcards
Programming paradigm
A philosophy, style or general approach to writing code
Imperative languages
A series of instructions that tell the computer exactly how to deal with a program and deal with a problem
3 types of imperative language
Structured, procedural and object-oriented
Structured
A series of procedures or functions that can be reused split a large program into manageable chunks
Declarative language
The user inputs the desired result but not how to get there and the computer does the work
Sets rules and answers questions
Logic programming
Expresses the logic of a computation without expressing its control flow
Defines a set of facts and rules based on the problem
Declarative language used
Medical diagnosis, oil exploration, processing natural language
Assembly language facts
Different for every type of processor
Assembler translates to machine code for execution
Each has it’s own instruction set called an instruction set architecture
What are the last 2 bits of the opcode?
The addressing mode, clarifies what the operand means
Little man computer
Only has 11 instructions
The imaginary computer it runs on has only 100 memory locations (7 bits)
LMC ADD x
Adds the contents of the memory address x to the value in the accumulator
LMC SUB x
Subtracts the contents of the memory address x from the value in the accumulator
LMC STA x
Stores the value in the accumulator in the memory address x
LMC LDA x
Loads the value in the memory address x to the accumulator
LMC HLT
Stops the program
LMC INP
Allows the user to input a value to the accumulator
LMC OUT
Outputs the value in the accumulator to the screen
LMC BRZ x
Branch if the contents of the accumulator equal 0
LMC BRP x
Branch if the contents of the accumulator are greater than or equal to 0
LMC BRA x
Branch always
LMC how do branches work?
You make a branch name after the BRA/BRP/BRZ and call it before a line to show where you skip to
LMC x DAT
Creates a variable using variablename DAT
Immediate addressing
The operand holds an actual value
Direct addressing
The operand holds the address of the value
Indirect addressing
The location holding the address of the value
Indexed addressing
The address of the operand is obtained by adding the value to a base address which is stored in the input register. Used for accessing an array whose elements are in successive memory locations
Reading from file pseudocode
myFile = openRead(“filename.txt”)
line = myFile.readLine()
myFile.close()
Determining end of file
myFile.endOfFile()
Writing to a file
myFile = openWrite(“filename.txt”)
myFile.writeLine(“text to write”)
myFile.close()