AVRASM ver. 2.2.7 C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\main.asm Sun Jun 10 03:42:22 2018 [builtin](2): Including file 'C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.150\avrasm\inc\m328pdef.inc' C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\main.asm(34): Including file 'C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\vectors.asm' C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\main.asm(35): Including file 'C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\hd44780.asm' C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\hd44780.asm(7): Including file 'C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\hd44780.inc' C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\hd44780.asm(29): Including file 'C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\div8u.asm' C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\div8u.asm(6): warning: Register r16 already defined by the .DEF directive C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\hd44780.asm(29): 'C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\div8u.asm' included form here C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\main.asm(35): 'C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\hd44780.asm' included form here C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\main.asm(36): Including file 'C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\wait.asm' C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\main.asm(37): Including file 'C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\1-wire.asm' C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\1-wire.asm(9): warning: Register r17 already defined by the .DEF directive C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\main.asm(37): 'C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\1-wire.asm' included form here C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\main.asm(38): Including file 'C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\crc8.asm' [builtin](2): Including file 'C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.150\avrasm\inc\m328pdef.inc' C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\main.asm(34): Including file 'C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\vectors.asm' C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\main.asm(35): Including file 'C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\hd44780.asm' C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\hd44780.asm(7): Including file 'C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\hd44780.inc' C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\hd44780.asm(29): Including file 'C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\div8u.asm' C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\main.asm(36): Including file 'C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\wait.asm' C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\main.asm(37): Including file 'C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\1-wire.asm' C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\main.asm(38): Including file 'C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\crc8.asm' ;------------------------------------------------------------------------------ ;***** Created: 2011-02-09 12:03 ******* Source: ATmega328P.xml ********** ;************************************************************************* ;* A P P L I C A T I O N N O T E F O R T H E A V R F A M I L Y ;* ;* Number : AVR000 ;* File Name : "m328Pdef.inc" ;* Title : Register/Bit Definitions for the ATmega328P ;* Date : 2011-02-09 ;* Version : 2.35 ;* Support E-mail : avr@atmel.com ;* Target MCU : ATmega328P ;* ;* DESCRIPTION ;* When including this file in the assembly program file, all I/O register ;* names and I/O register bit names appearing in the data book can be used. ;* In addition, the six registers forming the three data pointers X, Y and ;* Z have been assigned names XL - ZH. Highest RAM address for Internal ;* SRAM is also defined ;* ;* The Register names are represented by their hexadecimal address. ;* ;* The Register Bit names are represented by their bit number (0-7). ;* ;* Please observe the difference in using the bit names with instructions ;* such as "sbr"/"cbr" (set/clear bit in register) and "sbrs"/"sbrc" ;* (skip if bit in register set/cleared). The following example illustrates ;* this: ;* ;* in r16,PORTB ;read PORTB latch ;* sbr r16,(1<= 4MHz ; http://avr-mcu.dxp.pl ; e-mail : radek@dxp.pl ; (c) Radoslaw Kwiecien ;------------------------------------------------------------------------------ #ifndef F_CPU #endif #if F_CPU < 4000000 #endif #define CYCLES_PER_US (F_CPU/1000000) #define C4PUS (CYCLES_PER_US/4) #define DVUS(x) (C4PUS*x) ;------------------------------------------------------------------------------ ; Input : XH:XL - number of CPU cycles to wait (divided by four) ;------------------------------------------------------------------------------ Wait4xCycles: 0000b5 9711 sbiw XH:XL, 1 ; x-- (2 cycles) 0000b6 f7f1 brne Wait4xCycles ; jump if not zero (2 cycles) 0000b7 9508 ret ;------------------------------------------------------------------------------ ; Input : r16 - number of miliseconds to wait ;------------------------------------------------------------------------------ WaitMiliseconds: 0000b8 930f push r16 WaitMsLoop: 0000b9 e0b7 ldi XH,HIGH(DVUS(500)) 0000ba eda0 ldi XL,LOW(DVUS(500)) 0000bb dff9 rcall Wait4xCycles 0000bc e0b7 ldi XH,HIGH(DVUS(500)) 0000bd eda0 ldi XL,LOW(DVUS(500)) 0000be dff6 rcall Wait4xCycles 0000bf 950a dec r16 0000c0 f7c1 brne WaitMsLoop 0000c1 910f pop r16 0000c2 9508 ret ;------------------------------------------------------------------------------ ; ;------------------------------------------------------------------------------ #include "1-wire.asm" ; ;------------------------------------------------------------------------------ .equ OW_PORT = PORTB .equ OW_PIN = PINB .equ OW_DDR = DDRB .equ OW_DQ = PB0 .def OWCount = r17 #define ReadRom 0x33 #define SkipRom 0xcc #define ConvertTemp 0x44 ; Initiates temperature conversion. #define WScratch 0x4e ; Writes data into scratchpad bytes 2, 3, and4 (TH, TL, and configuration registers). #define RScratch 0xbe ;------------------------------------------------------------------------------ ; ;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------ ; Data segment, variable definitions ;------------------------------------------------------------------------------ .dseg 000108 TempWord: .byte 3 00010b TRegister: .byte 3 00010e ConfigRegister: .byte 2 .cseg ;------------------------------------------------------------------------------ ; Output : T - presence bit ;------------------------------------------------------------------------------ OWReset: 0000c3 9828 cbi OW_PORT,OW_DQ 0000c4 9a20 sbi OW_DDR,OW_DQ 0000c5 e0b7 ldi XH, HIGH(DVUS(470)) 0000c6 e5a8 ldi XL, LOW(DVUS(470)) 0000c7 dfed rcall Wait4xCycles 0000c8 9820 cbi OW_DDR,OW_DQ 0000c9 e0b1 ldi XH, HIGH(DVUS(70)) 0000ca e1a8 ldi XL, LOW(DVUS(70)) 0000cb dfe9 rcall Wait4xCycles 0000cc 9468 set 0000cd 9b18 sbis OW_PIN,OW_DQ 0000ce 94e8 clt 0000cf e0b3 ldi XH, HIGH(DVUS(240)) 0000d0 eca0 ldi XL, LOW(DVUS(240)) 0000d1 dfe3 rcall Wait4xCycles 0000d2 9508 ret ;------------------------------------------------------------------------------ ; Input : C - bit to write ;------------------------------------------------------------------------------ OWWriteBit: 0000d3 f418 brcc OWWriteZero 0000d4 e0b0 ldi XH, HIGH(DVUS(1)) 0000d5 e0a4 ldi XL, LOW(DVUS(1)) 0000d6 c002 rjmp OWWriteOne OWWriteZero: 0000d7 e0b1 ldi XH, HIGH(DVUS(120)) 0000d8 eea0 ldi XL, LOW(DVUS(120)) OWWriteOne: 0000d9 9a20 sbi OW_DDR, OW_DQ 0000da dfda rcall Wait4xCycles 0000db 9820 cbi OW_DDR, OW_DQ 0000dc e0b0 ldi XH, HIGH(DVUS(60)) 0000dd efa0 ldi XL, LOW(DVUS(60)) 0000de dfd6 rcall Wait4xCycles 0000df 9508 ret ;------------------------------------------------------------------------------ ; Input : r16 - byte to write ;------------------------------------------------------------------------------ OWWriteByte: 0000e0 931f push OWCount 0000e1 e010 ldi OWCount,0 OWWriteLoop: 0000e2 9507 ror r16 0000e3 dfef rcall OWWriteBit 0000e4 9513 inc OWCount 0000e5 3018 cpi OWCount,8 0000e6 f7d9 brne OWWriteLoop 0000e7 911f pop OWCount 0000e8 9508 ret ;------------------------------------------------------------------------------ ; Output : C - bit from slave ;------------------------------------------------------------------------------ OWReadBit: 0000e9 e0b0 ldi XH, HIGH(DVUS(1)) 0000ea e0a4 ldi XL, LOW(DVUS(1)) 0000eb 9a20 sbi OW_DDR, OW_DQ 0000ec dfc8 rcall Wait4xCycles 0000ed 9820 cbi OW_DDR, OW_DQ 0000ee e0b0 ldi XH, HIGH(DVUS(5)) 0000ef e1a4 ldi XL, LOW(DVUS(5)) 0000f0 dfc4 rcall Wait4xCycles 0000f1 94e8 clt 0000f2 9918 sbic OW_PIN,OW_DQ 0000f3 9468 set 0000f4 e0b0 ldi XH, HIGH(DVUS(50)) 0000f5 eca8 ldi XL, LOW(DVUS(50)) 0000f6 dfbe rcall Wait4xCycles 0000f7 9408 sec 0000f8 f00e brts OWReadBitEnd 0000f9 9488 clc OWReadBitEnd: 0000fa 9508 ret ;------------------------------------------------------------------------------ ; Output : r16 - byte from slave ;------------------------------------------------------------------------------ OWReadByte: 0000fb 931f push OWCount 0000fc e010 ldi OWCount,0 OWReadLoop: 0000fd dfeb rcall OWReadBit 0000fe 9507 ror r16 0000ff 9513 inc OWCount 000100 3018 cpi OWCount,8 000101 f7d9 brne OWReadLoop 000102 911f pop OWCount 000103 9508 ret ;------------------------------------------------------------------------------ ; 18b20 MainReadTemp ;------------------------------------------------------------------------------ MainReadTemp: 000104 e0c8 ldi YL,LOW(TempWord) 000105 e0d1 ldi YH,HIGH(TempWord) 000106 dfbc rcall OWReset ; One wire reset 000107 f3e6 brts MainReadTemp ; If device not present go to MainLoop 000108 dfba rcall OWReset ; One wire reset 000109 f3d6 brts MainReadTemp ; If device not present go to MainLoop 00010a dfb8 rcall OWReset ; One wire reset 00010b f3c6 brts MainReadTemp ; If device not present go to MainLoop 00010c ec0c ldi r16,SkipRom ; Write Skip Rom one wire in "single-drop" 00010d dfd2 rcall OWWriteByte ; 00010e eb0e ldi r16, RScratch ; Write ConvertCommand 00010f dfd0 rcall OWWriteByte ; 000110 dfea rcall OWReadByte 000111 9309 st Y+, r16 ; Store TEMPERATURE LSB(50h) byte to table, and increment pointer 000112 2f50 mov r21, r16 000113 dfe7 rcall OWReadByte 000114 9309 st Y+, r16 ; Store TEMPERATURE MSB(05h) byte to table, and increment pointer 000115 2f60 mov r22, r16 000116 9508 ret TempRequest: 000117 dfab rcall OWReset ; One wire reset 000118 f35e brts MainReadTemp ; If device not present go to MainLoop 000119 ec0c ldi r16,SkipRom ; Write Skip Rom one wire in "single-drop" 00011a dfc5 rcall OWWriteByte ; 00011b e404 ldi r16, ConvertTemp ; Write ConvertCommand 00011c dfc3 rcall OWWriteByte ; 00011d eb0c ldi r16, 188 00011e df99 rcall WaitMiliseconds 00011f 9518 reti ConvertTempForLCD: ;r18 contiendra la partie décimal et xl la partie entiere 000120 930f push r16 000121 931f push r17 000122 e0c8 ldi YL,LOW(TempWord) 000123 e0d1 ldi YH,HIGH(TempWord) 000124 91a9 ld XL, Y+ 000125 91b9 ld XH, Y+ 000126 95a6 lsr XL 000127 95a6 lsr XL ;Sup des deux bit inutilisé 000128 e003 ldi r16, 0x03 000129 2f2a mov r18, XL 00012a 2320 AND r18, r16 00012b e109 ldi r16, 25 00012c 9f20 mul r18, r16 00012d 0190 movw r18, r0 00012e 95a6 lsr XL 00012f 95a6 lsr XL ;Sup des deux bit de fraction 000130 e00f ldi r16, 15 000131 23b0 and XH,r16 000132 95b7 ROR XH 000133 95b7 ROR XH 000134 95b7 ROR XH 000135 95b7 ROR XH 000136 95b7 ROR XH ; xh>>4+1(+1 pour le carry) 000137 2bab or XL,XH 000138 911f pop r17 000139 910f pop r16 00013a 9508 ret #include "crc8.asm" ; CRC8 computing functions ; based on Application Note 27 from Dallas Semiconductor ; http://avr-mcu.dxp.pl ; e-mail: radek@dxp.pl ; (c) Radoslaw Kwiecien ;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------ ; Data segment ;------------------------------------------------------------------------------ .dseg 000110 _crc : .byte 1 ;------------------------------------------------------------------------------ ; Code segment ;------------------------------------------------------------------------------ .cseg ;------------------------------------------------------------------------------ ; Update crc value ;------------------------------------------------------------------------------ CRC8Update: 00013b 930f push r16 00013c 931f push r17 00013d 932f push r18 00013e 930f push r16 00013f e018 ldi r17, 8 CRC8L: 000140 9120 0110 lds r18, _crc 000142 2702 eor r16, r18 000143 9507 ror r16 000144 9100 0110 lds r16, _crc 000146 f410 brcc CRC8zero 000147 e128 ldi r18, 0x18 000148 2702 eor r16, r18 CRC8zero: 000149 9507 ror r16 00014a 9300 0110 sts _crc, r16 00014c 910f pop r16 00014d 9506 lsr r16 00014e 930f push r16 00014f 951a dec r17 000150 f779 brne CRC8L 000151 910f pop r16 000152 912f pop r18 000153 911f pop r17 000154 910f pop r16 000155 9508 ret ;------------------------------------------------------------------------------ ; Clear crc value ;------------------------------------------------------------------------------ CRC8Init: 000156 930f push r16 000157 e000 ldi r16,0 000158 9300 0110 sts _crc, r16 00015a 910f pop r16 00015b 9508 ret ;------------------------------------------------------------------------------ ; Copy crc value to r16 ;------------------------------------------------------------------------------ GetCRC8: 00015c 9100 0110 lds r16, _crc 00015e 9508 ret ;------------------------------------------------------------------------------ ; End of crc8.asm file ;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------ ; Constants definition ;------------------------------------------------------------------------------ Text1 : 00015f 4269 000160 7475 000161 6f74 000162 206e 000163 6552 000164 6461 000165 7265 000166 0000 .db "iButton Reader",0,0 Text2 : 000167 7661 000168 2d72 000169 636d 00016a 2e75 00016b 7864 00016c 2e70 00016d 6c70 00016e 0000 .db "avr-mcu.dxp.pl",0,0 Tp : 00016f 002e C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\main.asm(47): warning: .cseg .db misalignment - padding zero byte 000170 0000 .db ".",0,0 ;------------------------------------------------------------------------------ ; Program entry point ;------------------------------------------------------------------------------ ProgramEntryPoint: 000171 ef0f ldi r16, LOW(RAMEND) ; Initialize stack pointer 000172 bf0d out SPL, r16 ; 000173 df21 rcall LCD_Init ; Initialize LCD 000174 e001 ldi r16, (HD44780_LINE0 + 1) ; 000175 df19 rcall LCD_SetAddressDD ; Set Display Data address to (0,1) 000176 ebee ldi ZL, LOW(Text1 << 1) ; Load string address to Z 000177 e0f2 ldi ZH, HIGH(Text1<< 1) ; 000178 deee rcall LCD_WriteString ; Display string 000179 e401 ldi r16, (HD44780_LINE1 + 1) ; 00017a df14 rcall LCD_SetAddressDD ; Set Display Data address to (1,1); ;ldi ZL, LOW(Text2 << 1) ; ;ldi ZH, HIGH(Text2<< 1) ; Load string address to Z ;rcall LCD_WriteString ; Display string ConfigResolTo10Bits: 00017b df47 rcall OWReset 00017c f3f6 brts ConfigResolTo10Bits 00017d ec0c ldi r16, SkipRom ; Write Skip Rom one wire in "single-drop" 00017e df61 rcall OWWriteByte 00017f e40e ldi r16, WScratch 000180 df5f rcall OWWriteByte 000181 2700 clr r16 000182 df5d rcall OWWriteByte ;th,tl 000183 df5c rcall OWWriteByte ;th,tl 000184 e30f ldi r16, 63 000185 df5a rcall OWWriteByte ;resol MainLoop: 000186 e401 ldi r16, (HD44780_LINE1 + 1) ; 000187 df07 rcall LCD_SetAddressDD ; Set Display Data address to (1,1); 000188 df3a rcall OWReset ; One wire reset 000189 f3e6 brts MainLoop ; If device not present go to MainLoop 00018a df8c rcall TempRequest 00018b df78 rcall MainReadTemp 00018c df93 rcall ConvertTempForLCD ;rcall CRC8Init ; Initialize CRC8 value 00018d 940c 01a4 jmp LoadLoop 00018f df6b rcall OWReadByte ; Read first byte (Family ID) 000190 3000 cpi r16,0 ; If first byte equal to zero, go to MainLoop 000191 f3a1 breq MainLoop ; (short circuit on one wire bus) 000192 dfa8 rcall CRC8Update ; Update the CRC 000193 e0c0 ldi YL, LOW(SerialNumber) ; 000194 e0d1 ldi YH, HIGH(SerialNumber) ; Load to Y address of SerialNumber table 000195 9309 st Y+, r16 ; Store first byte to table, and increment pointer 000196 e017 ldi r17, 7 ; 7 bytes remaining StoreLoop: 000197 df63 rcall OWReadByte ; read next byte 000198 dfa2 rcall CRC8Update ; update the CRC 000199 9309 st Y+, r16 ; store next byte to table, and increment pointer 00019a 951a dec r17 ; decrement loop counter 00019b f7d9 brne StoreLoop ; if greater than zero, jump to StoreLoop 00019c dfbf rcall GetCRC8 ; Read computet CRC8 00019d 3000 cpi r16,0 ; copmare with zero 00019e f739 brne MainLoop ; if not equal, jump to MainLoop (bad CRC) ; else 00019f e400 ldi r16, (HD44780_LINE1 + 0) ; 0001a0 deee rcall LCD_SetAddressDD ; Set DisplayData address to (0,1) 0001a1 e0c0 ldi YL, LOW(SerialNumber) ; 0001a2 e0d1 ldi YH, HIGH(SerialNumber) ; Load to Y address of SerialNumber table 0001a3 e012 ldi r17,2 ; 8 digits to display LoadLoop: 0001a4 930f push r16 0001a5 2f0a mov r16, XL ; load to r16 byte from table 0001a6 930f push r16 0001a7 ef30 ldi r19,0xF0 0001a8 2303 and r16,r19 0001a9 d020 rcall bin2bcd8 0001aa 9506 lsr r16 0001ab 9506 lsr r16 0001ac 9506 lsr r16 0001ad 9506 lsr r16 0001ae debe rcall LCD_WriteHexDigit ; display it on LCD in HEX 0001af 910f pop r16 0001b0 d019 rcall bin2bcd8 0001b1 e02f ldi r18,0x0F 0001b2 2302 and r16,r18 0001b3 deb9 rcall LCD_WriteHexDigit ; display it on LCD in HEX 0001b4 2f02 mov r16, r18 ; load to r16 byte from table 0001b5 930f push r16 0001b6 ef30 ldi r19,0xF0 0001b7 2303 and r16,r19 0001b8 d011 rcall bin2bcd8 0001b9 9506 lsr r16 0001ba 9506 lsr r16 0001bb 9506 lsr r16 0001bc 9506 lsr r16 0001bd deaf rcall LCD_WriteHexDigit ; display it on LCD in HEX 0001be 910f pop r16 0001bf d00a rcall bin2bcd8 0001c0 e02f ldi r18,0x0F 0001c1 2302 and r16,r18 0001c2 deaa rcall LCD_WriteHexDigit ; display it on LCD in HEX 0001c3 0000 nop 0001c4 0000 nop 0001c5 0000 nop 0001c6 940c 0186 jmp MainLoop 0001c8 f6d9 brne LoadLoop ; if not zero, jump to LoadLoop 0001c9 cfbc rjmp MainLoop ; jump to MainLoop ;------------------------------------------------------------------------------ ; End of file ;------------------------------------------------------------------------------ ;======= Converting from HEX to BCD ====================================================https://evileg.com/en/post/19/ ;***************************************************** ;* "bin2BCD8" - 8-bit Binary to BCD conversion ;* This subroutine converts an 8-bit number (temp) to a 2-digit ;* i.e 0x15 becomes 0x21 ;* result in temp ;********************************************************** ;.def tBCD = r21 ;add this to main asm file ; bin2bcd8: 0001ca 2755 clr r21 ;clear temp reg bBCD8_1: 0001cb 500a subi r16,10 ;input = input - 10 0001cc f010 brcs bBCD8_2 ;abort if carry set 0001cd 5f50 subi r21,-$10 ;tBCD = tBCD + 10 0001ce cffc rjmp bBCD8_1 ;loop again bBCD8_2: 0001cf 5f06 subi r16,-10 ;compensate extra subtraction 0001d0 0f05 add r16,r21 RESOURCE USE INFORMATION ------------------------ Notice: The register and instruction counts are symbol table hit counts, and hence implicitly used resources are not counted, eg, the 'lpm' instruction without operands implicitly uses r0 and z, none of which are counted. x,y,z are separate entities in the symbol table and are counted separately from r26..r31 here. .dseg memory usage only counts static data declared with .byte "ATmega328P" register use summary: x : 0 y : 6 z : 1 r0 : 1 r1 : 0 r2 : 0 r3 : 0 r4 : 0 r5 : 0 r6 : 0 r7 : 0 r8 : 0 r9 : 0 r10: 0 r11: 0 r12: 0 r13: 0 r14: 3 r15: 6 r16: 117 r17: 32 r18: 17 r19: 4 r20: 0 r21: 4 r22: 1 r23: 0 r24: 0 r25: 0 r26: 21 r27: 21 r28: 4 r29: 4 r30: 1 r31: 1 Registers used: 17 out of 35 (48.6%) "ATmega328P" instruction use summary: .lds : 0 .sts : 0 adc : 0 add : 5 adiw : 0 and : 6 andi : 2 asr : 0 bclr : 0 bld : 0 brbc : 0 brbs : 0 brcc : 3 brcs : 1 break : 0 breq : 2 brge : 0 brhc : 0 brhs : 0 brid : 0 brie : 0 brlo : 1 brlt : 0 brmi : 0 brne : 12 brpl : 0 brsh : 0 brtc : 0 brts : 7 brvc : 0 brvs : 0 bset : 0 bst : 0 call : 0 cbi : 12 cbr : 0 clc : 2 clh : 0 cli : 0 cln : 0 clr : 4 cls : 0 clt : 2 clv : 0 clz : 0 com : 0 cp : 0 cpc : 0 cpi : 7 cpse : 0 dec : 6 eor : 2 fmul : 0 fmuls : 0 fmulsu: 0 icall : 0 ijmp : 0 in : 0 inc : 3 jmp : 2 ld : 2 ldd : 0 ldi : 77 lds : 3 lpm : 1 lsl : 0 lsr : 13 mov : 5 movw : 1 mul : 1 muls : 0 mulsu : 0 neg : 0 nop : 3 or : 1 ori : 2 out : 1 pop : 18 push : 19 rcall : 77 ret : 25 reti : 26 rjmp : 7 rol : 2 ror : 9 sbc : 0 sbci : 0 sbi : 15 sbic : 1 sbis : 1 sbiw : 1 sbr : 0 sbrc : 4 sbrs : 4 sec : 2 seh : 0 sei : 0 sen : 0 ser : 0 ses : 0 set : 2 sev : 0 sez : 0 sleep : 0 spm : 0 st : 4 std : 0 sts : 2 sub : 2 subi : 3 swap : 3 tst : 0 wdr : 0 Instructions used: 51 out of 113 (45.1%) "ATmega328P" memory use summary [bytes]: Segment Begin End Code Data Used Size Use% --------------------------------------------------------------- [.cseg] 0x000000 0x0003a4 846 36 882 32768 2.7% [.dseg] 0x000100 0x000111 0 17 17 2048 0.8% [.eseg] 0x000000 0x000000 0 0 0 1024 0.0% Assembly complete, 0 errors, 3 warnings