lmc assembly making programming friendlier. machine code issues have to remember numeric opcodes...
TRANSCRIPT
![Page 1: LMC Assembly Making Programming Friendlier. Machine Code Issues Have to remember numeric opcodes Have to think about physical memory locations – What](https://reader036.vdocument.in/reader036/viewer/2022082820/56649e5e5503460f94b5767b/html5/thumbnails/1.jpg)
LMC AssemblyMaking Programming Friendlier
![Page 2: LMC Assembly Making Programming Friendlier. Machine Code Issues Have to remember numeric opcodes Have to think about physical memory locations – What](https://reader036.vdocument.in/reader036/viewer/2022082820/56649e5e5503460f94b5767b/html5/thumbnails/2.jpg)
Machine Code Issues
• Have to remember numeric opcodes• Have to think about physical memory
locations– What if I need to add 6 lines
of code to this program?
![Page 3: LMC Assembly Making Programming Friendlier. Machine Code Issues Have to remember numeric opcodes Have to think about physical memory locations – What](https://reader036.vdocument.in/reader036/viewer/2022082820/56649e5e5503460f94b5767b/html5/thumbnails/3.jpg)
Assembly
• Assembly Code : human readable machine code
![Page 4: LMC Assembly Making Programming Friendlier. Machine Code Issues Have to remember numeric opcodes Have to think about physical memory locations – What](https://reader036.vdocument.in/reader036/viewer/2022082820/56649e5e5503460f94b5767b/html5/thumbnails/4.jpg)
Assembly
• Little Man Computer Assembly:
AssemblyMachine
code0 INP 9011 STA FIRST 3072 LDA TEN 5063 ADD FIRST 1074 OUT 9025 HLT 0006 TEN DAT 10 0107 FIRST DAT 0 000
Assembly Machine code Instruction HLT 000 end (halt) ADD 1xx add SUB 2xx subtract STA 3xx store STore Accumulator valueLDA 5xx load LoaD into AccumulatorBRA 6xx branch always BRanch AlwaysBRZ 7xx branch if 0 BRanch if ZeroBRP 8xx branch if >= 0 BRanch if zero or PositiveINP 901 input OUT 902 output DAT data location Used to specify a memory location
![Page 5: LMC Assembly Making Programming Friendlier. Machine Code Issues Have to remember numeric opcodes Have to think about physical memory locations – What](https://reader036.vdocument.in/reader036/viewer/2022082820/56649e5e5503460f94b5767b/html5/thumbnails/5.jpg)
DAT
• DAT Value: "this location is data"– Value is placed into memory
5 HLT 0006 TEN DAT 10 0107 FIRST DAT 0 000
![Page 6: LMC Assembly Making Programming Friendlier. Machine Code Issues Have to remember numeric opcodes Have to think about physical memory locations – What](https://reader036.vdocument.in/reader036/viewer/2022082820/56649e5e5503460f94b5767b/html5/thumbnails/6.jpg)
Identifier
• Identifier : Name for a memory location– Can come before any instruction
IDENTIFIER INSTRUCTION …
5 HLT 0006 TEN DAT 10 0107 FIRST DAT 0 000
![Page 7: LMC Assembly Making Programming Friendlier. Machine Code Issues Have to remember numeric opcodes Have to think about physical memory locations – What](https://reader036.vdocument.in/reader036/viewer/2022082820/56649e5e5503460f94b5767b/html5/thumbnails/7.jpg)
No XX
• Assembly can use names for memory locations
Assembly Machine code0 INP 9011 STA FIRST 3072 LDA TEN 5063 ADD FIRST 1074 OUT 9025 HLT 0006 TEN DAT 10 0107 FIRST DAT 0 000
![Page 8: LMC Assembly Making Programming Friendlier. Machine Code Issues Have to remember numeric opcodes Have to think about physical memory locations – What](https://reader036.vdocument.in/reader036/viewer/2022082820/56649e5e5503460f94b5767b/html5/thumbnails/8.jpg)
Names And Branch
• Use as target of branch:– #1
This is called LOOPSTARTWe add one to accumulator
– #3Branch to the instructionnamed LOOPSTART
Assembly
0 LDA ZERO
1 LOOPSTART ADD ONE
2 OUT
3 BRA LOOPSTART
4 HLT
5 ZERO DAT 0
6 ONE DAT 1
![Page 9: LMC Assembly Making Programming Friendlier. Machine Code Issues Have to remember numeric opcodes Have to think about physical memory locations – What](https://reader036.vdocument.in/reader036/viewer/2022082820/56649e5e5503460f94b5767b/html5/thumbnails/9.jpg)
Named Locations
• Named locations not affected by adding/removing code
Ex: Add EXTRA lines– Assembly fine– Machine version broken
Assembly Machine code0 INP 9011 STA FIRST 3072 LDA TEN 5063 ADD FIRST 1074 EXTRA EXTRA5 EXTRA EXTRA6 OUT 9027 HLT 0008 TEN DAT 10 0109 FIRST DAT 0 000
![Page 10: LMC Assembly Making Programming Friendlier. Machine Code Issues Have to remember numeric opcodes Have to think about physical memory locations – What](https://reader036.vdocument.in/reader036/viewer/2022082820/56649e5e5503460f94b5767b/html5/thumbnails/10.jpg)
Assembler
• An Assembler converts assembly to machine code:
http://faculty.chemeketa.edu/ascholer/cs160/Files/LMC/LMCAssembler.html