In SX Microcontrollers, SX/B Compiler and SX-Key Tool, wchahla wrote: The codes below are from an example found in this forum used for reading DS1302 timekeeping chip and displaying the values on an LCD . I was analysing the ASM equiv of the SX/B code block below in order to fully understand the SHIFTOUT implementation in ASM coding. ----- FROM the assembled output lst file ----------- [color=blue> 179 ] .....[/color] [color=blue> ...... [color=blue> 508 ] 015F 0028 509 0160 0C00 MOV __PARAM2,#(BurstRead >> 8) 0161 0029[/color] [color=blue> ....... ....... What is the end value stored in __PARAM1 as well as __PARAM2 , and why the assembler used this technique instead of directly using the valye of the constant ? What is the purpose of using __PARAM2 variable in the loop knowing that it is only referenced at line 517 with one command RR __PARAM2 only ? --- Source SX/B code ----- GetTimeAndDate: HIGH RTCCS ' start transaction SHIFTOUT Dta, Clk, LSBFIRST, BurstRead ' write address FOR Idx = Secs TO Ctrl ' read time registers SHIFTIN Dta, Clk, LSBPRE, TimeDate(Idx) NEXT LOW RTCCS RETURN ----- End SX/B Code ------------ ---------- Complete Block --------------------------------- 491 =0000014B GetTimeAndDate: ;GetTimeAndDate: 492 493 014B 0545 SETB RTCCS ; HIGH RTCCS ' start transaction 494 014C 0CFA MOV FSR,#__TRISA 014D 0024 495 014E 0440 CLRB IND.2 496 014F 005F MODE $0F 497 0150 0200 MOV !RA,IND 0151 0005 498 0152 0018 BANK $00 499 0153 0545 SETB RTCCS 500 501 0154 0C08 MOV __PARAM3,#8 ; SHIFTOUT Dta, Clk, LSBFIRST, BurstRead ' writeadress 0155 002A 502 0156 0CFA MOV FSR,#__TRISA 0157 0024 503 0158 005F MODE $0F 504 0159 0420 CLRB IND.1 505 015A 0400 CLRB IND.0 506 015B 0200 MOV !RA,IND 015C 0005 507 015D 0018 BANK $00 508 015E 0CBF MOV __PARAM1,#(BurstRead & 255) 015F 0028 509 0160 0C00 MOV __PARAM2,#(BurstRead >> 8) 0161 0029 510 0162 0708 MOVB Dta,__PARAM1.0 0163 0425 0608 0525 511 0166 0C05 MOV __PARAM4,#5 0167 002B 512 0168 02EB DJNZ __PARAM4,@$ 0169 0010 0B68 513 016B 0C01 XOR RA,#%00000001 016C 01A5 514 016D 0C05 MOV __PARAM4,#5 016E 002B 515 016F 02EB DJNZ __PARAM4,@$ 0170 0010 0B6F 516 0172 0C01 XOR RA,#%00000001 0173 01A5 517 0174 0329 RR __PARAM2 518 0175 0328 RR __PARAM1 519 0176 02EA DJNZ __PARAM3,@$-20 0177 0010 0B62 ---- ---- ---- --------------------------------------------------------- Regards ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=258668 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)