1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
; MCU 8051 IDE - Demonstration code
; Interrupts, hexadecimal editor and code validator
; ------------------------------------------------------
; THIS REQUIRES ANOTHER MCU THAN AT89C2051 BECAUSE
; AT89C2051 HAS NO XDATA MENORY. CLICK ON
; [Main menu] -> [Project] -> [Edit project] AND SELECT
; FOR INSTANCE AT89C51 AND SET XDATA TO SOME VALUE
; ------------------------------------------------------
; * Click on [Main menu] -> [Simulator] -> [Show XDATA memory]
; * Press F2 and F6 (start simulator and animate)
; Code with syntax errors
nolist ; Disable code listing
if 0
mov A, #55d, B ; too many operands
inc 0FFh,, 04x4h ; invalid operands
db (4 *** 5) ; invalid expression
label?: mul B ; invalid label and invalid operand
endif
list ; Enable code listing
; Constants
; --------------------
cseg at 0D0h
string: db 'Welcome in MCU 8051 IDE ! '
string_legth equ 26d
; Macro instructions
; --------------------
write_to_xdata macro str, code_ptr, xdata_ptr
mov A, code_ptr
mov DPTR, #str
movc A, @A+DPTR
mov DPL, xdata_ptr
movx @DPTR, A
inc xdata_ptr
inc code_ptr
endm
; Program initialization
; --------------------
org 0h ; Reset vector
sjmp start
org 0Bh ; Interrupt vector - T0
sjmp T0_int
; Sub-programs
; --------------------
;; Handle interrupt from TF0
T0_int: mov R7, #string_legth
mov R6, #0h
loop: write_to_xdata string, R6, R5
djnz R7, loop
reti
; Program start
; --------------------
start: ; Start timer 0 in mode 2
mov R5, #0h
mov IE, #0FFh
mov TL0, #255d
mov TMOD, #03h
setb TR0
sjmp main
; Main loop
; --------------------
main: sjmp $ ; Infinite loop
; Program end
; --------------------
end
|