A table lookup program

Publisher:cocolangLatest update time:2015-02-03 Source: laogu Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

When developing the 'Speech Teaching Instrument with Pinyin', the author encountered such a requirement: determine a function value (the code of the pronunciation spelled out by these three) based on three independent variables (the key value of the initial consonant, the key value of the final consonant, and the key value of the four tones), where the values ​​of the independent variables and the function are both known, but there is no clear correspondence between them. In addition, it is required to determine whether the independent variables have corresponding function values. The conventional table lookup method cannot be used. After some research, the author compiled a table lookup program to solve this problem.

1. Table lookup requirements:

Input variables: 1 ) the key value of the initial consonant, 2 ) the key value of the final vowel, 3 ) the key value of the four tones ( varies between 47-50 ).

Output result: the code of the corresponding pronunciation.

Table lookup requirements: Determine whether there is a corresponding value based on the input. If so, output the corresponding code. If not, give a not found mark.

2. Table Lookup Procedure:

;**********************************************************************

; Double spelling processing

; Entrance : 2EH and 2DH store the initials and finals of the spelling respectively , and 2CH stores the four tones of the spelling .

; Exit : If found, return the serial number value of the sound signal in 50H , and set 06H to 1

; If not found , 06H is cleared to ''0''

; R6 is used as a total number of spelling counters

;***********************************************************************

J_XH2:

PUSH PSW

MOV R6,#0

MOV DPTR,#J_X2

J2_LP0:

INC R6

CLR A

MOVC A,@A+DPTR

CJNE A,2EH,J2_NOTEQH; take initial consonants , compare , if not equal, transfer

INC DPTR

MOVC A,@A+DPTR

CJNE A,2DH,J2_NOTEQL; if the initials are equal , the finals are not equal.

MOV A,2CH

SUBB A, #47; minus 47 ( radix , so the key value starts at ''0'' and goes from 0 to 3)

MOV R7,A; R7 is used as a four-tone key value counter

J2_LOOP:

CJNE R7,#0,J2_LOOP1; if the value in R7 is not 0, then go to loop

AJMP J2_DONE

J2_LOOP1:

INC DPTR

DEC R7

AJMP J2_LOOP

J2_DONE:; Get data

INC DPTR

CLR A

MOVC A,@A+DPTR

MOV50H,A; store number

SETB06H

AJMP J2_RET

J2_NOTE:

INC DPTR

J2_NOTEQL:

INC DPTR

INC DPTR

INC DPTR

INC DPTR

CJNE R6,#SPZS,J2_LP0; if not equal to the total number of double spellings , continue the cycle

CLR06H

J2_RIGHT:

POP PSW

RIGHT

J_X2:DB1826100101102103;zi

DB1926104105106107;ci

DB2026108109110111;si.

3. Description

Before using this program, you must know exactly how many data there are in the table and define a constant: SPZS , that is, define it as follows in the program header (assuming there are 100 data in the table):

SPZS EQU100

According to this program, it is not difficult to get the three-spelling table lookup program. The above program has been verified and proved to be running correctly.

Reference address:A table lookup program

Previous article:msp430 software installation cracking process
Next article:MSP430 microcontroller framework program

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号