Professional Documents
Culture Documents
MachineLanguage
VonNeumannArchitecture
Memory CPU Control Unit Registers
ALU
SlightlyMoreCompletePicture
Memory CPU Control Unit Registers
ALU
Secondary Storage
VonNeumannArchitecture
Program and Data are both stored in memory. Fetch, Decode, Execute cycle
ALU
MachineLanguageExample
SampleInstruction
InstructionID Register# MemoryLocation
MachineLanguage
LOAD contents of memory location into register 100000010 RR MMMMM ex: R0 = Mem[3] 100000010 00 00011 100000100 RR MMMMM ex: Mem[4] = R0 100000100 00 00100 100100010000 RR RR ex: R0 = R1 100100010000 00 01
MachineLanguage
ADD contents of 2 registers, store result in third. 1010000100 RR RR RR ex: R0 = R1 + R2 1010000100 00 01 10 1010001000 RR RR RR ex: R0 = R1 R2 1010001000 00 01 10 1111111111111111
ReadingMachineLanguage
Inourcase,firstninebitsspecifiestheoperation,last6 (or7)bitsspecifiesthearguments:
Itisverytedioustoprograminmachinelanguage.
AssemblyLanguage
Assemblyinstructionsarejustshorthandformachine instructions:
MachineLanguage EquivalentAssembly 1000000100100101LOADR15 1000000101000101LOADR25 1010000100000110ADDR0R1R2 1000001000000110SAVER06 1111111111111111HALT
Exercise
ExerciseSolution
STORE1R1 MOVER1R2 LOADR21 HALT
SomeMoreInstructions
Wearemissingsomecrucialfunctionality ??
SomeMoreInstructions
Wearemissingsomecrucialfunctionality Loops!
BRANCH [MEM]
Branch if the ALU result is BZERO [MEM] zero. Branch if the ALU result is BNEG [MEM] negative.
AMoreComplexExample
R0 R1 R2 R3 3 1 Number 2 0 3 4 5 BZERO 4 BRANCH 0 MOVE R2 R3 HALT 0 1 ADD R3 R2 R3 SUB R0 R0 R1
InMatlab
ProblemswithAssembly
Whymightweavoidwritinginassembly?
HighLevelLanguages:Compilationand Interpretation
InterpreterTranslationisonthefly.(Matlab) CompilerTranslationhappensallatonce.
Advantagesanddisadvantages...
Compilers,Interpreters,Assemblers
BecauseitisnotfuntoprograminAssembly,we havehighlevelprogramminglanguages.
Matlab
Python,C,C++,Java,Fortran,Cobol,Pascal,M,Ada,Lisp,Ruby,Smalltalk, C#,Haskell,Prolog
Compiler/Interpretertranslatesfromthehighlevel languagetomachinelanguage.
ProgramTranslation
Compiler/Interpreter
Assembler
MiniLab
http://www.davereed.com/book/source.html