⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme.txt

📁 binary to bcd conversion
💻 TXT
字号:
From fmayr@electronic.tu-graz.ac.at Thu Feb  6 10:24:30 1997
Date: Wed, 05 Feb 1997 15:36:00 +0100
From: Friedrich Mayr <fmayr@electronic.tu-graz.ac.at>
To: 8051code@keil.com
Subject: Fast LONG to BCD conversion

This function was written within the Keil C51 environment
by Dr. Roehrer (Inst. f. Elektronik, TU-Graz) and me
to be called from a C - Program as: "void bin2bcd(void)"

The following global variable (must be located in the 
internal RAM of the processor, "data" or "idata" ) is 
used both to pass the argument (a "long" value) to the 
function, as well as to receive the result (6 digits):

union 
{
   unsigned char buf[6];
   long in;
} idata U_b;  

The purpose of the code is to convert a signed long value
to BCD - code with leading sign if needed. Values exceeding 
the range of 6(-:5) Digits should all be displayed by '-'.
The usage of memory was critical because no external RAM is
present in the system, so only the Accu, B, R1, R2, R3, R4 
are used aside of the digit- (and argument-) buffer "U_b".

The trick applied in the function is to use a 
"small" (nibble by nibble) division and the extensive
use of the '51 - opcodes XCHD and SWAP.
This results in very fast execution.
The function can easily be modified for example 
to time-calculations or extended to the full "long"
range .

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -