Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/20/08 18:46
Read: times


 
#149776 - using - does not give the same result
Responding to: ???'s previous message
C code:
mainoff = -mainoff;


Results in the following asm code:
clr	c
clr	a
subb	a,_mainoff //(0x50)
mov	_mainoff,a //(0xB0)
clr	a
subb	a,(_mainoff + 1) //(0xC3)
mov	(_mainoff + 1),a //(0x3D)


and if mainoff is 50000 (0xC350), its two compliment sould be
-50000 (0x3CB0) but the code preduces -49744 (0x3DB0).

and C code:
mainoff = ~(--mainoff);



Results in the following:
	dec	_mainoff  //(0x50)
	mov	a,#0xff   
	cjne	a,_mainoff,00124$ //Skips
	dec	(_mainoff + 1)  
00124$:
	mov	a,_mainoff //(0x4F)
	cpl	a  
	mov	_mainoff,a //(0xB0)
	mov	a,(_mainoff + 1) //(0xC3)
	cpl	a
	mov	(_mainoff + 1),a //(0x3C)


And my main question was is this asm is legal ?

_asm
	mov    _TL2,_mainoff 
	mov    _TH2,(_mainoff + 1)   
_endasm;


The reason i'm so strict about speed is because its a critical code section under tight timing...





List of 19 messages in thread
TopicAuthorDate
SDCC, copying integer in ASM            01/01/70 00:00      
   Shift-and-mask, or union            01/01/70 00:00      
      I used asm tag and the rr command but....            01/01/70 00:00      
         Your question            01/01/70 00:00      
            Portable unions            01/01/70 00:00      
               Less non-portable?            01/01/70 00:00      
                  Less non-portable            01/01/70 00:00      
                     portable, schmortable            01/01/70 00:00      
                        Disagree!            01/01/70 00:00      
                           how portable?            01/01/70 00:00      
                              emphasis            01/01/70 00:00      
                        Real world portable            01/01/70 00:00      
      using - does not give the same result            01/01/70 00:00      
         try this            01/01/70 00:00      
         You are exceeeding 2 byte signed integer limits            01/01/70 00:00      
            Fighting the tools            01/01/70 00:00      
   Thanks all.            01/01/70 00:00      
      Dangerous            01/01/70 00:00      
         Very important warning!            01/01/70 00:00      

Back to Subject List