Today, we wrote and ran our first assembly program. To be honest, since we are used to coding in higher level languages, it seems getting used to assembly will not be easy. However, even though it may get annoying, it is fun!

We run our code at Hippy simulator. It simulates a M6800 processor. Despite the fact that we have not learned loops and conditionals yet, I was too curious to wait for the next lectures. Therefore, I tried to write a very simple program that has very basic usage of conditionals and loops. Since I am not familiar with the instructions yet, it took more than necessary time. But it was worth every minute of it and I think I will get along well with assembly.

Now I am representing the source of my program. Thanks to the Hippy, I do not have to load op-codes to memory manually. It compiles the mnemonic codes and loads the op-codes to the memory. I will not explain what code does, actually it may be a good exercise if you try to understand. Well, label names will be very helpful.

P.S: I know this code can be shortened. I was too lazy to improve it and do not forget the fact that this is my first program.

LDAA 100H
LDAB 105H

CBA
BGE AGRE
BRA BGRE

AGRE: SBA
CBA
BGE AGRE
CMPA #0000H
BEQ DIVISIBLE
BRA NONDIVISIBLE

LDAA 105H
LDAB 100H
BGRE: SBA
CBA
BGE BGRE
CMPA #0000H
BEQ DIVISIBLE
BRA NONDIVISIBLE

DIVISIBLE: LDAA #1H
STAA 110H
SWI

NONDIVISIBLE: LDAA #0H
STAA 110H
SWI