| Author |
Message |
Raju C
Joined: 17 Sep 2009 Posts: 43 Location: Bangalore
|
24 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
|
12 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
|
13 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

|
13 Oct 2009 7:44 Ads |
|
|
|
|
|
|
| Back to top |
|
 |
Colbhaidh
Joined: 10 Aug 2004 Posts: 232 Helped: 35 Location: Scotland
|
13 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
|
13 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
|
15 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 |
|
 |