Download Pelles C here: http://www.pellesc.se
QuoteChatGPT:
Assuming the usual widths on a typical modern desktop/compiler:
unsigned short = 16 bits
unsigned int = 32 bits
stdc_first_leading_one(x) returns the 1-based position of the first 1 when scanning from the most-significant bit (MSB).
stdc_first_leading_zero(x) returns the 1-based position of the first 0 when scanning from the MSB.
For 4, the bit pattern is ...00000100 (only bit 2 set, counting from LSB starting at 0):
First leading one is at position width - 2
First leading zero is at position 1 (because the MSB is 0 for the value 4)
So the output will be:
a1 one:14 a1 zero:1
a2 one:30 a2 zero:1
Explanation:
a1 (16-bit): 16 - 2 = 14
a2 (32-bit): 32 - 2 = 30
If you run this on a platform where unsigned int is not 32-bit (or unsigned short not 16-bit), the one: numbers will change accordingly, but the zero: values will still be 1 for 4 (since the MSB is still 0).
Quote from: rweidner on March 16, 2026, 07:52:25 PMYes, main.c is in a different directory. I have a reason for it. It is just not a great reason. LOL.
Hierarchical and more structured.include movbeCheck.inc
.data
m1 db 'The processor does not support the instruction movbe.',0
m2 db 'The processor supports the instruction movbe.',0
StrTable dq OFFSET m1,OFFSET m2
.code
start:
sub rsp,8+4*8
call main
invoke ExitProcess,0
main PROC PARMAREA=4*SIZEOF QWORD
LOCAL _rax:QWORD
xor rax,rax
mov _rax,rax
mov rax,1
cpuid
bt rcx,22
mov rax,_rax
adc rax,0
mov rdx,OFFSET StrTable
lea rcx,[rdx+8*rax]
invoke printf,QWORD PTR [rcx]
ret
main ENDP
END start
include movbeCheck.inc
.data
m1 db 'The processor does not support the instruction movbe.',0
m2 db 'The processor supports the instruction movbe.',0
StrTable dd OFFSET m1,OFFSET m2
.code
start:
call main
invoke ExitProcess,0
main PROC
xor eax,eax
push eax
mov eax,1
cpuid
bt ecx,22
pop eax
adc eax,0
mov edx,OFFSET StrTable
lea ecx,[edx+4*eax]
invoke printf,DWORD PTR [ecx]
ret
main ENDP
END start
Page created in 0.066 seconds with 15 queries.