[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-562618-105":3,"detail-sidebar-cat-0-en-105":80,"doc-detail-562618-en":130,"doc-similar-562618":187},{"code":4,"msg":5,"data":6},0,"ok",{"site_id":7,"language":8,"slug":9,"title":10,"keywords":11,"description":12,"schema_data":13,"social_meta":73,"head_meta":75,"extra_data":77,"updated_unix":79},105,"en","an526-pic16c5x-pic16cxxx-math-utility-routines","AN526 - PIC16C5X / PIC16CXXX Math Utility Routines","","AN526 introduces utility math routines for Microchip’s PIC16C5X and PIC16CXXX 8-bit microcontrollers. It covers multiple arithmetic and conversion operations implemented in native assembly, including 8x8 unsigned multiplication, 16x16 double precision multiplication with signed/unsigned support, fixed point division with algorithmic considerations, and 16x16 double precision addition, subtraction, BCD-to-binary and binary-to-BCD conversions, BCD arithmetic, plus a square root routine. Speed-optimized and code-size-optimized versions are provided, with calling sequences documented in the appendices.",{"@graph":14,"@context":72},[15,34,55],{"@type":16,"itemListElement":17},"BreadcrumbList",[18,23,27,31],{"item":19,"name":20,"@type":21,"position":22},"https://docshare.wps.com","Home","ListItem",1,{"item":24,"name":25,"@type":21,"position":26},"https://docshare.wps.com/document/","Document",2,{"item":28,"name":29,"@type":21,"position":30},"https://docshare.wps.com/document/technology/","Technology",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/document/an526-pic16c5x-pic16cxxx-math-utility-routines/562618/",4,{"url":32,"name":10,"@type":35,"image":36,"author":41,"headline":10,"publisher":44,"fileFormat":47,"inLanguage":8,"description":12,"dateModified":48,"datePublished":49,"encodingFormat":47,"isAccessibleForFree":50,"interactionStatistic":51},"DigitalDocument",{"url":37,"@type":38,"width":39,"height":40},"https://docshare.wps.com/thumbnails/an526-pic16c5x-pic16cxxx-math-utility-routines/562618.png","ImageObject",300,407,{"name":42,"@type":43},"OmBimo","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-11-12","2026-10-12",true,{"@type":52,"interactionType":53,"userInteractionCount":33},"InteractionCounter",{"@type":54},"ViewAction",{"@type":56,"mainEntity":57},"FAQPage",[58,64,68],{"name":59,"@type":60,"acceptedAnswer":61},"What kinds of math routines does AN526 provide for PIC16C5X/PIC16CXXX devices?","Question",{"text":62,"@type":63},"AN526 provides utility routines for multiplication, fixed-point division, 16x16 addition and subtraction, BCD and binary conversions, BCD arithmetic, and square root. It also notes that all routines can be called as subroutines.","Answer",{"name":65,"@type":60,"acceptedAnswer":66},"How are multiplication routines organized regarding speed versus code size?",{"text":67,"@type":63},"For both 8x8 and 16x16 multiplication, AN526 provides two versions of each routine: one optimized for speed and another optimized for code size, with performance specs shown in the tables.",{"name":69,"@type":60,"acceptedAnswer":70},"How does fixed point division in this note relate to standard restoring and nonrestoring division?",{"text":71,"@type":63},"The division section explains restoring division as shift-and-subtract with quotient bit decisions from the partial remainder sign, and contrasts it with nonrestoring division that can keep a negative partial remainder to improve speed. It also discusses two’s complement division constraints and overflow conditions.","https://schema.org",{"og:url":32,"og:type":74,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":76,"canonical":32},"index,follow",{"doc_id":78,"site_id":7},562618,1791908249,{"code":4,"msg":81,"data":82},"success",[83,87,91,95,100,104,109,114,119,122,126],{"id":22,"doc_module":4,"doc_module_name":25,"category_name":84,"show_sort_weight":85,"slug":86},"Story & Novel",90,"story-novel",{"id":26,"doc_module":4,"doc_module_name":25,"category_name":88,"show_sort_weight":89,"slug":90},"Literature",80,"literature",{"id":33,"doc_module":4,"doc_module_name":25,"category_name":92,"show_sort_weight":93,"slug":94},"Exam",70,"exam",{"id":96,"doc_module":4,"doc_module_name":25,"category_name":97,"show_sort_weight":98,"slug":99},5,"Comic",60,"comic",{"id":101,"doc_module":4,"doc_module_name":25,"category_name":29,"show_sort_weight":102,"slug":103},6,50,"technology",{"id":105,"doc_module":4,"doc_module_name":25,"category_name":106,"show_sort_weight":107,"slug":108},7,"Healthcare",40,"healthcare",{"id":110,"doc_module":4,"doc_module_name":25,"category_name":111,"show_sort_weight":112,"slug":113},8,"Research & Report",30,"research-report",{"id":115,"doc_module":4,"doc_module_name":25,"category_name":116,"show_sort_weight":117,"slug":118},9,"Religion & Spirituality",20,"religion-spirituality",{"id":117,"doc_module":4,"doc_module_name":25,"category_name":120,"show_sort_weight":117,"slug":121},"World Cup","world-cup",{"id":123,"doc_module":4,"doc_module_name":25,"category_name":124,"show_sort_weight":123,"slug":125},10,"Lifestyle","lifestyle",{"id":127,"doc_module":4,"doc_module_name":25,"category_name":128,"show_sort_weight":96,"slug":129},19,"General","general",{"code":4,"msg":81,"data":131},{"doc_id":78,"user_id":132,"nickname":42,"user_avatar":133,"doc_module":4,"category_id":101,"category_name":29,"doc_title":10,"doc_description":12,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":33,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":139,"language":140,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":141,"faqs":142,"seo_title":143,"seo_description":12,"update_tm":144,"read_time":145,"preview_page_count":123,"preview_urls":146},962090893581,"https://ap-avatar.wpscdn.com/davatar_276721f389ce27ea32af1340a28f341c","AN526  \nPIC16C5X / PIC16CXXX Math Utility Routines  \nINTRODUCTION  \nThis application note provides some utility math routines for Microchip’s PIC16C5X and PIC16CXXX series of 8-bit microcontrollers. The following math outlines are provided:  \n• 8x8 unsigned multiply  \n• 16x16 double precision multiply  \n• Fixed Point Division (Table 3)  \n• 16x16 double precision addition  \n• 16x16 double precision subtraction  \n• BCD (Binary Coded Decimal) to binary conversion routines  \n• Binary to BCD conversion routines  \n• BCD addition  \n• BCD subtraction  \n• Square root  \nThese are written in native assembly language and the listing ﬁles are provided. They are also available on a disk (MS-DOS􀃒) . All the routines provided can be called as subroutines. Most of the routines have two different versions: one optimized for speed and the other optimized for code size. The calling sequence of each routine is explained at the beginning of each listing ﬁle.  \nSINGLE PRECISION UNSIGNED MULTIPLICATION (8x8)  \nThis routine computes the product of two 8-bit unsigned numbers and produces a 16-bit result. Two routines are provided: one routine is optimized for speed (by writing a straight line code) and the other routine has been written to reduce the code size (a looped code) . The listing of these routines are given in Appendices A and B. The performance specs for the routines are shown in Table 1.  \nMS-DOS is a registered trademark of Microsoft Corporation.  \nTABLE 1: PERFORMANCE SPECS  \n\n| Spec | Program Memory | Instruction Cycles |\n| --- | --- | --- |\n| Speed Efﬁcient | 35 | 37 |\n| Code Efﬁcient | 16 | 71 |\n\nFIGURE 1: Flowchart for Unsigned  \n8x8 Multiply  \n􀃓 1997 Microchip Technology Inc. DS00526E-page 1  \nAN526  \nDOUBLE PRECISION MULTIPLY  \nThis routine computes the product of two 16-bit numbers and produces a 32-bit result. Both signed and unsigned arithmetic are supported. Two routines are provided: one routine is optimized for speed (by writing a straight line code) the other routine has been written to reduce code size (a looped code) . The listing of these routines are given in Appendices Cand D. The performance specs for routines are shown in Table 2.  \nTABLE 2: PERFORMANCE SPECS  \n\n| Spec | Program Memory | Instruction Cycles |\n| --- | --- | --- |\n| Speed Efﬁcient | 240 | 233 |\n| Code Efﬁcient | 33 | 333 |\n\nThe code in Appendices C and D has been setup for unsigned arithmetic and the performance specs in the table above is for unsigned arithmetic. If signed arithmetic is desired, edit the line with “SIGNED equ FALSE” to “SIGNED equ TRUE” then re-assemble the code.  \nIn case of signed multiply, both operands are assumed to be 16-bit 2’s complement numbers.  \nConditional assembly is supported by MPASM. If you have an older version, please contact the Microchip Technology sales ofﬁce nearest you.  \nDOUBLE PRECISION DIVISION  \nFixed Point Divide Routines  \nFixed point division is fundamentally a conditional shift and subtract operation, resulting in a quotient and a remainder, with standard methods related to simple binary long division by hand calculation. Typically, a processor with n-bit operands uses a ﬁxed accumulator of 2n bits containing the dividend. In standard restoring division, the dividend is left shifted by one bit and the divisor is subtracted from the high half of the accumulator, referred to as the partial remainder. If the result is positive, the divisor was less than or equal to the partial remainder and the corresponding quotient bit in the LSb of the accumulator is set to one. If the result is negative, the divisor was greater than the partial remainder and the dividend is restored by adding back the divisor to the high half of the accumulator and setting the LSb to zero. This process is repeated for each of the n bits in the divisor, resulting in an n-bit quotient in the low half of the accumulator and the n-bit remainder in the high half, and requiring n subtractions and on average n/2 additions [1] . Nonrestoring divis","cbCaih5abrjWN1ha","https://ap.wps.com/l/cbCaih5abrjWN1ha","pdf",668163,95,"English","# Introduction\n# Single Precision Unsigned Multiplication (8x8)\n# Double Precision Multiply\n# Fixed Point Division Routines","[{\"question\":\"What kinds of math routines does AN526 provide for PIC16C5X/PIC16CXXX devices?\",\"answer\":\"AN526 provides utility routines for multiplication, fixed-point division, 16x16 addition and subtraction, BCD and binary conversions, BCD arithmetic, and square root. It also notes that all routines can be called as subroutines.\"},{\"question\":\"How are multiplication routines organized regarding speed versus code size?\",\"answer\":\"For both 8x8 and 16x16 multiplication, AN526 provides two versions of each routine: one optimized for speed and another optimized for code size, with performance specs shown in the tables.\"},{\"question\":\"How does fixed point division in this note relate to standard restoring and nonrestoring division?\",\"answer\":\"The division section explains restoring division as shift-and-subtract with quotient bit decisions from the partial remainder sign, and contrasts it with nonrestoring division that can keep a negative partial remainder to improve speed. It also discusses two’s complement division constraints and overflow conditions.\"}]","AN526 - PIC16C5X / PIC16CXXX Math Utility Routines | PDF",1791809101,239,[147,151,155,159,163,167,171,175,179,183],{"page_no":22,"url":148,"width":149,"height":150},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-17/b1ee092d8f6409159e633682e1916164.webp",983,1272,{"page_no":26,"url":152,"width":153,"height":154},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-17/728e4e9a5fff584fbbbd1ee40a4c8fe2.webp",982,1270,{"page_no":30,"url":156,"width":157,"height":158},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-17/98d3536170af4ad35880cf3c0513f30a.webp",981,1269,{"page_no":33,"url":160,"width":161,"height":162},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-17/4b975b661f3a7cacbedef969d8e61e7f.webp",980,1268,{"page_no":96,"url":164,"width":165,"height":166},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-17/15114450dd722d30cc36213149ad551b.webp",979,1267,{"page_no":101,"url":168,"width":169,"height":170},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-17/00fc4628255f7f6f82f9bf8e489362d3.webp",978,1265,{"page_no":105,"url":172,"width":173,"height":174},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-17/ee8665467296d99422348986681ffd91.webp",977,1264,{"page_no":110,"url":176,"width":177,"height":178},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-17/e1350f199ad0105773e90ad517b27ef9.webp",976,1263,{"page_no":115,"url":180,"width":181,"height":182},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-17/3b72f794bc1aabb79b6f6b258a583e8a.webp",975,1261,{"page_no":123,"url":184,"width":185,"height":186},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-17/dcddfe60d2930444d090349de8069390.webp",974,1260,{"list":188,"token":11},[189,195,201,207,214,220,226,232,238,245],{"doc_id":190,"doc_title":191,"file_type":137,"home_preview_img_url":192,"slug":193,"view_count":115,"category_name":29,"create_tm":194},562619,"AN556 - Implementing a Table Read - Application note","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229947886867/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796212319&Signature=Gb1L6GQBeq%2FzmZ8ZmB30QqLX0NQ%3D","an556-implementing-a-table-read-application-note",1791809106,{"doc_id":196,"doc_title":197,"file_type":137,"home_preview_img_url":198,"slug":199,"view_count":33,"category_name":29,"create_tm":200},692139,"Corporate Focus Product Selector Guide - First Half 2011","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230002904637/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796212319&Signature=9zEpM45rX%2B%2BvaQSu3jNIf9uniSA%3D","corporate-focus-product-selector-guide-first-half-2011",1794179603,{"doc_id":202,"doc_title":203,"file_type":137,"home_preview_img_url":204,"slug":205,"view_count":101,"category_name":29,"create_tm":206},561961,"μPD8039HL, μPD8049H - and μPD8749H - High-Speed, 8-Bit, Single-Chip HMOS Microcomputers","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229947665078/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796212319&Signature=WhV%2FUChLBXY5UNSW0ZcwgU16w4I%3D","pd8039hl-pd8049h-and-pd8749h-high-speed-8-bit-single-chip-hmos-microcomputers",1791807373,{"doc_id":208,"doc_title":209,"file_type":137,"home_preview_img_url":210,"slug":211,"view_count":212,"category_name":29,"create_tm":213},344717,"Basic4Android Core","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229910851870/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796212319&Signature=iunmZbZd6NjzyHJQYcGjJSg1uxY%3D","basic4android-core",14,1790055043,{"doc_id":215,"doc_title":216,"file_type":137,"home_preview_img_url":217,"slug":218,"view_count":96,"category_name":29,"create_tm":219},720620,"DFRobot Gravity - 0-10V 15Bit 2-Channel ADC Module (SKU:DFR1184) - Features, Specifications, and Serial/I2C/UART Guide","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230023676127/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796212319&Signature=FwV0r5Ht8lNx8MACyfL9lwamiMA%3D","dfrobot-gravity-0-10v-15bit-2-channel-adc-module-skudfr1184-features-specifications-and-seriali2cuart-guide",1795038474,{"doc_id":221,"doc_title":222,"file_type":137,"home_preview_img_url":223,"slug":224,"view_count":30,"category_name":29,"create_tm":225},690234,"AURIX™ 32-bit microcontrollers for automotive and industrial applications - Issue 2020","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230002599411/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796212319&Signature=zzIvupVCTjVrNQ54%2FkolQEa%2BE%2FY%3D","aurix-32-bit-microcontrollers-for-automotive-and-industrial-applications-issue-2020",1794158958,{"doc_id":227,"doc_title":228,"file_type":137,"home_preview_img_url":229,"slug":230,"view_count":110,"category_name":29,"create_tm":231},559656,"PIC16F631/677/685/687/689/690 Data Sheet - 20-Pin Flash-Based, 8-Bit CMOS Microcontrollers with nanoWatt Technology","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229947583929/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796212319&Signature=dEgI3XgVyGnM4J%2BAjEVmrgPAYoo%3D","pic16f631677685687689690-data-sheet-20-pin-flash-based-8-bit-cmos-microcontrollers-with-nanowatt-technology",1791800867,{"doc_id":233,"doc_title":234,"file_type":137,"home_preview_img_url":235,"slug":236,"view_count":115,"category_name":29,"create_tm":237},561720,"PIC12F635/PIC16F636/639 Data Sheet - 8/14-Pin, Flash-Based 8-Bit CMOS Microcontrollers with nanoWatt Technology","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229947771678/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796212319&Signature=%2BjfQcHuNukDx879Cdj56nTH07ik%3D","pic12f635pic16f636639-data-sheet-814-pin-flash-based-8-bit-cmos-microcontrollers-with-nanowatt-technology",1791806736,{"doc_id":239,"doc_title":240,"file_type":137,"home_preview_img_url":241,"slug":242,"view_count":243,"category_name":29,"create_tm":244},562624,"PIC16F630/676 Data Sheet - 14-Pin, Flash-Based 8-Bit CMOS Microcontrollers","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229947820309/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796212319&Signature=tyfG8wGmRAbmusmRol9HY1%2FtHKI%3D","pic16f630676-data-sheet-14-pin-flash-based-8-bit-cmos-microcontrollers",11,1791809122,{"doc_id":246,"doc_title":247,"file_type":137,"home_preview_img_url":248,"slug":249,"view_count":22,"category_name":29,"create_tm":250},759761,"8086 Microprocessor - Unit-8","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230044482789/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796212319&Signature=jCfUzAKAUHwc7h0WR%2B6hIoVvqBs%3D","8086-microprocessor-unit-8",1795894372]