PDA

View Full Version : Where can i ask re asm programming problem with bcd subtraction



tasmod
- 26th October 2012, 18:29
As per title. I know this is pbp forum but I can't seem to find a suitable forum to ask a question ref assembly language.

I have a 10 digit number stored in 5 byte variables as packed BCD representing a frequency. Say the number is 10000000 in freq4, freq3,freq2,freq1,freq0 whre freq4 is MSB

I want to subtract 9000000 from this 10 digit number. The number would never be less than 9000000. This would be an if offset for a ham radio.

I have tried but the result always screws up the result with unfortunately no way of debugging my efforts.

Thanks for your time.

Mike, K8LH
- 27th October 2012, 09:48
hi tasmod,

start with this routine (http://www.piclist.com/techref/microchip/math/sub/bcdp2.htm) from Scott Datallo where 'x' is the minuend and 'y' is the subtrahend. if C = 0 after the packed bcd subtraction you'll have to borrow from the next most significant packed bcd minuend byte.


unfortunately no way of debugging my efforts

Why can't you use the MPLAB Simulator?

tasmod
- 29th October 2012, 11:43
Thanks Mike,

Unfortunately I've already tried that routine but nothing changes. I've tried looking for my error but I'm now dizzy with it.

As it's a direct step before sending the byte to the LCD i assumed it should at least mess up the display tens digits.

The 'tens' value are in just one BCD packed byte.

I have the code working as a direct rf signal generator using one of the cheap ebay dds boards. Total cost of parts about 10 pounds sterling.

I would like to utilise it as a vfo for a homebrew rig but displaying 0 on the display when the dds is giving out 9mhz. The dds and display would then track up in tandem. This would match the 'i f' then.

It seems a shame to start again with PBP when I have full working asm code. I may just try to get the 'freq word' out to the dds using PBP in a test situation.

Rob G4NQX

Mike, K8LH
- 29th October 2012, 12:53
Hi Rob,

I wouldn't mind taking a closer look. Can you post a sample five byte packed BCD frequency value? Also, are you using a fixed or absolute address for the five byte frequency variable? And, are you subtracting a "constant" 9000000 value or will that be a variable value?

Regards, Mike, K8LH

tasmod
- 2nd November 2012, 09:47
Hi Mike,

Apologies, I've been away a few days.

I've sent you a PM including my email address, so as not to clutter up the forum.

Rob G4NQX