Machine Code and Assembly Code.

Machine code can be used on two websites these are:

http://robowriter.info/little-man-computer/bo
http://peterhigginson.co.uk/LMC/

Some LMC instructions on agbonline.co.uk are:

 

Instruction

Mnemonic

MachineCode

Load

LDA

5xx

Store

STA

3xx

Add

ADD

1xx

Subtract

SUB

2xx

Input

INP

901

Output

OUT

902

End

HLT

000

Branch if zero

BRZ

7xx

Branch if zero or positive

BRP

8xx

Branch always

BRA

6xx

Data storage

DAT

                                                                                                            agbonline.co.uk

Basic Hello World Example

901

In

902

Output

A Basic 2 number addition calculator.

Machine Code

Instructions

Line Number

Instruction

901

In

00

INP

399

Sto 99

01

STA 99

901

In

02

INP

199

In

03

ADD 99

902

Out

04

OUT

000

Cob

05

HLT

 

 

 

 

Input 3 numbers.

901

In

315

Sto 15

901

In

115

Add 15

316

Sto 15

901

In

116

Add 16

318

Sto 18

902

Out

000

Cob

 

 

 

Input 3 numbers and subtract 2 numbers.


Location of instruction.

Instruction in location.

Instruction.

0

901

In

1

315

Sto 15

2

901

In

3

316

Sto 16

4

901

In

5

317

Sto 17

6

901

In

7

318

Sto 18

8

901

In

9

319

Sto 19

10

515

Lda 15

11

116

Add 16

12

117

Add 17

13

218

Sub 18

14

219

Sub 19

15

902

Out

16

000

Cob

 

http://robowriter.info/little-man-computer/bo

http://peterhigginson.co.uk/LMC/




In Peter higginsons LMC the code is slightly different but does the same thing.
Inp
Sta 15
Inp
Sta 16
Inp
Sta 17
Inp
Sta 18
Inp
Sto 19
Lda 15
Add 16
Add 17
Sub 18
Sub 19
Out
hlt

You can also do loops in Assembly Language using Little Man Computers.

To do:

Value= INPUT
Do while value >=0
print value
value -
next
end.

Can be represented in LMC as:

IN
STA 25
SUB ONE
BRZ 05
BRA 00
OUT
HLT
ONE DAT 01

Extension activity.

00        In
01        Sta a
02        In
03        Sta b
04        Lda b
05        Brz end
06        Sub one
07        Sta b
08        Lda count
09        Add a
10        Sta count
11        Bra start
12        Lda count
13        out
14        Hlt
15        Dat 01
16        Dat 02
17        Dat 03
18        Dat 04

Fibonacci Code
Add the previous two numbers together.

1          1          2          3          5          8          13        21        34        55        89        144

 

 

Teaching Ideas.

Show a Powerpoint having some fun identifying terms like Date a Bus = Databus.

Work through examples with

http://robowriter.info/little-man-computer/bo
http://peterhigginson.co.uk/LMC/

Research project on Important figures in history of computing.
Von Neumann
Babbage
IBM creator Hermann Hollerich
Alan Turing.