Sunday, 5 February 2017

8 bit microprocessor code refresher (assembly programming)

It has been long since I looked at the lowest level programming, probably first since 2000.
Problem / assignment
int i =  14
int j = 28
printf (“%d”, i + j)
result -> 42

4 bit mnemonic table used on 8 bit processor:
0
0
0
0
NOP
No operation
0
0
0
1
LDA
Load data from given memory address into register A
0
0
1
0
ADD
Add register A with given address and store the result in register A
0
0
1
1
SUB
Subtract A with given address and store the result in register A
0
1
0
0
STA
Store register A data into given memory
0
1
0
1
OUT
Copy register A to output (display)
0
1
1
0
JMP
Jump to PC to given address
0
1
1
1
LDI
Load value into the register A
1
0
0
0
JC
Jump is carry is set
1
1
1
1
HLT
Halt the execution

Binary code version:

Address
Instruction (mnemonic)
Data

0
LDA
4
Copy address 4 data into A
1
ADD
5
Add address 5 data with A and store in A
2
OUT

Display the A data [ replacement of ‘printf’ ]
3
HLT

Halt the execution
4
NOP
14
14 value at address 4  [replacement of ‘int i = 14’]
5
NOP
28
28 value at address 5 [replacement of  ‘int j = 28’]


Thanks for Ben Eater  for sharing this video:


Screenshot of same from video.


No comments:

Post a Comment

Total Pageviews

Popular Posts