Oi vey, sar is sign-extending, which is not what we want
This commit is contained in:
		
							parent
							
								
									cd258ccbe4
								
							
						
					
					
						commit
						e4dec4b14c
					
				
					 1 changed files with 3 additions and 3 deletions
				
			
		|  | @ -5,21 +5,21 @@ popcnt: | ||||||
|   mov bx, ax |   mov bx, ax | ||||||
|   and ax, 0x5555 ; 8x 01 |   and ax, 0x5555 ; 8x 01 | ||||||
|   and bx, 0xaaaa ; 8x 10 |   and bx, 0xaaaa ; 8x 10 | ||||||
|   sar bx, 1 |   shr bx, 1 | ||||||
|   add ax, bx |   add ax, bx | ||||||
| 
 | 
 | ||||||
|   mov bx, ax |   mov bx, ax | ||||||
|   and ax, 0x3333 ; 4x 0011 |   and ax, 0x3333 ; 4x 0011 | ||||||
|   and bx, 0xcccc ; 4x 1100 |   and bx, 0xcccc ; 4x 1100 | ||||||
|   mov cl, 2 |   mov cl, 2 | ||||||
|   sar bx, cl |   shr bx, cl | ||||||
|   add ax, bx |   add ax, bx | ||||||
| 
 | 
 | ||||||
|   mov bx, ax |   mov bx, ax | ||||||
|   and ax, 0x0f0f ; 2x 00001111 |   and ax, 0x0f0f ; 2x 00001111 | ||||||
|   and bx, 0xf0f0 ; 2x 11110000 |   and bx, 0xf0f0 ; 2x 11110000 | ||||||
|   mov cl, 4 |   mov cl, 4 | ||||||
|   sar bx, cl |   shr bx, cl | ||||||
|   add ax, bx |   add ax, bx | ||||||
| 
 | 
 | ||||||
|   add al, ah |   add al, ah | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue