8-bit Microcontroller. Application. Note. AVR204: BCD Arithmetics. Features. Introduction. 16-bit Binary to 5-digit BCD Conversion bin2bcd16



Similar documents
8-bit Microcontroller. Application Note. AVR222: 8-point Moving Average Filter

8-bit RISC Microcontroller. Application Note. AVR236: CRC Check of Program Memory

8-bit Microcontroller. Application Note. AVR400: Low Cost A/D Converter

AVR305: Half Duplex Compact Software UART. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit RISC Microcontroller. Application Note. AVR182: Zero Cross Detector

8-bit Microcontroller. Application Note. AVR201: Using the AVR Hardware Multiplier

8-bit Microcontroller. Application Note. AVR314: DTMF Generator

Tag Tuning/RFID. Application Note. Tag Tuning. Introduction. Antenna Equivalent Circuit

AVR106: C functions for reading and writing to Flash memory. 8-bit Microcontrollers. Application Note. Features. Introduction

8-bit Microcontroller. Application Note. AVR415: RC5 IR Remote Control Transmitter. Features. Introduction. Figure 1.

AVR034: Mixing C and Assembly Code with IAR Embedded Workbench for AVR. 8-bit Microcontroller. Application Note. Features.

Quick Start Guide. CAN Microcontrollers. ATADAPCAN01 - STK501 CAN Extension. Requirements

AT91 ARM Thumb Microcontrollers. Application Note. Interfacing a PC Card to an AT91RM9200-DK. Introduction. Hardware Interface

AVR317: Using the Master SPI Mode of the USART module. 8-bit Microcontrollers. Application Note. Features. Introduction

How to Calculate the Capacitor of the Reset Input of a C51 Microcontroller 80C51. Application Note. Microcontrollers. Introduction

AVR319: Using the USI module for SPI communication. 8-bit Microcontrollers. Application Note. Features. Introduction

AVR134: Real Time Clock (RTC) using the Asynchronous Timer. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AT89C5131A Starter Kit... Software User Guide

General Porting Considerations. Memory EEPROM XRAM

8-bit Microcontroller. Application Note. AVR105: Power Efficient High Endurance Parameter Storage in Flash Memory

AVR030: Getting Started with IAR Embedded Workbench for Atmel AVR. 8-bit Microcontrollers. Application Note. Features.

Application Note. C51 Bootloaders. C51 General Information about Bootloader and In System Programming. Overview. Abreviations

AVR245: Code Lock with 4x4 Keypad and I2C LCD. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR120: Characterization and Calibration of the ADC on an AVR. 8-bit Microcontrollers. Application Note. Features. Introduction

AT91 ARM Thumb Microcontrollers. AT91SAM CAN Bootloader. AT91SAM CAN Bootloader User Notes. 1. Description. 2. Key Features

AVR241: Direct driving of LCD display using general IO. 8-bit Microcontrollers. Application Note. Features. Introduction AVR

AVR442: PC Fan Control using ATtiny13. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

3-output Laser Driver for HD-DVD/ Blu-ray/DVD/ CD-ROM ATR0885. Preliminary. Summary

AVR32110: Using the AVR32 Timer/Counter. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit RISC Microcontroller. Application Note. AVR155: Accessing an I 2 C LCD Display using the AVR 2-wire Serial Interface

Application Note. Migrating from RS-232 to USB Bridge Specification USB Microcontrollers. Doc Control. References. Abbreviations

AVR32100: Using the AVR32 USART. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit Microcontroller. Application Note. AVR461: Quick Start Guide for the Embedded Internet Toolkit. Introduction. System Requirements

USB 2.0 Full-Speed Host/Function Processor AT43USB370. Summary. Features. Overview

8-bit Microcontroller. Application Note. AVR410: RC5 IR Remote Control Receiver

Step Motor Controller. Application Note. AVR360: Step Motor Controller. Theory of Operation. Features. Introduction

USB Test Environment ATUSBTEST- SS7400. Summary

