Last Updated or created 2023-01-16
Funny story about learning machinelanguage at school.
It was around 1989, and was attending a class Microcomputer Programming in Machine Language.
We where given a problem we had to solve using 8085 machine code.
The machine we had to program this on was a Intel SDK-85, much like below example.
Note it only had a hex keyboard and 7segmented display. You had to punch in the machinecode into memory slots yourself.
Problem we where given was something like searching for certain data in memory.
Normal procedure was :
- Draw a flow of instructions (Flowchart)
- Write the machine languages codes
- Convert those assembly statements into Opcodes the machine could understand
- Punch in those numbers, run and verify
Most of us knew a lot of opcodes by heart, but some knew all opcodes. And how many bytes where needed. besides that we had to remember jump and return addresses.
So our teacher presented the problem, when he stopped talking, my friend Martin and I when up to our machines … punching buttons.
” Guys .. you can’t expect it to work without writing the program down first!
A few minutes later .. we pressed enter .. and it worked.
A program like above looked like:
01 2E 2B 21 00 00 79 BE C2 1F C0 CD 19 C0 CA 1E C0 78 BE C2 06 C0 C3 25 C0 2C C2 1E C0 24 C9 CD 19 C0 C3 06 C0 C9
Cut into opcodes:
01 2E 2B
21 00 00
79
BE
C2 1F C0
CD 19 C0
CA 1E C0
78
BE
C2 06 C0
C3 25 C0
2C
C2 1E C0
24
C9
CD 19 C0
C3 06 C0
C9
Some opcodes used 1 byte, others 2 or 3.
C2 1F C0 – means Jump to address C01F when not zero
C9 – means return, go back to a previous CALL statement
Example of machine language which is translated into above
ADDR ; INSTRUCTION C000 ; LXI B,0X2B2E C003 ; LXI H,0X0000 C006 ; MOV A,C C007 ; CMP H C008 ; JNZ C01F C00B ; CALL CO19 COOE ; JZ CO1E ETC