Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

call ,retlw in mikroC

Status
Not open for further replies.

bbgil

Full Member level 2
Joined
Mar 11, 2006
Messages
135
Helped
13
Reputation
26
Reaction score
9
Trophy points
1,298
Activity points
2,321
retlw pcl mikroc

Guys,

in assembly code call and retlw is used to call data in tables. In mikroC, how to do this? i have scout and goggle, but no luck. my plan is to call letters and characters in ascii code. Any help is appreciated. thnx in advance.
 

just define const tables...
Code:
 const char Table[5] = {45, 0x34, 'a', 4 , 0b1010};
then you can use a index to access the table...
Code:
PORTB = Table(3); // PORTB = 4

as far as I remember... you can also set a pointer and a function like
Code:
void puts (const char *meso)
{
  while(*meso != 0)
  {
    Usart_write(*meso); // or somekind of data sink
    meso++;
  }
}


void main()
{
// and later....

puts("Hi, just a constant ascii string to be printed...");
 

    bbgil

    Points: 2
    Helpful Answer Positive Rating
my question goes something like this. the conversion part of this assembly code into C.

INICIO:BSF ADCON0, 2 ;Start Conversion
:
:
:

MOVF ADRESH, 0 ;Moving ADRESH to W
CALL OP_TAB ;Conversion Table Binary-BCD
:
:
:
:
GOTO INICIO ;New Conversion
OP_TAB:ADDWF PCL,1 ;(PC +1) Binary-BCD conversion
RETLW 0x00 ; 0°C
RETLW 0x01 ; 1°C
RETLW 0x02 ; 2°C
RETLW 0x03 ; 3°C
RETLW 0x04 ; 4°C
RETLW 0x05 ; 5°C
RETLW 0x06 ; 6°C
RETLW 0x07 ; 7°C
RETLW 0x08 ; 8°C
RETLW 0x09 ; 9°C
RETLW 0x10 ;10°C
RETLW 0x11 ;11°C
RETLW 0x12 ;12°C
RETLW 0x13 ;13°C
RETLW 0x14 ;14°C
RETLW 0x15 ;15°C
RETLW 0x16 ;16°C
RETLW 0x17 ;17°C
RETLW 0x18 ;18°C
RETLW 0x19 ;19°C
 

Code:
const char OP_TAB[20]={0,0x1,0x2,0x3,0x4,0x5,0x6,0,x7,0x8,0x9,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19};
void main (void)
{
 char temp;
 /*

 */
 while (1)
 {
  temp = adconv(); //your data source
  //
  //
  PORTB = op_TAB[temp];
 }
}

but you can do it better by converting binary data in temp to bcd-packet(up to 99)

Code:
char bin2bcd(unsigned char bindata)
{
  return ((bindata/10)<<4) | (bin data%10);
}
void main (void)
{
 char temp;
 /*

 */
 while (1)
 {
  temp = adconv(); //your data source
  //
  //
  PORTB = bin2bcd(temp);
 }
}
 

    bbgil

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top