Presentation is loading. Please wait.

Presentation is loading. Please wait.

Making Programming Friendlier

Similar presentations


Presentation on theme: "Making Programming Friendlier"— Presentation transcript:

1 Making Programming Friendlier
LMC Assembly Making Programming Friendlier

2 Machine Code Issues Have to remember numeric opcodes
Have to think about physical memory locations Machine code 901 1 307 2 506 3 207 4 902 5 000 6 010 7 8 9

3 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? Machine code 901 1 307 2 506 3 207 4 902 5 000 6 010 7 8 9

4 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? Machine code 901 1 307 2 506 3 207 4 NEW 5 6 902 7 000 8 010 9

5 Assembly Assembly Code : human readable machine code

6 Assembly Little Man Computer Assembly: Assembly Machine code INP 901
INP 901 1 STA FIRST 307 2 LDA TEN 506 3 ADD FIRST 107 4 OUT 902 5 HLT 000 6 TEN DAT 10 010 7 FIRST DAT 0 Assembly Machine code Instruction HLT 000 end (halt) ADD 1xx add SUB 2xx subtract STA 3xx store STore Accumulator value LDA 5xx load LoaD into Accumulator BRA 6xx branch always BRanch Always BRZ 7xx branch if 0 BRanch if Zero BRP 8xx branch if >= 0 BRanch if zero or Positive INP 901 input OUT 902 output DAT data location Used to specify a memory location

7 DAT DAT Value: "this location is data" Value is placed into memory HLT
5 HLT 000 6 TEN DAT 10 010 7 FIRST DAT 0

8 Identifier Identifier : Name for a memory location
Can come before any instruction IDENTIFIER INSTRUCTION … 5 HLT 000 6 TEN DAT 10 010 7 FIRST DAT 0

9 No XX Assembly can use names for memory locations Assembly
Machine code INP 901 1 STA FIRST 307 2 LDA TEN 506 3 SUB FIRST 207 4 OUT 902 5 HLT 000 6 TEN DAT 10 010 7 FIRST DAT 0

10 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 LDA ZERO 1 LOOPSTART ADD ONE 2 OUT 3 BRA LOOPSTART 4 HLT 5 ZERO DAT 0 6 ONE DAT 1

11 Named Locations Named locations not affected by adding/removing code
Ex: Add EXTRA lines Assembly fine Machine version broken Assembly Machine code INP 901 1 STA FIRST 307 2 LDA TEN 506 3 SUB FIRST 207 4 EXTRA 5 6 OUT 902 7 HLT 000 8 TEN DAT 10 010 9 FIRST DAT 0

12 Assembler An Assembler converts assembly to machine code:


Download ppt "Making Programming Friendlier"

Similar presentations


Ads by Google