8-bit Microcontroller. Application Note. AVR134: Real-Time Clock (RTC) using the Asynchronous Timer. Features. Theory of Operation.

2-wire Serial EEPROM AT24C1024. Advance Information

Two-wire Automotive Serial EEPROM AT24C01A AT24C02 AT24C04 AT24C08 (1) AT24C16 (2)

2-Wire Serial EEPROM AT24C32 AT24C64. 2-Wire, 32K Serial E 2 PROM. Features. Description. Pin Configurations. 32K (4096 x 8) 64K (8192 x 8)

Application Note. 8-bit Microcontrollers. AVR091: Replacing AT90S2313 by ATtiny2313. Features. Introduction

Application Note. USB Mass Storage Device Implementation. USB Microcontrollers. References. Abbreviations. Supported Controllers

AVR1318: Using the XMEGA built-in AES accelerator. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Application Note. 8-bit Microcontrollers. AVR280: USB Host CDC Demonstration. 1. Introduction

AVR444: Sensorless control of 3-phase brushless DC motors. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

How To Prevent Power Supply Corruption On An 8Bit Microcontroller From Overheating

ATF15xx Product Family Conversion. Application Note. ATF15xx Product Family Conversion. Introduction

AVR32701: AVR32AP7 USB Performance. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

Application Note. 8-bit Microcontrollers. AVR307: Half Duplex UART Using the USI Module

Two-wire Serial EEPROM AT24C1024 (1)

AVR353: Voltage Reference Calibration and Voltage ADC Usage. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Using CryptoMemory in Full I 2 C Compliant Mode. Using CryptoMemory in Full I 2 C Compliant Mode AT88SC0104CA AT88SC0204CA AT88SC0404CA AT88SC0808CA

DIP Top View VCC A16 A15 A12 A7 A6 A5 A4 A3 A2 A1 A0 I/O0 I/O1 I/O2 GND A17 A14 A13 A8 A9 A11 A10 I/O7 I/O6 I/O5 I/O4 I/O3. PLCC Top View VCC A17

8-bit. Application Note. Microcontrollers. AVR282: USB Firmware Upgrade for AT90USB

AVR1309: Using the XMEGA SPI. 8-bit Microcontrollers. Application Note. Features. 1 Introduction SCK MOSI MISO SS

AVR1900: Getting started with ATxmega128A1 on STK bit Microcontrollers. Application Note. 1 Introduction

AVR32138: How to optimize the ADC usage on AT32UC3A0/1, AT32UC3A3 and AT32UC3B0/1 series. 32-bit Microcontrollers. Application Note.

AVR1600: Using the XMEGA Quadrature Decoder. 8-bit Microcontrollers. Application Note. Features. 1 Introduction. Sensors

Table of Contents. Section 1 Introduction Section 2 Getting Started Section 3 Hardware Description

AVR033: Getting Started with the CodeVisionAVR C Compiler. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

STK 500, AVRISP, AVRISP

AVR1301: Using the XMEGA DAC. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR1510: Xplain training - XMEGA USART. 8-bit Microcontrollers. Application Note. Prerequisites. 1 Introduction

Application Note. 8-bit Microcontrollers. AVR435: BLDC/BLAC Motor Control Using a Sinus Modulated PWM Algorithm. 1. Features. 2.

AT86RF230 (2450 MHz band) Radio Transceiver... User Guide

8-bit Microcontroller. Application Note. AVR313: Interfacing the PC AT Keyboard

Application Note. 8-bit Microcontrollers. AVR270: USB Mouse Demonstration

AVR1922: Xplain Board Controller Firmware. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR318: Dallas 1-Wire master. 8-bit Microcontrollers. Application Note. Features. Introduction

2-wire Serial EEPROM AT24C512

All-band AM/FM Receiver and Audio Amplifier IC U2510B

8-bit RISC Microcontroller. Application Note. AVR335: Digital Sound Recorder with AVR and DataFlash

AVR2006: Design and characterization of the Radio Controller Board's 2.4GHz PCB Antenna. Application Note. Features.

8-bit. Application Note. Microcontrollers. AVR273: USB Mass Storage Implementation. Features. 1. Introduction

Application Note Microcontrollers. Guidelines to Keep ADC Resolution within Specification. Introduction. ADC Resolution

Application Note. 8-bit Microcontrollers. AVR272: USB CDC Demonstration UART to USB Bridge

AVR055: Using a 32kHz XTAL for run-time calibration of the internal RC. 8-bit Microcontrollers. Application Note. Features.

Application Note. Microcontrollers. AVR480: Anti-Pinch System for Electrical Window

256K (32K x 8) OTP EPROM AT27C256R 256K EPROM. Features. Description. Pin Configurations

AT91 ARM Thumb Microcontrollers. Application Note. GNU-Based Software Development on AT91SAM Microcontrollers. 1. Introduction. 2.

80C51 MCU s. Application Note. Analyzing the Behavior of an Oscillator and Ensuring Good Start-up. Oscillator Fundamentals

AVR441: Intelligent BLDC Fan Controller with Temperature Sensor and Serial Interface. 8-bit Microcontrollers. Application Note.

Atmel AVR4920: ASF - USB Device Stack - Compliance and Performance Figures. Atmel Microcontrollers. Application Note. Features.

AVR223: Digital Filters with AVR. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR287: USB Host HID and Mass Storage Demonstration. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR115: Data Logging with Atmel File System on ATmega32U4. Microcontrollers. Application Note. 1 Introduction. Atmel

AVR447: Sinusoidal driving of three-phase permanent magnet motor using ATmega48/88/ bit Microcontrollers. Application Note.

AVR32788: AVR 32 How to use the SSC in I2S mode. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

APPLICATION NOTE. Atmel AVR134: Real Time Clock (RTC) Using the Asynchronous Timer. Atmel AVR 8-bit Microcontroller. Introduction.

ABEL/CUPL Design File Conversion. Application Note. Converting ABEL Design Files to CUPL. Background for ABEL and CUPL

Atmel AVR4921: ASF - USB Device Stack Differences between ASF V1 and V2. 8-bit Atmel Microcontrollers. Application Note. Features.

AVR068: STK500 Communication Protocol. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

3-output Laser Driver for HD-DVD/ Blu-ray/DVD/ CD-ROM ATR0885. Preliminary. Summary. Features. Applications. 1. Description

Application Note. AVR Microcontrollers. AVR493: Sensorless Commutation of Brushless DC Motor (BLDC) using AT90PWM3 and ATAVRMC

32-bit AVR UC3 Microcontrollers. 32-bit AtmelAVR Application Note. AVR32769: How to Compile the standalone AVR32 Software Framework in AVR32 Studio V2

8051 Flash Microcontroller. Application Note. A Digital Thermometer Using the Atmel AT89LP2052 Microcontroller

Atmel AVR4903: ASF - USB Device HID Mouse Application. Atmel Microcontrollers. Application Note. Features. 1 Introduction

AVR064: A Temperature Monitoring System with LCD Output. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Transcription:

AVR204: BCD Arithmetics Features Conversion 16 Bits 5 Digits, 8 Bits 2 Digits 2-digit Addition and Subtraction Superb Speed and Code Density Runable Example Program Introduction This application note lists routines for BCD arithmetics. A listing of all implementations with key performance specifications is given in Table 1. 8-bit Microcontroller Application ote Table 1. Performance Figures Summary Application Code Size (Words) Execution Time (Cycles) 16-bit Binary to 5-digit BCD Conversion 25 760 8-bit Binary to 2-digit BCD Conversion 6 28 5-digit BCD to 16-bit Binary Conversion 30 108 2-digit BCD to 8-bit Binary Conversion 4 26 2-digit Packed BCD Addition 19 19 2-digit Packed BCD Subtraction 13 15 16-bit Binary to 5-digit BCD Conversion bin2bcd16 This subroutine converts a 16-bit binary value to a 5-digit packed BCD number. The implementation is Code Size optimized. This implementation uses the Z-pointer's auto-decrement facility, and can not be used as is for the AT90Sxx0x series. To use this routine on an AT90Sxx0x, add an IC ZL instruction where indicated in the file listing. Rev. 1

