📄 uipavr.lst
字号:
__text_start:
__start:
1312 E800 LDI R16,0x80
1313 E011 LDI R17,1
1314 FF10 SBRS R17,0
1315 6400 ORI R16,0x40
1316 BF05 OUT 0x35,R16
1317 EFCF LDI R28,0xFF
1318 E1D0 LDI R29,0x10
1319 BFCD OUT 0x3D,R28
131A BFDE OUT 0x3E,R29
131B 52C8 SUBI R28,0x28
131C 40D0 SBCI R29,0
131D EA0A LDI R16,0xAA
131E 8308 STD Y+0,R16
131F 2400 CLR R0
1320 EFE7 LDI R30,0xF7
1321 E2F9 LDI R31,0x29
1322 E312 LDI R17,0x32
1323 32E3 CPI R30,0x23
1324 07F1 CPC R31,R17
1325 F011 BEQ 0x1328
1326 9201 ST R0,Z+
1327 CFFB RJMP 0x1323
1328 8300 STD Z+0,R16
1329 E2ED LDI R30,0x2D
132A E0FD LDI R31,0xD
132B E0A0 LDI R26,0
132C E1B1 LDI R27,0x11
132D E216 LDI R17,0x26
132E 32E4 CPI R30,0x24
132F 07F1 CPC R31,R17
1330 F021 BEQ 0x1335
1331 95C8 LPM
1332 9631 ADIW R30,1
1333 920D ST R0,X+
1334 CFF9 RJMP 0x132E
1335 940E1366 CALL _main
_exit:
1337 CFFF RJMP _exit
_delay_ms:
delay_count --> R10
delay_cnt --> R10
delay_cnt_buffer --> R12
ms --> R16
1338 940E2E6F CALL push_gset4x
FILE: D:\hexok项目\AVRNET项目\AVRNET光盘\AVRuIP\delay.c
(0001) #include "delay.h"
(0002)
(0003)
(0004) void delay_ms(unsigned char ms)
(0005) {
(0006) unsigned short delay_count = F_CPU / 4000;
(0007) #ifdef __GNUC__
(0008) unsigned short cnt;
(0009) asm volatile ("\n"
(0010) "L_dl1%=:\n\t"
(0011) "mov %A0, %A2\n\t"
(0012) "mov %B0, %B2\n"
(0013) "L_dl2%=:\n\t"
(0014) "sbiw %A0, 1\n\t"
(0015) "brne L_dl2%=\n\t"
(0016) "dec %1\n\t" "brne L_dl1%=\n\t":"=&w" (cnt)
(0017) :"r"(ms), "r"((unsigned short) (delay_count))
(0018) );
(0019) #else
(0020) unsigned short delay_cnt = F_CPU/6000;
133A ED80 LDI R24,0xD0
133B E097 LDI R25,7
133C 015C MOVW R10,R24
133D C009 RJMP 0x1347
(0021) //unsigned short delay_cnt = 2400; //*KU* for 14.745600 MHz Clock
(0022) unsigned short delay_cnt_buffer;
(0023)
(0024) while (ms--) {
(0025) delay_cnt_buffer = delay_cnt;
133E 0165 MOVW R12,R10
(0026) while (delay_cnt_buffer--);
133F 0116 MOVW R2,R12
1340 01C1 MOVW R24,R2
1341 9701 SBIW R24,1
1342 016C MOVW R12,R24
1343 2022 TST R2
1344 F7D1 BNE 0x133F
1345 2033 TST R3
1346 F7C1 BNE 0x133F
1347 2E20 MOV R2,R16
1348 2433 CLR R3
1349 5001 SUBI R16,1
134A 2022 TST R2
134B F791 BNE 0x133E
134C 940E2E66 CALL pop_gset4x
134E 9508 RET
FILE: D:\hexok项目\AVRNET项目\AVRNET光盘\AVRuIP\main.c
(0001) /*****************************************************************************
(0002) * Module Name: uIP-AVR Port - main control loop shell
(0003) *
(0004) * Created By: Louis Beaudoin (www.embedded-creations.com)
(0005) *
(0006) * Original Release: September 21, 2002
(0007) *
(0008) * Module Description:
(0009) * This main control loop shell provides everything required for a basic uIP
(0010) * application using the RTL8019AS NIC
(0011) *
(0012) *
(0013) * November 16, 2003
(0014) * Changed NIC interface from RTL8019 specific to general NIC calls
(0015) * Calls the uip_arp_timer function every 10 seconds
(0016) *
(0017) * September 30, 2002
(0018) * Added support for Imagecraft Compiler
(0019) *****************************************************************************/
(0020)
(0021)
(0022) #include "uip.h"
(0023) #include "nic.h"
(0024) #include "uip_arp.h"
(0025) #include "httpd.h"
(0026)
(0027) #include "fs.h"
(0028) #include "fsdata.h"
(0029) #include "cgi.h"
(0030) #include "filelist.h"
(0031) #include "compiler.h"
(0032)
(0033)
(0034) #define BUF ((struct uip_eth_hdr *)&uip_buf[0])
(0035)
(0036)
(0037)
(0038) /*****************************************************************************
(0039) * Periodic Timout Functions and variables
(0040) *
(0041) * The periodic timeout rate can be changed depeding on your application
(0042) * Modify these functions and variables based on your AVR device and clock
(0043) * rate
(0044) * The current setup will interrupt every 256 timer ticks when the timer
(0045) * counter overflows. timerCounter must count until 0.5 seconds have
(0046) * alapsed
(0047) *****************************************************************************/
(0048)
(0049) #define TIMER_PRESCALE 1024
(0050) #define F_CPU 12000000
(0051)
(0052) #define TIMERCOUNTER_PERIODIC_TIMEOUT (F_CPU / TIMER_PRESCALE / 2 / 256)
(0053)
(0054) static unsigned char timerCounter;
(0055)
(0056) void initTimer(void)
(0057) {
(0058) outp( 7, TCCR0 ) ; // timer0 prescale 1/1024 (7)
_initTimer:
134F E087 LDI R24,7
1350 BF83 OUT 0x33,R24
(0059)
(0060) // interrupt on overflow
(0061) sbi( TIMSK, TOIE0 ) ;
1351 B787 IN R24,0x37
1352 6081 ORI R24,1
1353 BF87 OUT 0x37,R24
(0062)
(0063) timerCounter = 0;
1354 2422 CLR R2
1355 922029F7 STS timerCounter,R2
1357 9508 RET
_SIG_OVERFLOW0:
1358 938A ST R24,-Y
1359 939A ST R25,-Y
135A B78F IN R24,0x3F
135B 938A ST R24,-Y
(0064) }
(0065)
(0066)
(0067)
(0068) #ifdef __IMAGECRAFT__
(0069) #pragma interrupt_handler SIG_OVERFLOW0:iv_TIMER0_OVF
(0070) #endif
(0071)
(0072) SIGNAL(SIG_OVERFLOW0)
(0073) {
(0074) timerCounter++;
135C 918029F7 LDS R24,timerCounter
135E 5F8F SUBI R24,0xFF
135F 938029F7 STS timerCounter,R24
1361 9189 LD R24,Y+
1362 BF8F OUT 0x3F,R24
1363 9199 LD R25,Y+
1364 9189 LD R24,Y+
1365 9518 RETI
(0075) }
(0076)
(0077)
(0078)
(0079) /*****************************************************************************
(0080) * Main Control Loop
(0081) *
(0082) *
(0083) *****************************************************************************/
(0084) int main(void)
(0085) {
(0086) unsigned char i;
(0087) unsigned char arptimer=0;
_main:
arptimer --> R10
i --> R12
1366 24AA CLR R10
(0088) PORTD = 0x02;
1367 E082 LDI R24,2
1368 BB82 OUT 0x12,R24
(0089) DDRD = 0x30;
1369 E380 LDI R24,0x30
136A BB81 OUT 0x11,R24
(0090) // init NIC device driver
(0091) nic_init();
136B 940E13F9 CALL _nic_init
(0092)
(0093) // init uIP
(0094) uip_init();
136D 940E1C6B CALL _uip_init
(0095)
(0096) // init http
(0097) httpd_init();
136F 940E174B CALL _httpd_init
(0098)
(0099) // init ARP cache
(0100) uip_arp_init();
1371 940E28E4 CALL _uip_arp_init
(0101)
(0102) // init periodic timer
(0103) initTimer();
1373 DFDB RCALL _initTimer
(0104)
(0105) sei();
1374 9478 BSET 7
1375 C07F RJMP 0x13F5
(0106)
(0107) while(1)
(0108) {
(0109) // look for a packet
(0110) uip_len = nic_poll();
1376 940E1430 CALL _nic_poll
1378 93102BC3 STS uip_len+1,R17
137A 93002BC2 STS uip_len,R16
(0111) if(uip_len == 0)
137C 90202BC2 LDS R2,uip_len
137E 90302BC3 LDS R3,uip_len+1
1380 2022 TST R2
1381 F009 BEQ 0x1383
1382 C03E RJMP 0x13C1
1383 2033 TST R3
1384 F009 BEQ 0x1386
1385 C03B RJMP 0x13C1
(0112) {
(0113) // if timed out, call periodic function for each connection
(0114) if(timerCounter > TIMERCOUNTER_PERIODIC_TIMEOUT)
1386 E186 LDI R24,0x16
1387 E090 LDI R25,0
1388 E0A0 LDI R26,0
1389 E0B0 LDI R27,0
138A 902029F7 LDS R2,timerCounter
138C 2433 CLR R3
138D 2444 CLR R4
138E 2455 CLR R5
138F 1582 CP R24,R2
1390 0593 CPC R25,R3
1391 05A4 CPC R26,R4
1392 05B5 CPC R27,R5
1393 F00C BLT 0x1395
1394 C060 RJMP 0x13F5
(0115) {
(0116) timerCounter = 0;
1395 2422 CLR R2
1396 922029F7 STS timerCounter,R2
(0117)
(0118) for(i = 0; i < UIP_CONNS; i++)
1398 24CC CLR R12
1399 C01B RJMP 0x13B5
(0119) {
(0120) uip_periodic(i);
139A E283 LDI R24,0x23
139B 9D8C MUL R24,R12
139C 0110 MOVW R2,R0
139D E58E LDI R24,0x5E
139E E29A LDI R25,0x2A
139F 0E28 ADD R2,R24
13A0 1E39 ADC R3,R25
13A1 92302BBD STS uip_conn+1,R3
13A3 92202BBC STS uip_conn,R2
13A5 E002 LDI R16,2
13A6 940E1DE5 CALL _uip_process
(0121)
(0122) // transmit a packet, if one is ready
(0123) if(uip_len > 0)
13A8 90202BC2 LDS R2,uip_len
13AA 90302BC3 LDS R3,uip_len+1
13AC 2022 TST R2
13AD F411 BNE 0x13B0
13AE 2033 TST R3
13AF F021 BEQ 0x13B4
(0124) {
(0125) uip_arp_out();
13B0 940E2B14 CALL _uip_arp_out
(0126) nic_send();
13B2 940E13FC CALL _nic_send
13B4 94C3 INC R12
13B5 2D8C MOV R24,R12
13B6 308A CPI R24,0xA
13B7 F310 BCS 0x139A
(0127) }
(0128) }
(0129)
(0130) /* Call the ARP timer function every 10 seconds. */
(0131) if(++arptimer == 20)
13B8 2D8A MOV R24,R10
13B9 5F8F SUBI R24,0xFF
13BA 2EA8 MOV R10,R24
13BB 3184 CPI R24,0x14
13BC F5C1 BNE 0x13F5
(0132) {
(0133) uip_arp_timer();
13BD 940E2905 CALL _uip_arp_timer
(0134) arptimer = 0;
13BF 24AA CLR R10
(0135) }
(0136) }
(0137) }
13C0 C034 RJMP 0x13F5
(0138) else // packet received
(0139) {
(0140) // process an IP packet
(0141) if(BUF->type == htons(UIP_ETHTYPE_IP))
13C1 E000 LDI R16,0
13C2 E018 LDI R17,0x8
13C3 940E27BF CALL _htons
13C5 90202BD6 LDS R2,0x2BD6
13C7 90302BD7 LDS R3,0x2BD7
13C9 1620 CP R2,R16
13CA 0631 CPC R3,R17
13CB F491 BNE 0x13DE
(0142) {
(0143) // add the source to the ARP cache
(0144) // also correctly set the ethernet packet length before processing
(0145) uip_arp_ipin();
13CC 940E2A04 CALL _uip_arp_ipin
(0146) uip_input();
13CE E001 LDI R16,1
13CF 940E1DE5 CALL _uip_process
(0147)
(0148) // transmit a packet, if one is ready
(0149) if(uip_len > 0)
13D1 90202BC2 LDS R2,uip_len
13D3 90302BC3 LDS R3,uip_len+1
13D5 2022 TST R2
13D6 F411 BNE 0x13D9
13D7 2033 TST R3
13D8 F0E1 BEQ 0x13F5
(0150) {
(0151) uip_arp_out();
13D9 940E2B14 CALL _uip_arp_out
(0152) nic_send();
13DB 940E13FC CALL _nic_send
(0153) }
(0154) }
13DD C017 RJMP 0x13F5
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -