Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
INTRODUCTION
EMU 8086 is a microprocessor emulator with an integrated 8086 Assembler. The emulator
can run programs on a Virtual Machine, and emulate real hardware including screen,
memory, and input and output devices. It helps you program in assembly language. The
source code is compiled by assembler and then executed on Emulator step-by-step, allowing
you to watch registers, flags and memory while your program runs.
A number of programs can be written in this useful emulator. In my project, I have written a
program on digital clock .
Step 6 : Go to step 3.
ASSUMPTIONS
Clock frequency of the processor is assumed to be 5 MHz.
Database stores previous time and balance in the form of digits in seven
segment code..
The hours, minutes, and seconds are entered at the memory locations
which is in decimal form. The enetered data is converted into the format from
decimal. A delay of exactly one second is generated and after each delay, the
done in hex. form and converted back into decimal before displaying
HARDWARE SPECIFICATIONS
9. Number keypad - 1
Facility of lap timing which stores the time at which the user presses the switch and display it
when needed.
Various registers like ax, bx , cx etc have also been used to make the code easy and
understandable .
CODE
line level source
1 #include<reg51.h>
2 #include<string.h>
3 #define lcd P3
4 sbit rs=P2^0;
5 sbit e=P2^1;
7 sbit c=P0^0;
8 sbit d=P0^1;
15
25
26
27 int no[10]={48,49,50,51,52,53,54,55,56,57};
29
31 {
33 1 for(;d>0;d--)
34 1 {
35 2 for(i=250;i>0;i--);
36 2 for(i=248;i>0;i--);
37 2 }
38 1 }
39
41 {
42 1 lcd=c;
43 1 rs=0;
44 1 e=1;
45 1 delay(5);
46 1 e=0;
47 1 }
49 {
50 1 lcd=c;
51 1 rs=1;
52 1 e=1;
53 1 delay(5);
54 1 e=0;
55 1 }
C51 COMPILER V9.59.0.0 HELLO
57 {
58 1 while(*p)
59 1 {
60 2 display(*p++);
61 2 }
62 1 }
64 {
65 1 cmd(0x38);
66 1 cmd(0x0c);
67 1 cmd(0x01);
68 1 cmd(0x80);
69 1 }
70
71
73 {
74 1 c=1;
75 1 d=1;
76 1 delay(1);
77 1 d=0;
78 1 delay(1);
79 1 }
80
82 {
83 1 c=0;
84 1 delay(1);
85 1 d=0;
86 1 delay(1);
87 1 c=1;
88 1 delay(1);
89 1 d=1;
90 1 delay(1);
91 1 }
93 {
94 1 char j;
95 1 for(j=0;j<8;j++)
96 1 {
97 2 c=0;
98 2 d=(a&0x80>>j)?1:0;
99 2 c=1;
100 2 }
101 1 }
103 {
104 1 char j;
106 1 for(j=0;j<8;j++)
107 1 {
108 2 c=0;
109 2 if(d)
110 2 temp=temp|(0x80>>j);
111 2 c=1;
112 2 }
114 1 }
116 {
117 1 c=0;
C51 COMPILER V9.59.0.
118 1 delay(1);
119 1 d=1;
120 1 delay(1);
121 1 c=1;
122 1 delay(1);
123 1 while(d==1);
124 1 c=0;
125 1 delay(1);
126 1 }
128 {
129 1 c=0;
130 1 delay(1);
131 1 d=1;
132 1 delay(1);
133 1 c=1;
134 1 delay(1);
135 1
136 1 }
137
138 void write (unsigned char sa, unsigned char w_addr, unsigned char dat)
139 {
140 1 i2c_start();
141 1 i2c_write(sa);
142 1 i2c_ack();
143 1 i2c_write(w_addr);
144 1 i2c_ack();
145 1 i2c_write(dat);
146 1 i2c_ack();
147 1 i2c_stop();
148 1 delay(10);
149 1 }
150 unsigned char read (unsigned char sa, unsigned char w_addr)
151 {
153 1 i2c_start();
154 1 i2c_write(sa);
155 1 i2c_ack();
156 1 i2c_write(w_addr);
157 1 i2c_ack();
158 1 i2c_start();
159 1 i2c_write(sa|0x01);
160 1 i2c_ack();
161 1 buf=i2c_read();
162 1 i2c_noack();
163 1 i2c_stop();
165 1 }
166 void set_time (unsigned char hour, unsigned char min, unsigned char sec)
167 {
172 1 write(0xd0,0x00,temp[0]);
173 1 write(0xd0,0x01,temp[1]);
174 1 write(0xd0,0x02,temp[2]);
175 1 }
176
177
179 {
C51 COMPILER V9.59.0.0 HELLO
181 1 init();
183 1 cmd(0xc0);
185 1
186 1 delay(3000);
187 1 cmd(0x01);
188 1 set_time(12,59,51);
189 1 delay(500);
190 1 while(1)
191 1 {
192 2 cmd(0x80);
193 2 temp=read(0xd0,0x00);
195 2 temp=read(0xd0,0x01);
197 2 temp=read(0xd0,0x02);
199 2
200 2 display(no[(temp1[2]/10)%10]);
201 2 display(no[temp1[2]%10]);
202 2 display(':');
203 2 display(no[(temp1[1]/10)%10]);
204 2 display(no[temp1[1]%10]);
205 2 display(':');
206 2 display(no[(temp1[0]/10)%10]);
207 2 display(no[temp1[0]%10]);
208 2
209 2 }
210 1 while(1);
211 1 }
C51 COMPILER V9.59.0.0 HELLO
0009 L?0052:
000B L?0053:
; SOURCE LINE # 30
; SOURCE LINE # 31
; SOURCE LINE # 32
; SOURCE LINE # 33
000F ?C0001:
000F D3 SETB C
; SOURCE LINE # 34
; SOURCE LINE # 35
001C ?C0004:
001C ED MOV A,R5
001D D3 SETB C
0026 1D DEC R5
0029 ?C0005:
; SOURCE LINE # 36
002B ?C0007:
002C D3 SETB C
0035 1D DEC R5
; SOURCE LINE # 37
0038 ?C0003:
0039 1F DEC R7
003C 1E DEC R6
003D ?C0042:
; SOURCE LINE # 38
003F ?C0010:
C51 COMPILER V9.59.0.0 HELLO
003F 22 RET
; SOURCE LINE # 40
; SOURCE LINE # 41
; SOURCE LINE # 42
; SOURCE LINE # 43
; SOURCE LINE # 44
; SOURCE LINE # 45
; SOURCE LINE # 46
; SOURCE LINE # 47
000F 22 RET
0002 L?0049:
0007 L?0050:
0014 08 INC R0
; SOURCE LINE # 48
; SOURCE LINE # 49
; SOURCE LINE # 50
; SOURCE LINE # 51
; SOURCE LINE # 52
; SOURCE LINE # 53
; SOURCE LINE # 54
; SOURCE LINE # 55
0026 22 RET
; SOURCE LINE # 56
; SOURCE LINE # 57
0006 ?C0013:
; SOURCE LINE # 58
; SOURCE LINE # 59
; SOURCE LINE # 60
0019 ?C0043:
0019 14 DEC A
; SOURCE LINE # 61
; SOURCE LINE # 62
0024 ?C0015:
0024 22 RET
; SOURCE LINE # 63
; SOURCE LINE # 64
; SOURCE LINE # 65
; SOURCE LINE # 66
; SOURCE LINE # 67
; SOURCE LINE # 68
; SOURCE LINE # 72
; SOURCE LINE # 73
; SOURCE LINE # 74
; SOURCE LINE # 75
; SOURCE LINE # 76
; SOURCE LINE # 77
; SOURCE LINE # 78
; SOURCE LINE # 81
; SOURCE LINE # 82
; SOURCE LINE # 83
; SOURCE LINE # 84
; SOURCE LINE # 85
; SOURCE LINE # 86
; SOURCE LINE # 87
; SOURCE LINE # 88
; SOURCE LINE # 89
; SOURCE LINE # 90
; SOURCE LINE # 92
; SOURCE LINE # 93
; SOURCE LINE # 95
0002 E4 CLR A
0006 33 RLC A
000A C3 CLR C
; SOURCE LINE # 96
; SOURCE LINE # 97
; SOURCE LINE # 98
001D 08 INC R0
0020 ?C0044:
0023 13 RRC A
0025 13 RRC A
0026 ?C0045:
002F D3 SETB C
0032 ?C0022:
0032 C3 CLR C
0033 ?C0023:
; SOURCE LINE # 99
0037 0C INC R4
003A ?C0024:
003A 22 RET
0000 E4 CLR A
0005 33 RLC A
0009 C3 CLR C
001D 08 INC R0
0020 ?C0046:
0020 C3 CLR C
0021 13 RRC A
0022 ?C0047:
0026 ?C0028:
C51 COMPILER V9.59.0.0 HELLO
0028 0E INC R6
002B ?C0026:
002B 22 RET
0013 ?C0030:
0028 22 RET
C51 COMPILER V9.59.0.0 HELLO
0006 84 DIV AB
000A A4 MUL AB
0012 84 DIV AB
0021 84 DIV AB
002D 84 DIV AB
003B 84 DIV AB
003F A4 MUL AB
0047 84 DIV AB
0053 E4 CLR A
0000 E4 CLR A
0039 ?C0037:
003E E4 CLR A
C51 COMPILER V9.59.0.0 HELLO
004B C4 SWAP A
0051 A4 MUL AB
006D C4 SWAP A
0073 A4 MUL AB
0074 FF MOV R7,A
008F C4 SWAP A
0095 A4 MUL AB
DATA SIZE = 26 10
APPLICATIONS
Because digital clocks can be very small and inexpensive devices that
enhance the popularity of product designs, they are often incorporated into all
kinds of devices such as cars, radios, televisions, microwave ovens, standard
ovens, computers and cell phones
FUTURE SCOPE
Apart from the security purpose , this logic now a days is used as a new concept .
REFERENCES
• www.free2code.net
• www.emu8086.com