Algorithm Description bin2bcd16 implements the following algorithm: 1. Load Loop counter with 16. 2. Clear all three bytes of result. 3. Shift left input value Low byte. 4. Shift left carry into input value High byte. 5. Shift left carry into result byte 0 (two least significant digits). 6. Shift left carry into result byte 1. 7. Shift left carry into result byte 2 (most significant digit). 8. Decrement Loop counter 9. If Loop counter is zero, return from subroutine. 10. Add $03 to result byte 2. 11. If bit 3 is zero after addition, restore old value of byte 2. 12. Add $30 to result byte 2. 13. If bit 7 is zero after addition, restore old value of byte 2. 14. Add $03 to result byte 1. 15. If bit 3 is zero after addition, restore old value of byte 1. 16. Add $30 to result byte 1. 17. If bit 7 is zero after addition, restore old value of byte 1. 18. Add $03 to result byte 0. 19. If bit 3 is zero after addition, restore old value of byte 0. 20. Add $30 to result byte 0. 21. If bit 7 is zero after addition, restore old value of byte 0. 22. Goto Step 3. In the implementation. Steps 10-21 are carried out inside a loop, where the Z-pointer is used for successive access of all three bytes of the result. This is shown in the flow chart shown in Figure 1. 2 AVR204

AVR204 Figure 1. bin2bcd16 Flow Chart BI2BCD16 LOOP COUTER 16 CLEAR RESULT (3 BTES) SHIFT LEFT IPUT LOW BTE SHIFT LEFT IPUT HIGH BTE WITH CARR SHIFT LEFT RESULT BTE 0 WITH CARR SHIFT LEFT RESULT BTE 1 WITH CARR SHIFT LEFT RESULT BTE 2 WITH CARR DECREMET LOOP COUTER LOOP COUTER = 0 RETUR Z ADRESS OF RESULT BTE 2 + 1 Z Z 1, TMP16A @Z TMP16A TMP16A + $03 TMP16A TMP16A + $30 BIT 3 OF TMP16A SET? BIT 7 OF TMP16A SET? Z = ADDRESS OF RESULT BTE 0? @Z TMP16A @Z TMP16A 3

Usage 1. Load the 16-bit register variable fbinh:fbinl with the 16-bit number to be converted (High byte in fbinh ). 2. Call bin2bcd16. 3. The result is found in the 3-byte register variable fbcd2:fbcd1:fbcd0 with MSD in the lower nibble of fbcd2. Performance Table 2. bin2bcd16 Register Usage Register Input Internal Output R13 fbcd0 BCD Digits 1 and 0 R14 fbcd1 BCD Digits 2 and 3 R15 fbcd2 BCD Digit 4 R16 R17 R18 R19 R30 R31 fbinl Binary Value Low Byte fbinh Binary Value High Byte cnt16a Loop Counter tmp16a Temporary Storage ZL ZH Table 3. bin2bcd16 Performance Figures Parameter Value Code Size (Words) 25 Average Execution Time (Cycles) 760 Register Usage Low Registers High Registers Pointers Interrupts Usage one Peripherals Usage one :3 :4 :Z 4 AVR204

AVR204 8-bit Binary to 2-digit BCD Conversion bin2bcd8 Algorithm Description This subroutine converts an 8-bit binary value to a 2-digit BCD number. The binary number must not exceed 99, since a 2-digit BCD number can only represent 0-99. The implementation does not generate a packed result, i.e., the two digits are represented in two separate bytes. To accomplish this, some smaller modifications must be done to the algorithm as shown in the following section. bin2bcd8 implements the following algorithm: 1. Clear result MSD. 2. Subtract 10 from the 8-bit input number. 3. If result negative, add back 10 to 8-bit input number and return. 4. Increment result MSD and goto step 2. LSD of the result is found in the same register as the input number. If a packed result is needed, make the following changes to the algorithm: Instead of incrementing MSD in Step 4, add $10 to MSD. After adding back 10 to the input number in step 3, add LSD and MSD together. Where to make these changes is indicated in the program listing. Figure 2. bin2bcd8 Flow Chart BI2BCD8 CLEAR RESULT MSD IPUT IPUT 10 RESULT EGATIVE? ICREMET RESULT MSD IPUT IPUT + 10 RETUR Usage 1. Load the register variable fbin with the value to be converted. 2. Call bin2bcd8. 3. The result MSD and LSD is found in fbcdh and fbcdl, respectively. 5

Performance Table 4. bin2bcd8 Register Usage Register Input Internal Output R16 fbin Binary Value tbcdl LSD of Result R17 tbcdh MSD of Result Table 5. bin2bcd8 Performance Figures Parameter Value Code Size (Words) 6 + return Average Execution Time (Cycles) 28 Register Usage Low registers High registers Pointers Interrupts Usage one Peripherals Usage one :one :2 :one 5-digit BCD to 16-bit BCD Conversion BCD2bin16 Algorithm Description This subroutine converts a 5-digit packed BCD number to a 16-bit binary value. Let a, b, c, d, e denote the 5 digits in the BCD number (a = MSD, e = LSD). The result is generated by computing the following equation: 10( 10( 10( 10a + b) + c) + d) + e The four times repeated operation multiply-by-10-and-add is implemented as a subroutine. This subroutine takes the 16-bit register variable mp10h:mp10l and the register variable adder as input parameters. The subroutine can be called by two separate addresses, mul10a and mul10b. The difference is summarized as follows: mul10a multiplies mp10h:mp10l and adds the higher nibble of adder. mul10b multiplies mp10h:mp10l and adds the lower nibble of adder. The subroutine implements the following algorithm: 1. Swap high/low nibble of adder. 2. Make a copy of mp10h:mp10l. 3. Multiply original by two (Shift left). 4. Multiply copy by eight (Shift left x 3). 5. Add copy and original. 6. Clear upper nibble of adder. 7. Add lower nibble of adder. 8. If carry set, increment mp10h. When calling mul10b, Step 1 is omitted. 6 AVR204

AVR204 The main routine follows this algorithm: 1. Clear upper nibble of BCD byte 2 (MSD). 2. Clear mp10h. 3. mp10h BCD byte 2. 4. adder BCD byte 1. 5. Call mul10a. 6. adder BCD byte 1. 7. Call mul10b. 8. adder BCD byte 0. 9. Call mul10a. 10. adder BCD byte 0. 11. Call mul10b. Usage 1. Load the 3-byte register variable fbcd2:fbcd1:fbcd0 with the value to be converted (MSD in the lower nibble of fbcd2 ). 2. Call BCD2bin16. 3. The 16-bit result is found in tbinh:tbinl. Performance Table 6. BCD2bin16 Register Usage Register Input Internal Output R12 R13 R14 R15 R16 fbcd0 BCD Digits 1 and 0 R17 fbcd1 BCD Digits 2 and 3 R18 fbcd2 BCD Digit 4 copyl Temporary Value Used by mul10a/mul10b copyh Temporary Value Used by mul10a/mul10b mp10l Low Byte of Input to be Multiplied by mul10a/mul10b mp10h High Byte of Input to be Multiplied by mul10a/mul10b tbinl Low Byte of 16- bit Result tbinh High Byte of 16- bit Result 7

Table 7. BCD2bin16 Performance Figures Parameter Value Code Size (Words) 30 Execution Time (Cycles) 108 Register Usage Low registers High registers Pointers Interrupts Usage one Peripherals Usage one :4 :4 :one 2-digit BCD to 8-bit Binary Conversion BCD2bin8 Algorithm Description This subroutine converts a 2-digit BCD number to an 8-bit binary value. The implementation does not accept a packed BCD input, i.e., the two digits must be represented in two separate bytes. To accomplish this, some modifications will have to be made to the algorithm as shown in the following section. BCD2bin8 implements the following algorithm: 1. Subtract 1 from input MSD. 2. If result negative, return. 3. Add 10 to 8-bit result/input LSD. 4. Goto Step 1. The result is found in the same register as the input number LSD. To make the algorithm accept a packed BCD input, use this algorithm: 1. Copy BCD input to result. 2. Clear higher nibble of result. 3. Subtract $10 from input MSD. 4. If half carry set, return. 5. Add decimal 10 to result. 6. Goto Step 3. The program listing shows how and where to make the changes. Figure 3 shows the flowchart which applies to the non-packed input implementation. 8 AVR204

AVR204 Figure 3. BCD2bin8 Flow Chart BCD2BI8 MSD MSD 1 MSD EGATIVE? ADD 10 TO LSD/RESULT RETUR Usage 1. Load the register variables fbcdh and fbcdl with the input MSD and LSD, respectively. 2. Call BCD2bin8. 3. The 8-bit result is found in tbin. Performance Table 8. BCD2bin8 Register Usage Register Input Internal Output R16 fbcdl LSD of BCD Input tbin 8-bit of Result R17 fbcdh MSD of BCD Input Table 9. BCD2bin8 Performance Figures Parameter Value Code Size (Words) 4 + return Average Execution Time (Cycles) 26 Register Usage Low registers High registers Pointers Interrupts Usage one Peripherals Usage one :one :2 :one 9

2-digit Packed BCD Addition BCDadd Algorithm Description This subroutine adds two 2-digit packed BCD numbers. The output is the sum of the two input numbers, also as 2-digit packed BCD, and any overflow carry. BCDadd implements the following algorithm: 1. Add the values binary. 2. If half carry set, set BCD carry, add 6 to LSD, and Goto Step 5. 3. Clear BCD carry and add 6 to LSD. 4. If half carry clear after adding 6, LSD 9, so restore LSD by subtracting 6. 5. Add 6 to MSD. 6. If carry set in step 1, 3, or 5 above, then MSD > 9, so set BCD carry and return. 7. If carry was set during Step 1, restore MSD by subtracting 6. Figure 4. BCDadd Flow Chart BCDADD BCD1 BCD1 + BCD2 CLEAR BCD CARR CARR SET? SET BCD CARR HALF CARR SET? BCD1 BCD1 + 6 (LSD LSD + 6) BCD1 BCD1 + 6 (LSD LSD + 6) HALF CARR SET (LSD > 9)? BCD1 BCD1 6 (RESTORE LSD) HALF CARR SET? SET BCD CARR BCD1 BCD1 + $60 (MSD MSD + 6) CARR SET? BCD CARR SET? BCD1 BCD1 $60 (RESTORE MSD) SET BCD CARR RETUR 10 AVR204

AVR204 Usage 1. Load the register variables BCD1 and BCD2 with the numbers to be added. 2. Call BCDadd. 3. The BCD sum is found in BCD1 and the overflow carry in BCD2. Performance Table 10. BCDadd Register Usage Register Input Internal Output R16 BCD1 BCD umber 1 BCD1 BCD Result R17 BCD2 BCD umber 2 BCD2 Overflow Carry R18 tmpadd Holds Values $06 and $60 to be Added Table 11. BCDadd Performance Figures Parameter Value Code Size (Words) 19 Average Execution Time (Cycles) 19 Register Usage Low registers High registers Pointers Interrupts Usage one Peripherals Usage one :one :3 :one 2-digit Packed BCD Subtraction BCDsub Algorithm Description This subroutine subtract two 2-digit packed BCD numbers. The output is the difference of the two input numbers, also as 2-digit packed BCD, and any underflow carry. BCDadd implements the following algorithm: 1. Add the values binary. 2. If carry set, set BCD carry. 3. If half carry set, subtract 6 from LSD. 4. If BCD carry clear, return. 5. Subtract six from MSD and set BCD carry. 6. If carry set, set BCD carry. 11

