gnupic: gpasm numbers


Previous by date: 25 Aug 2004 00:32:04 +0100 gpasm numbers, Craig Franklin
Next by date: 25 Aug 2004 00:32:04 +0100 Re: gpasm numbers, Craig Franklin
Previous in thread: 25 Aug 2004 00:32:04 +0100 gpasm numbers, Craig Franklin
Next in thread: 25 Aug 2004 00:32:04 +0100 Re: gpasm numbers, Craig Franklin

Subject: gpasm numbers
From: pico ####@####.####
Date: 25 Aug 2004 00:32:04 +0100
Message-Id: <412BCFDA.5060306@sourceforge.net>

Additional note:
The most misleading thing about numbers in gpasm is that the default 
radix is HEX and not DEC as in many other assembler.
Microchip application notes requires, especially the math related, that
the default radix is decimal.The same apply for third part code.
The gpasm manual don't explain that the default radix is hex in the 
section related to numbers. Instead it's explained in the section 
regarding command line arguments. As explained in the previous mail, some of
the numeric representations explained in the gpasm manual don't work.


One simple example:

#define KH	*1000
#defime MH	KH KH
; set processor speed
#define CLK	4000000
; or
#define CLK	4MH
; set timer0 prescaler
#define TM0PRE	16 ; set prescaler to 16 - minimum is 4


delay_ms:
; ARGS: 0-256  = W
; VARS: _tmp
; RET : W = 0
; NOTE: destroys the W register and set Z. C is untouched.
;       timer0 must be started before enter this pice of code.
;       otherwise this is a non returning call.
; DESC: delays 0-256 milliseconds
; HOOK: idle_1ms
#if CLK / TM0PRE / D'1000' > 0xff
   #error "Prescaler in timer0 out of range"
#endif
   movwf	_tmp
   skipnz
   retlw 0
   movlw	( CLK / 4 -4 ) / D'1000' / TM0PRE
   movwf	tmr0
   call  idle_1ms	; idle task called every ms in a time loop
   movf  tmr0
   skipz
   goto $-2
   goto delay_ms+1

The result is a 3 or 4 time longer delay.

	


Previous by date: 25 Aug 2004 00:32:04 +0100 gpasm numbers, Craig Franklin
Next by date: 25 Aug 2004 00:32:04 +0100 Re: gpasm numbers, Craig Franklin
Previous in thread: 25 Aug 2004 00:32:04 +0100 gpasm numbers, Craig Franklin
Next in thread: 25 Aug 2004 00:32:04 +0100 Re: gpasm numbers, Craig Franklin


Powered by ezmlm-browse 0.20.