Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/23/02 06:14
Read: times


 
#26146 - what\'s wrong with this code...
hi,
I have a module which is part of an assembly program and i am trying to convert it into C. When i try to translate / link it i am getting errors "operation invalid in this segment" ... why is it so...
can anybody help me out...



EXTRN CODE (FREQTBL)

XSEG AT 5000H
TOTCNT: DS 2 ;STORAGE VAR FOR TOTAL TMR CNT (FREQ TMR0)
FREQ: DS 1 ;VAR TO STORE FREQ 1 = 0.5HZ 64 = 32HZ



CALCULATEFREQ: ;SUB TO CALCULATE VAR TOTCNT FROM FREQ
PUSH ACC
MOV A,DPL
PUSH ACC
MOV A,DPH
PUSH ACC

MOV A,R7
PUSH ACC
MOV A,R6
PUSH ACC

MOV DPTR,#FREQ ; GET DESIRED FREQ
MOVX A,@DPTR
MOV DPTR,#FREQTBL ;POINT TO LOOK UP TABLE
DEC A ;SETUP TO INDEX TABLE (ELEMENT 1 = 0.5 ETC)
CLR C ;CLEAR CARRY
RLC A ;MULTIPLY BY 2
JNC NOCY1
INC DPH ;IF CARRY SET, INC DPH
NOCY1: ADD A,DPL
MOV DPL,A
JNC NOCY2
INC DPH ;IF CARRY, INC DPH
NOCY2: MOVX A,@DPTR ;GET HIGHBYTE FROM TABLE
CALL SWAP_DPTR ;SAVE POINTER TO FREQTBL
MOV DPTR,#TOTCNT ;POINT TO TOTCNT VAR
MOVX @DPTR,A ;STORE HIGHBYTE
INC DPTR ;POINT TO LOWBYTE
CALL SWAP_DPTR ;GET TABLE
INC DPTR ;POINT TO FREQ LOWBYTE
MOVX A,@DPTR ;TRANSFER CONTENTS
CALL SWAP_DPTR
MOVX @DPTR,A

POP ACC
MOV R6,A
POP ACC
MOV R7,A

POP ACC
MOV DPH,A
POP ACC
MOV DPL,A
POP ACC
RET

*******************************************

SWAP_DPTR : ;SWAPS DPTR WITH R6:R7
PUSH ACC

MOV A,DPL
MOV DPL,R7
MOV R7,A
MOV A,DPH
MOV DPH,R6
MOV R6,A

POP ACC
RET

what does the statement Mov DPTR, #FREQTBL means. It does do move FREQTBL to DPTR but what does it signify??? and if i try to include this line in my main program i get an error.. unresolved external symbol FREQTBL. How to get over this problem any suggestions or help would be greatly appreciated


thanks,
roger

List of 5 messages in thread
TopicAuthorDate
what\'s wrong with this code...            01/01/70 00:00      
   What\'s the problem here?            01/01/70 00:00      
RE: what\'s wrong with this code...            01/01/70 00:00      
RE: MOV DPTR, #FREQTBL            01/01/70 00:00      
RE: what\'s wrong with this code...            01/01/70 00:00      

Back to Subject List