Figure 5. BCDsub Flow Chart BCD2SUB BCDA BCDA BCDB CLEAR BCD CARR CARR SET? Set BCD CARR HALF CARR SET? BCDA BCDA 6 (LSD LSD 6) BCD CARR SET? BCD1 BCD1 $60 (MSD MSD 6) SET BCD CARR CARR SET? CLEAR BCD CARR RETUR Usage 1. Load the register variable BCDa with the number to be subtracted and BCDb with the number subtract. 2. Call BCDsub. 3. The BCD sum is found in BCDa and the underflow carry in BCDb. 12 AVR204

AVR204 Performance Table 12. BCDadd Register Usage Register Input Internal Output R16 BCDa BCD umber to Subtract From BCD1 BCD Result R17 BCDb BCD umber to Subtract BCD2 Underflow Carry Table 13. BCDadd Performance Figures Parameter Value Code Size (Words) 13 Average Execution Time (Cycles) 15 Register Usage Low registers High registers Pointers Interrupts Usage one Peripherals Usage one :one :2 :one 13

Atmel Headquarters Corporate Headquarters 2325 Orchard Parkway San Jose, CA 95131 TEL 1(408) 441-0311 FAX 1(408) 487-2600 Europe Atmel Sarl Route des Arsenaux 41 Case Postale 80 CH-1705 Fribourg Switzerland TEL (41) 26-426-5555 FAX (41) 26-426-5500 Asia Room 1219 Chinachem Golden Plaza 77 Mody Road Tsimhatsui East Kowloon Hong Kong TEL (852) 2721-9778 FAX (852) 2722-1369 Japan 9F, Tonetsu Shinkawa Bldg. 1-24-8 Shinkawa Chuo-ku, Tokyo 104-0033 Japan TEL (81) 3-3523-3551 FAX (81) 3-3523-7581 Atmel Operations Memory 2325 Orchard Parkway San Jose, CA 95131 TEL 1(408) 441-0311 FAX 1(408) 436-4314 Microcontrollers 2325 Orchard Parkway San Jose, CA 95131 TEL 1(408) 441-0311 FAX 1(408) 436-4314 La Chantrerie BP 70602 44306 antes Cedex 3, France TEL (33) 2-40-18-18-18 FAX (33) 2-40-18-19-60 ASIC/ASSP/Smart Cards Zone Industrielle 13106 Rousset Cedex, France TEL (33) 4-42-53-60-00 FAX (33) 4-42-53-60-01 1150 East Cheyenne Mtn. Blvd. Colorado Springs, CO 80906 TEL 1(719) 576-3300 FAX 1(719) 540-1759 Scottish Enterprise Technology Park Maxwell Building East Kilbride G75 0QR, Scotland TEL (44) 1355-803-000 FAX (44) 1355-242-743 RF/Automotive Theresienstrasse 2 Postfach 3535 74025 Heilbronn, Germany TEL (49) 71-31-67-0 FAX (49) 71-31-67-2340 1150 East Cheyenne Mtn. Blvd. Colorado Springs, CO 80906 TEL 1(719) 576-3300 FAX 1(719) 540-1759 Biometrics/Imaging/Hi-Rel MPU/ High Speed Converters/RF Datacom Avenue de Rochepleine BP 123 38521 Saint-Egreve Cedex, France TEL (33) 4-76-58-30-00 FAX (33) 4-76-58-34-80 e-mail literature@atmel.com Web Site http://www.atmel.com Atmel Corporation 2003. Atmel Corporation makes no warranty for the use of its products, other than those expressly contained in the Company s standard warranty which is detailed in Atmel s Terms and Conditions located on the Company s web site. The Company assumes no responsibility for any errors which may appear in this document, reserves the right to change devices or specifications detailed herein at any time without notice, and does not make any commitment to update the information contained herein. o licenses to patents or other intellectual property of Atmel are granted by the Company in connection with the sale of Atmel products, expressly or by implication. Atmel s products are not authorized for use as critical components in life support devices or systems. ATMEL and AVR are the registered trademarks of Atmel. Other terms and product names may be the trademarks of others. Printed on recycled paper. 0M