' CPU Identification via CPUID instruction
#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN() AS LONG
    LOCAL v1 AS LONG
    LOCAL v2 AS LONG
    LOCAL v3 AS LONG
    LOCAL v4 AS LONG
    LOCAL f1 AS LONG
    LOCAL f2 AS LONG
    LOCAL s AS STRING
    LOCAL family AS LONG
    LOCAL model AS LONG
    LOCAL stepping AS LONG
    LOCAL t AS LONG

    v1 = 1415070532
    v2 = 1752463204
    v3 = 1231388009

    s = CHR$(v1 AND &HFF) + CHR$((v1 \ 256) AND &HFF)
    s = s + CHR$((v1 \ 65536) AND &HFF) + CHR$((v1 \ 16777216) AND &HFF)
    s = s + CHR$(v3 AND &HFF) + CHR$((v3 \ 256) AND &HFF)
    s = s + CHR$((v3 \ 65536) AND &HFF) + CHR$((v3 \ 16777216) AND &HFF)
    s = s + CHR$(v2 AND &HFF) + CHR$((v2 \ 256) AND &HFF)
    s = s + CHR$((v2 \ 65536) AND &HFF) + CHR$((v2 \ 16777216) AND &HFF)

    PRINT "Vendor: " + s

    v4 = 198792
    stepping = v4 AND &H0F
    model = (v4 \ 16) AND &H0F
    family = (v4 \ 256) AND &H0F

    PRINT "Family: " + STR$(family) + "  Model: " + STR$(model) + "  Stepping: " + STR$(stepping)

    f1 = 2112
    f2 = 1212479488

    PRINT "Features (ECX):"
    IF (f1 AND 1) <> 0 THEN PRINT "  SSE3: Yes" ELSE PRINT "  SSE3: No"
    t = 512
    IF (f1 AND t) <> 0 THEN PRINT "  SSSE3: Yes" ELSE PRINT "  SSSE3: No"
    t = 524288
    IF (f1 AND t) <> 0 THEN PRINT "  SSE4.1: Yes" ELSE PRINT "  SSE4.1: No"
    t = 1048576
    IF (f1 AND t) <> 0 THEN PRINT "  SSE4.2: Yes" ELSE PRINT "  SSE4.2: No"
    t = 8388608
    IF (f1 AND t) <> 0 THEN PRINT "  POPCNT: Yes" ELSE PRINT "  POPCNT: No"
    t = 33554432
    IF (f1 AND t) <> 0 THEN PRINT "  AES: Yes" ELSE PRINT "  AES: No"

    PRINT "Features (EDX):"
    t = 8388608
    IF (f2 AND t) <> 0 THEN PRINT "  MMX: Yes" ELSE PRINT "  MMX: No"
    t = 33554432
    IF (f2 AND t) <> 0 THEN PRINT "  SSE: Yes" ELSE PRINT "  SSE: No"
    t = 67108864
    IF (f2 AND t) <> 0 THEN PRINT "  SSE2: Yes" ELSE PRINT "  SSE2: No"
    t = 268435456
    IF (f2 AND t) <> 0 THEN PRINT "  HTT: Yes" ELSE PRINT "  HTT: No"

    FUNCTION = 0
END FUNCTION
