Studio 4 Simulator math ( solved )

1 post / 0 new
Author
Message

I have Studio 4.18 and I'm trying to simulate Atmel appNote200 ( 16 x 16 mult unsigned ). The stack pointer value shows up in reg. view, but after that as i step thru code no regs. change values ( it's not even loading values !!!???? )

WTF^10 !!!!!

```.include "tn2313def.inc"

;***** Subroutine Register Variables

.def	mc16uL	=r16		;multiplicand low byte
.def	mc16uH	=r17		;multiplicand high byte
.def	mp16uL	=r18		;multiplier low byte
.def	mp16uH	=r19		;multiplier high byte
.def	m16u0	=r18		;result byte 0 (LSB)
.def	m16u1	=r19		;result byte 1
.def	m16u2	=r20		;result byte 2
.def	m16u3	=r21		;result byte 3 (MSB)
.def	mcnt16u	=r22		;loop counter

.org   0x0000

rjmp   reset
reti
reti
reti
reti  ;rjmp   Fifty_mS_ISR_OC1A ;reti
reti
reti
reti
reti
reti
reti
reti
reti
reti  ;rjmp   OC0A_ISR   ;reti
reti
reti
reti
reti
reti
reti
reti

.org   0x0030

reset:

ldi r16, low(RAMEND)
out SPL, r16

ldi   mc16uL, low( 65536 )
ldi   mc16uH, high( 65536 )
ldi   mp16uL, low( 65536 )
ldi   mp16uH, high( 65536 )
rcall  mpy16u

loop:
rjmp   loop

;* "mpy16u" - 16x16 Bit Unsigned Multiplication
;*
;* This subroutine multiplies the two 16-bit register variables
;* mp16uH:mp16uL and mc16uH:mc16uL.
;* The result is placed in m16u3:m16u2:m16u1:m16u0.
;*
;* Number of words	:14 + return
;* Number of cycles	:153 + return
;* Low registers used	:None
;* High registers used  :7 (mp16uL,mp16uH,mc16uL/m16u0,mc16uH/m16u1,m16u2,
;*                          m16u3,mcnt16u)
;*
;***************************************************************************

;***** Code

mpy16u:	clr	m16u3		;clear 2 highest bytes of result
clr	m16u2
ldi	mcnt16u,16	;init loop counter
lsr	mp16uH
ror	mp16uL

m16u_1:	brcc	noad8		;if bit 0 of multiplier set
noad8:	ror	m16u3		;shift right result byte 3
ror	m16u2		;rotate right result byte 2
ror	m16u1		;rotate result byte 1 and multiplier High
ror	m16u0		;rotate result byte 0 and multiplier Low
dec	mcnt16u		;decrement loop counter
brne	m16u_1		;if not done, loop more
ret```

edit:
65,536 IS 0 for a 16 bit var. THAT's WTF^10. Sorry !

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1