electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

Math Function in assembly


Post new topic  Reply to topic    EDAboard.com Forum Index -> Mathematics & Physics -> Math Function in assembly
Author Message
Raju C



Joined: 17 Sep 2009
Posts: 43
Location: Bangalore


Post24 Sep 2009 10:06   

Math Function in assembly


Can any one help to write a assembly program for the below Formulas..
DEC2HEX(MOD(N,1024)+16384,4)
DEC2HEX(INT(N/1024)+17408,4)

here N is 20bits value ..
Back to top
Colbhaidh



Joined: 10 Aug 2004
Posts: 232
Helped: 35
Location: Scotland


Post12 Oct 2009 16:36   

Re: Math Function in assembly


mov ecx,1024 ;divisor
mov eax,N ;your 20 bit N value
xor edx,edx ;clear edx to give EDX:EAX
div ecx ;divide EDX:EAX by ECX, Quotiet in EAX, remainder in EDX
add edx, 16384 ;Result for 1st equation
add eax, 17408 ;Result for 2nd equation


Do you need a DEC2HEX routine or do you assume that exists?
Back to top
Raju C



Joined: 17 Sep 2009
Posts: 43
Location: Bangalore


Post13 Oct 2009 7:44   

Re: Math Function in assembly


ya thank you but as i am using PIC18F25K20 their is no division operation and it is 8 bit so how to implement this?
Back to top
Google
AdSense
Google Adsense




Post13 Oct 2009 7:44   

Ads




Back to top
Colbhaidh



Joined: 10 Aug 2004
Posts: 232
Helped: 35
Location: Scotland


Post13 Oct 2009 8:53   

Re: Math Function in assembly


See multi-byte math routines for PIC here. Use the DIV function with precision 4.

h**p://avtanski.net/projects/math/
Back to top
Raju C



Joined: 17 Sep 2009
Posts: 43
Location: Bangalore


Post13 Oct 2009 12:13   

Re: Math Function in assembly


hey thank you very much i think it helps me .. if any other doubt means i will ask you again ..
Back to top
Raju C



Joined: 17 Sep 2009
Posts: 43
Location: Bangalore


Post15 Oct 2009 4:56   

Re: Math Function in assembly


can you pls tell me how the below code works..

M_DIV: ; Z / X -> Y; remainder -> Z
movlw REG_Y ; passing one value here
call M_CLR ; clearing that resistor
movlw PRECISION*8 ;How it works?
movwf REG_ROT_COUNTER ; passing the multiplied precision value
M_DIV_rot_loop:
btfsc REG_X+PRECISION-1,7; How it works?
goto M_DIV_loop
movlw REG_X
bcf STATUS,C
call M_ROL
decf REG_ROT_COUNTER,f
btfss STATUS,Z
goto M_DIV_rot_loop
bsf STATUS,Z
return
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> Mathematics & Physics -> Math Function in assembly
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
Math and Assembly (1)
PIC Assembly Math HELP! (2)
Math Function for 8051 in C (5)
A math question about average function in time domain (4)
Call C function in assembly (PIC 18) (4)
Intergrate C function in Assembly code!!! (2)
PCW CCS: Return from assembly function ? (4)
How We can call a C function from Assembly (8051) (12)
c++ passing array from function to main function wit pointer (7)
Need a m-file s-function of Gaussian function for UWB puls (2)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS