Assembly Language Friday, Week 5 Monday, Week 6. Assembly Language Set of mnemonic names for the...
-
Upload
rosa-melton -
Category
Documents
-
view
217 -
download
0
Transcript of Assembly Language Friday, Week 5 Monday, Week 6. Assembly Language Set of mnemonic names for the...
![Page 1: Assembly Language Friday, Week 5 Monday, Week 6. Assembly Language Set of mnemonic names for the instructions in a particular computer's machine language.](https://reader035.fdocuments.in/reader035/viewer/2022081811/5697bf8a1a28abf838c8abd0/html5/thumbnails/1.jpg)
Assembly Language
Friday, Week 5
Monday, Week 6
![Page 2: Assembly Language Friday, Week 5 Monday, Week 6. Assembly Language Set of mnemonic names for the instructions in a particular computer's machine language.](https://reader035.fdocuments.in/reader035/viewer/2022081811/5697bf8a1a28abf838c8abd0/html5/thumbnails/2.jpg)
Assembly Language
Set of mnemonic names for the instructions in a particular computer's machine language.
Works on accumulator and memory locations in the computer.
Translated into binary instructions.
![Page 3: Assembly Language Friday, Week 5 Monday, Week 6. Assembly Language Set of mnemonic names for the instructions in a particular computer's machine language.](https://reader035.fdocuments.in/reader035/viewer/2022081811/5697bf8a1a28abf838c8abd0/html5/thumbnails/3.jpg)
Pippin
STO X Store accumulator value in memory location X
LOD X Load contents of memory location X into accumulator
LOD #X Load value X into accumulator
HLT Halt execution
ADD X Add contents of memory location X to accumulator
ADD #X Add value X to accumulator
![Page 4: Assembly Language Friday, Week 5 Monday, Week 6. Assembly Language Set of mnemonic names for the instructions in a particular computer's machine language.](https://reader035.fdocuments.in/reader035/viewer/2022081811/5697bf8a1a28abf838c8abd0/html5/thumbnails/4.jpg)
Pippin
Pippin has an accumulator - a place to store intermediate values during computation.
Similar to the calculator but we have memory locations to store values and to load values.
![Page 5: Assembly Language Friday, Week 5 Monday, Week 6. Assembly Language Set of mnemonic names for the instructions in a particular computer's machine language.](https://reader035.fdocuments.in/reader035/viewer/2022081811/5697bf8a1a28abf838c8abd0/html5/thumbnails/5.jpg)
Sample Program
LOD #2
STO 129
ADD 129
STO 129
ADD #3
STO 130
HLT
![Page 6: Assembly Language Friday, Week 5 Monday, Week 6. Assembly Language Set of mnemonic names for the instructions in a particular computer's machine language.](https://reader035.fdocuments.in/reader035/viewer/2022081811/5697bf8a1a28abf838c8abd0/html5/thumbnails/6.jpg)
Exercise
What would be the assembly instructions to add 1 to the contents of memory location 130?
STO XStore acc value in mem loc X
LOD XLoad contents of mem loc X into acc
LOD #X Load value X into acc
HLT Halt execution
ADD X Add contents of mem loc X to acc
ADD #X Add value X to acc
![Page 7: Assembly Language Friday, Week 5 Monday, Week 6. Assembly Language Set of mnemonic names for the instructions in a particular computer's machine language.](https://reader035.fdocuments.in/reader035/viewer/2022081811/5697bf8a1a28abf838c8abd0/html5/thumbnails/7.jpg)
Exercise Solution
LOD #1
ADD 130
STO 130
HLT
![Page 8: Assembly Language Friday, Week 5 Monday, Week 6. Assembly Language Set of mnemonic names for the instructions in a particular computer's machine language.](https://reader035.fdocuments.in/reader035/viewer/2022081811/5697bf8a1a28abf838c8abd0/html5/thumbnails/8.jpg)
Exercise
What would be the assembly language instructions to add the values in memory locations 129 and 132, putting the answer in 128?
STO XStore acc value in mem loc X
LOD XLoad contents of mem loc X into acc
LOD #X Load value X into acc
HLT Halt execution
ADD X Add contents of mem loc X to acc
ADD #X Add value X to acc
![Page 9: Assembly Language Friday, Week 5 Monday, Week 6. Assembly Language Set of mnemonic names for the instructions in a particular computer's machine language.](https://reader035.fdocuments.in/reader035/viewer/2022081811/5697bf8a1a28abf838c8abd0/html5/thumbnails/9.jpg)
Exercise Solution
LOD 129
ADD 132
STO 128
HLT
![Page 10: Assembly Language Friday, Week 5 Monday, Week 6. Assembly Language Set of mnemonic names for the instructions in a particular computer's machine language.](https://reader035.fdocuments.in/reader035/viewer/2022081811/5697bf8a1a28abf838c8abd0/html5/thumbnails/10.jpg)
Machine Language
Assembly language still cannot be read directly by the computer - it’s not in binary.
Assembly language commands need to be translated into binary commands called machine language.
![Page 11: Assembly Language Friday, Week 5 Monday, Week 6. Assembly Language Set of mnemonic names for the instructions in a particular computer's machine language.](https://reader035.fdocuments.in/reader035/viewer/2022081811/5697bf8a1a28abf838c8abd0/html5/thumbnails/11.jpg)
Pippin Machine Language
LOD X 00000100
LOD # 00010100
ADD X 00000000
ADD # 00010000
STO 00000101
HLT 00001111
Memory location 129 10000001
Memory location 130 10000010
![Page 12: Assembly Language Friday, Week 5 Monday, Week 6. Assembly Language Set of mnemonic names for the instructions in a particular computer's machine language.](https://reader035.fdocuments.in/reader035/viewer/2022081811/5697bf8a1a28abf838c8abd0/html5/thumbnails/12.jpg)
Example Program
LOD 129 00000100 10000001
ADD #3 00001000 00000011
STO 129 00000101 10000001
HLT 00001111
![Page 13: Assembly Language Friday, Week 5 Monday, Week 6. Assembly Language Set of mnemonic names for the instructions in a particular computer's machine language.](https://reader035.fdocuments.in/reader035/viewer/2022081811/5697bf8a1a28abf838c8abd0/html5/thumbnails/13.jpg)
Exercise
LOD X
ADD Y
STO Y
HLT
LOD X
LOD #
ADD X
ADD #
STO
HLT
00000100
00010100
00000000
00010000
00000101
00001111
Translate above into machine language.
Memory location X
Memory location Y
10000001
10000010
![Page 14: Assembly Language Friday, Week 5 Monday, Week 6. Assembly Language Set of mnemonic names for the instructions in a particular computer's machine language.](https://reader035.fdocuments.in/reader035/viewer/2022081811/5697bf8a1a28abf838c8abd0/html5/thumbnails/14.jpg)
Exercise Solution
LOD X
ADD Y
STO Y
HLT
00000100
00000000
00000101
00001111
10000001
10000010
10000010
![Page 15: Assembly Language Friday, Week 5 Monday, Week 6. Assembly Language Set of mnemonic names for the instructions in a particular computer's machine language.](https://reader035.fdocuments.in/reader035/viewer/2022081811/5697bf8a1a28abf838c8abd0/html5/thumbnails/15.jpg)
Exercise
Write an assembly program that calculates Y=X+3.
LOD X
LOD #
ADD X
ADD #
STO
HLT
00000100
00010100
00000000
00010000
00000101
00001111
Translate the program into machine language.
Memory location X
Memory location Y
10000001
10000010
![Page 16: Assembly Language Friday, Week 5 Monday, Week 6. Assembly Language Set of mnemonic names for the instructions in a particular computer's machine language.](https://reader035.fdocuments.in/reader035/viewer/2022081811/5697bf8a1a28abf838c8abd0/html5/thumbnails/16.jpg)
Exercise Solution
LOD X
ADD #3
STO Y
HLT
00000100
00010000
00000101
00001111
10000001
00000011
10000010
![Page 17: Assembly Language Friday, Week 5 Monday, Week 6. Assembly Language Set of mnemonic names for the instructions in a particular computer's machine language.](https://reader035.fdocuments.in/reader035/viewer/2022081811/5697bf8a1a28abf838c8abd0/html5/thumbnails/17.jpg)
PIPPIN Lab
This week’s lab will be to use a simulator called PIPPIN to write assembly language programs and change them to machine language.
Let’s take a look at PIPPIN. Do Pre-Lab Assignment
![Page 18: Assembly Language Friday, Week 5 Monday, Week 6. Assembly Language Set of mnemonic names for the instructions in a particular computer's machine language.](https://reader035.fdocuments.in/reader035/viewer/2022081811/5697bf8a1a28abf838c8abd0/html5/thumbnails/18.jpg)
JMP
All commands seen so far in PIPPIN are sequential.
We have no way to make a decision or to skip some statements.
JMP X command says always jump to the command labeled X.
JMZ X checks the accumulator first - if it’s 0 then we jump; otherwise don’t jump.
![Page 19: Assembly Language Friday, Week 5 Monday, Week 6. Assembly Language Set of mnemonic names for the instructions in a particular computer's machine language.](https://reader035.fdocuments.in/reader035/viewer/2022081811/5697bf8a1a28abf838c8abd0/html5/thumbnails/19.jpg)
Example
LOD #3
STO X
LOD #0
STO Z
LOOP: LOD Z
ADD Y
STO Z
LOD X
SUB #1
STO X
JMZ END
JMP LOOP
END: LOD Z
STO Y
HLT
![Page 20: Assembly Language Friday, Week 5 Monday, Week 6. Assembly Language Set of mnemonic names for the instructions in a particular computer's machine language.](https://reader035.fdocuments.in/reader035/viewer/2022081811/5697bf8a1a28abf838c8abd0/html5/thumbnails/20.jpg)
In JavaScript
The same program in JavaScript would be the following:
var z=0;for (var x=3; x!=0; x--)
z += y;y = z;
Or the following:y = y*3;