flat assembler
Message board for the users of flat assembler.
  
|  Index
      > Main > How do faster two Cmp? | 
| Author | 
 | 
| Roman 08 Jan 2024, 09:41 Fasmw 1.73
 How do this in three commands? Code: Cmp Al, "0" Jb @f Cmp Al, "9" Ja @f Do some code @@: | |||
|  08 Jan 2024, 09:41 | 
 | 
| revolution 08 Jan 2024, 10:10 Code: sub al,'0' cmp al,9 ja .out_of_range ; do my thing .out_of_range: | |||
|  08 Jan 2024, 10:10 | 
 | 
| MatQuasar 08 Jan 2024, 10:33 Try:
 Code: mov eax, "1" xor al, 0x30 cmp al, 9 ja quit | |||
|  08 Jan 2024, 10:33 | 
 | 
| Roman 08 Jan 2024, 10:39 Thanks.
 Both variants work fine. I tested. | |||
|  08 Jan 2024, 10:39 | 
 | 
| Picnic 09 Jan 2024, 12:10 How about:
 Code: lea ecx, [eax-'0'] cmp ecx, 10 jc _isdigit | |||
|  09 Jan 2024, 12:10 | 
 | 
| revolution 09 Jan 2024, 14:31 Using the full eax value might be a problem if the top 24 bits are not well defined. But you can change it to this:     Code: lea ecx, [eax-'0'] cmp cl, 10 jc _isdigit | |||
|  09 Jan 2024, 14:31 | 
 | 
| Roman 09 Jan 2024, 14:57 lea ecx, [eax-'0'] not faster than sub AL,"0"
 And sub AL,"0" less bytes lea ecx, [eax-'0'] 3 bytes sub AL,"0" 2 bytes | |||
|  09 Jan 2024, 14:57 | 
 | 
| < Last Thread | Next Thread > | 
| Forum Rules: 
 | 
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.