Menu

[4cf102]: / bits2.asm  Maximize  Restore  History

Download this file

27 lines (25 with data), 1.0 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
segment .bss
set resq 10
segment .text
global main
main:
push rbp
mov rbp, rsp
bts qword [set], 4 ; set bit 4 of set
bts qword [set], 7 ; set bit 7 of set
bts qword [set], 8 ; set bit 8 of set
bts qword [set+8], 12 ; set bit 76 of set
mov rax, 76 ; test bits 4, 76, 77
mov rbx, rax ; copy bit number to rbx
shr rbx, 6 ; qword number of set to test
mov rcx, rax ; copy bit number to rcx
and rcx, 0x3f ; extract rightmost 6 bits
xor edx, edx ; set rdx to 0
lea r8,[set]
bt [r8+8*rbx], rcx ; test bit
setc dl ; edx equals the tested bit
bts [r8+8*rbx], rcx ; set the bit, insert into set
btr [r8+8*rbx], rcx ; clear the bit, remove
xor rax, rax
leave
ret