Keywords: Category:
 
Application of Table Instruction in EzCode4E
TIME: 2009-4-17
 

Application of Table Instruction in EzCode4E

When programming, we often use the table lookup function. With this function, we can realize our required function by looking up a value in table. According to this, Alpha’s EzCode4E has included the table lookup function, which allows us to swiftly lookup a value merely by a table instruction.
 
This article describes how to realize the conversion from 8bit hexadecimal number into the decimal number by using the table lookup method.
 
1.      Table Instruction
Tabletable_name,row_index,col_index,return_reg{,return_type}
table_name:{Table name}
row_index:Y-axis position, namely the row index.
{Constant, register} ;0<=constant/register<=15, register=valid register
col_index: X-axis position, namely the column index.
{Constant, register} ;0<=constant/register<=15, register=valid register
return_reg:The stored return value.
{Register}, register=valid register
return_type: Bit number of return value.
{L,M,H}, L (Default): Return b3~b0; M: Return b7~b4; H: Return b9~b8
 
2.        Establishing Table
(Conversion from Hexadecimal into Decimal Number)
First take the high 4bit (hexadecimal) as the rows and the low 4bit as the columns to establish a table. In this table, the units of decimal digit are stored in bit0~3. The tens (digit) are stored in bit4~7, and the hundreds (digit) are stored in bit8~9. Data is stored in hexadecimal form. See the figure 1.
 
The figure 1 shows the conversion table. By looking up this table, you can find the corresponding values of units, tens, and hundreds digits according to hexadecimal digits.
 

Figure 1
Ex
Hexadecimal number: 0xa6
           r0=0xa, r1=6,Table(tab1,r0,r1,r2,L): Where r2=6, it means the unit digit (decimal).
           r0=0xa, r1=6,Table(tab1,r0,r1,r2,M): Where r2=6, it means the ten digit (decimal).
           r0=0xa, r1=6,Table(tab1,r0,r1,r2,H): Where r2=1, it means the hundred digit (decimal).
The Col_Index and Row_Index in this instruction locate the x-axis and y-axis positions in the table, that is, the 7th column and 11th row. Thus, the lookup value in the table is 0x166, namely the value 166 (decimal).
 
Programming
1.       Create a new file and select an AM4E Body (e.g. AM4EC010)
2.       Fill in the client name and related information in Project Page.
3.       Add voices.
4.       Set input ports as shown in figure 2.

Figure 2
5.       Set In State as shown in figure 3.

Figure 3
6.       Add a table in [Table] section. See the figure 1.
7.       Program (figure 4).
 

Figure 4
 
Description for Program Example
1.       This program accumulates a hexadecimal number by triggering Pra0, and plays this number by voice.
2.       Then looks up table to get a decimal number by triggering Pra1, and plays this number (decimal) by voice.
3.       The playing order is from high bit to low bit.
 
Notes
1.         The value of r0 in playv (r0) should range from 1 to 15 but not be ‘0’.
2.         The number matrix of table cannot exceed 16 x 16.
3.         The range of established table value is 0~0x3ff.
4.         The numbers in X-axis should be the same in table.
 
 
 
ORIGIN: ICE
BACK TO TOP PRINT ADD TO FAVORITE SUBMIT CLOSE
 
>>
 OTHERS
 
·Application Note of Recording Modes (EzCode4...
·Using Midi Background
·How to Use General I/O to Drive LCD?
·The Application of One Key One Note
·Making an LED fan by ALPHA MCU
·Using ALPHA IC in Serial Communication
·Application of the Action Function
·Using AM8EB for I2C Communication
 
>>
 RECOMMENDED
 
·About the Recording Duration of AMSR Series ...
·EzCode4E Solutions
·Application Note of Recording Modes (EzCode4...
·Using Midi Background
·The Control of Silicon Controlled Rectifier
·The Application of One Key One Note
·Portamento Effect in AM4F
 
 

About Us Contact Us Disclaimer


ICP Record : 08035793 Prepared Guangdong ICP