Presentation is loading. Please wait.

Presentation is loading. Please wait.

LMC Assembly Making Programming Friendlier. Machine Code Issues Have to remember numeric opcodes Have to think about physical memory locations – What.

Similar presentations


Presentation on theme: "LMC Assembly Making Programming Friendlier. Machine Code Issues Have to remember numeric opcodes Have to think about physical memory locations – What."— Presentation transcript:

1 LMC Assembly Making Programming Friendlier

2 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?

3 Assembly Assembly Code : human readable machine code

4 Assembly Little Man Computer Assembly: Assembly Machine code 0 INP901 1 STA FIRST307 2 LDA TEN506 3 ADD FIRST107 4 OUT902 5 HLT000 6 TEN DAT 10010 7 FIRST DAT 0000 AssemblyMachine codeInstruction HLT000end (halt) ADD1xxadd SUB2xxsubtract STA3xxstore STore Accumulator value LDA5xxload LoaD into Accumulator BRA6xxbranch always BRanch Always BRZ7xxbranch if 0 BRanch if Zero BRP8xxbranch if >= 0 BRanch if zero or Positive INP901input OUT902output DAT data location Used to specify a memory location

5 DAT DAT Value: "this location is data" – Value is placed into memory 5 HLT000 6 TEN DAT 10010 7 FIRST DAT 0000

6 Identifier Identifier : Name for a memory location – Can come before any instruction IDENTIFIER INSTRUCTION … 5 HLT000 6 TEN DAT 10010 7 FIRST DAT 0000

7 No XX Assembly can use names for memory locations AssemblyMachine code 0 INP901 1 STA FIRST307 2 LDA TEN506 3 ADD FIRST107 4 OUT902 5 HLT000 6 TEN DAT 10010 7 FIRST DAT 0000

8 Names And Branch Use as target of branch: – #1 This is called LOOPSTART We add one to accumulator – #3 Branch to the instruction named LOOPSTART Assembly 0 LDA ZERO 1 LOOPSTART ADD ONE 2 OUT 3 BRA LOOPSTART 4 HLT 5 ZERO DAT 0 6 ONE DAT 1

9 Named Locations Named locations not affected by adding/removing code Ex: Add EXTRA lines – Assembly fine – Machine version broken AssemblyMachine code 0 INP901 1 STA FIRST307 2 LDA TEN506 3 ADD FIRST107 4 EXTRA 5 6 OUT902 7 HLT000 8 TEN DAT 10010 9 FIRST DAT 0000

10 Assembler An Assembler converts assembly to machine code: http://faculty.chemeketa.edu/ascholer/cs160/Files/LMC/LMCAssembler.html


Download ppt "LMC Assembly Making Programming Friendlier. Machine Code Issues Have to remember numeric opcodes Have to think about physical memory locations – What."

Similar presentations


Ads by Google