Assembly is one of programming languages. It's the closest form of machine's language. When we learn about C programming language, or Pascal, we still use the language that uses human language, especially English. The instructions are, if-then-else, while-do, for-to-do, etc. In Assembly, we don't use it anymore(maybe a little, but the syntax is completely different). We can see clearly how the machine works in this language, like moving memory, decreasing or increasing accumulator, using registers, I/O ports, etc.
I use Pinnacle to compile and simulate the program.
The Pinnacle software can be downloaded in :
here
The 8051 Assembly Language Manual can be downloaded in :
here
Common instructions in Assembly :
DJNZ(Decrease and Jump if Not Zero)
CJNE(Compare and Jump if Not Equal)
SJMP(Short Jump)
MOV
RL,RR(Shift Left, Shift Right)
This is an example :
ORG 0H
START:
MOV A,#0FEH
MOV R3,#008H
CALL LAGI
MOV R3,#004H
CALL SAPI
MOV R3,#004H
CALL KUDA
CALL WOW
SJMP START
LAGI:
MOV P1,A
CALL DELAY
RL A
DJNZ R3,LAGI
RET
SAPI:
CALL DELAY
MOV P1,#0FFH
CALL DELAY
MOV P1,#000H
DJNZ R3,SAPI
RET
KUDA:
CALL DELAY
MOV A,#11110000B
MOV P1,A
CALL DELAY
MOV A,#00001111B
MOV P1,A
DJNZ R3,KUDA
RET
WOW:
CALL DELAY
MOV P1,#01111110B
CALL DELAY
MOV P1,#10111101B
CALL DELAY
MOV P1,#11011011B
CALL DELAY
MOV P1,#11100111B
CALL DELAY
MOV P1,#11011011B
CALL DELAY
MOV P1,#10111101B
CALL DELAY
MOV P1,#01111110B
RET
DELAY:
MOV R0,#05H
ULANG:
MOV R1,#0FEH
ULANG1:
MOV R2,#000H
DJNZ R2,$
DJNZ R1,ULANG1
DJNZ R0,ULANG
RET
end
Just copy this program and save into *.asm and compile in Pinnacle. Simulate this using "play" button and view the ports from menu bar.
This program can be downloaded into a MCS-51 chip, using a downloader circuit. This is the result of the program above.
This is the schematic of the circuit :
If you have any questions, feel free to ask.
No comments:
Post a Comment