The following three subprograms were created by DeepSeek AI at the push of a button! 🤖✨ It's truly fascinating how well AI can generate small subprograms today. While it may struggle with larger programs, these smaller ones look impressive! 😍 You can even specify that you'd like it in InlineASM, and it delivers just that! 💻🔧
#DeepSeekAI #ArtificialIntelligence #Subprograms #InlineASM #TechInnovation 🚀💡🤯👾
'##################################################################################################
'
'##################################################################################################
' -----------------------------------------------------------------------------
' TstBitByte
' Purpose: Tests if a specific bit in a byte is set.
' Parameters:
' - U01: The byte to test.
' - U02: The bit position to check (0-7).
' Returns: 1 if the bit is set, 0 otherwise.
' -----------------------------------------------------------------------------
FUNCTION TstBitByte(BYVAL U01 AS BYTE, BYVAL U02 AS BYTE) AS BYTE
! MOV AL, U01 ' Move the byte (U01) into AL register
! MOV CL, U02 ' Move the bit position (U02) into CL register
! SHR AL, CL ' Shift AL right by CL positions (bit position)
! AND AL, 1 ' Mask all bits except the least significant bit (LSB)
! MOV FUNCTION, AL ' Return the result (0 or 1)
END FUNCTION
'##################################################################################################
'
'##################################################################################################
'
' -----------------------------------------------------------------------------
' TestDword
' Purpose: Tests if a specific bit in a 32-bit DWORD is set.
' Parameters:
' - U01: The DWORD to test.
' - U02: The bit position to check (0-31).
' Returns: 1 if the bit is set, 0 otherwise.
' -----------------------------------------------------------------------------
FUNCTION TstBitDword(BYVAL U01 AS DWORD, BYVAL U02 AS BYTE) AS BYTE
! MOV EAX, U01 ' Move the DWORD (U01) into EAX register
! MOV CL, U02 ' Move the bit position (U02) into CL register
! SHR EAX, CL ' Shift EAX right by CL positions (bit position)
! AND EAX, 1 ' Mask all bits except the least significant bit (LSB)
! MOV FUNCTION, AL ' Return the result (0 or 1)
END FUNCTION
'##################################################################################################
'
'##################################################################################################
' -----------------------------------------------------------------------------
' TstBitQuad
' Purpose: Tests if a specific bit in a 64-bit QUAD is set.
' Parameters:
' - U01: The QUAD to test.
' - U02: The bit position to check (0-63).
' Returns: 1 if the bit is set, 0 otherwise.
' -----------------------------------------------------------------------------
FUNCTION TstBitQuad(BYVAL U01 AS QUAD, BYVAL U02 AS BYTE) AS BYTE
LOCAL lowDword AS DWORD ' Unteres DWORD des QUAD (Bits 0-31)
LOCAL highDword AS DWORD ' Oberes DWORD des QUAD (Bits 32-63)
LOCAL bitPosition AS BYTE
' Teile das QUAD in zwei DWORDs auf
lowDword = LO(DWORD, U01) ' Untere 32 Bits
highDword = HI(DWORD, U01) ' Obere 32 Bits
' Bestimme, ob das Bit im unteren oder oberen DWORD liegt
IF U02 < 32 THEN
' Bit liegt im unteren DWORD
bitPosition = U02
! MOV EAX, lowDword ' Lade das untere DWORD in EAX
ELSE
' Bit liegt im oberen DWORD
bitPosition = U02 - 32
! MOV EAX, highDword ' Lade das obere DWORD in EAX
END IF
! MOV CL, bitPosition ' Lade die Bitposition in CL
! SHR EAX, CL ' Verschiebe EAX um CL Positionen nach rechts
! AND EAX, 1 ' Maskiere alle Bits außer dem LSB
! MOV FUNCTION, AL ' Rückgabe des Ergebnisses (0 oder 1)
END FUNCTION