Problem with SXSim
Valio
Posts: 29
Can somebody plz explain me why SXSim doesnt
correctly initialyze constant's.
I took some code from included samples:
The 0x and 1x row of reg file in simulator have
random garbage data instead initialized "1"
as it seen from code above.
So why study example doesnt work correctly ?
Thanks a lot.
Post Edited (Valio) : 6/4/2009 10:05:23 PM GMT
correctly initialyze constant's.
I took some code from included samples:
ORG $8 temp DS 1 ;temporary workspace ORG $10 acc0 DS 1 ;pwm accumulators acc1 DS 1 acc2 DS 1 acc3 DS 1 acc4 DS 1 acc5 DS 1 acc6 DS 1 acc7 DS 1 duty0 DS 1 ;pwm duty cycles duty1 DS 1 duty2 DS 1 duty3 DS 1 duty4 DS 1 duty5 DS 1 duty6 DS 1
The 0x and 1x row of reg file in simulator have
random garbage data instead initialized "1"
as it seen from code above.
So why study example doesnt work correctly ?
Thanks a lot.
Post Edited (Valio) : 6/4/2009 10:05:23 PM GMT
Comments
You're not initializing those variables, just setting aside space. The "1" means "make this variable take up one byte of memory", not fill this variable with the number 1.
Thanks,
PeterM
I thought vars could be initialized this way, not just reserving space
I took PWM.src example from "SX Assembly" directory of installation.
If it's so, means this code doesnt works, as far vars contain garbage?
Could you take a look plz.
All above means it not possible have pre-initialized variables and
they should be set by itself fro constant. How can I make org directive
refer to program space ?
Thanks,
Alex
Post Edited (Valio) : 6/5/2009 5:31:24 AM GMT
You're a bit too quick to say the program "doesn't work" -- it does; what it doesn't do is initialize the PWM settings. Random values in the duty* variables will be output to the port; the values in the acc* registers will be overwritten every time the interrupt runs so they're it doesn't matter that they're not initialized. If you look at the code you'll find this comment:
This is an invitation to set one or more of the duty* variables before running the loop (at Main). You can use mov for a non-zero value of clr if you want to set a duty cycle register to zero.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Post Edited (Zoot) : 6/6/2009 6:05:56 PM GMT