Τρίτη 18 Αυγούστου 2026

Revision 26 Version 15

 New function Assembly():

' using assembly(code$) we get the machince code for running from the first offset
example1=Assembly({
    fild  dword [esp+4]    ; st0 = numerator
    fild  dword [esp+8]    ; st0 = divisor, st1 = numerator
    fdivp                  ; st1 = st1 / st0, pop st0
    mov eax, 0    
    ret 8
})
Declare Division Code example1(0) {long a, long b} as single
Print Division(34, 10)=3.4


' using assembly(code$, true) we get tuple, machinecode in a buffer and the object to get pointers from labels
(example1, Assembler)=Assembly({
    fild  dword [esp+4]    ; st0 = numerator
    fild  dword [esp+8]    ; st0 = divisor, st1 = numerator
    fdivp                  ; st1 = st1 / st0, pop st0
    mov eax, 0    
    ret 8
ASM_TEST_CPUID:
    ;mov eax, [esp+4]
    pushad ; 32 bytes
    xor eax, eax
    mov edi, [esp+36]
    xor eax, eax
    cpuid
    mov [edi+0], ebx
    mov [edi+4], edx
    mov [edi+8], ecx
    popad
    xor eax, eax
    ret 4
}, true)
Declare Division Code example1(0) {long a, long b} as single
Print Division(34, 10)=3.4
Dim Ret(12) as byte
addrPtr=Assembler=>LabelPtr("ASM_TEST_CPUID")
Hex "Call address of ASM_TEST_CPUID = ";addrPtr
Declare CPUID Code addrPtr {long ptrArrayItem}
call CPUID(VarPtr(Ret(0)))
' chr(number) return ansi string
for i=0 to len(Ret())-1
    Print chr(Ret(i));
next
Print
buffer clear retstring as byte*12
call CPUID(retstring(0))
' chr$(string_value) convert ANSI to UTF16LE
Print chr(retstring[0, 12])


Greek Version:

Παράδειγμα=ΚΩΔΙΚΑΣ({
    fild  dword [esp+4]    ; st0 = numerator
    fild  dword [esp+8]    ; st0 = divisor, st1 = numerator
    fdivp                  ; st1 = st1 / st0, pop st0
    mov eax, 0    
    ret 8
})
ΟΡΙΣΕ Διαίρεση ΚΩΔΙΚΑ Παράδειγμα(0) {ΜΑΚΡΥΣ α, ΜΑΚΡΥΣ β} ΩΣ ΑΠΛΟΣ
ΤΥΠΩΣΕ Διαίρεση(34, 10)=3.4


(Παράδειγμα1, Συνθέτης)=ΚΩΔΙΚΑΣ({
    fild  dword [esp+4]    ; st0 = numerator
    fild  dword [esp+8]    ; st0 = divisor, st1 = numerator
    fdivp                  ; st1 = st1 / st0, pop st0
    mov eax, 0    
    ret 8
ASM_TEST_CPUID:
    ;mov eax, [esp+4]
    pushad ; 32 bytes
    xor eax, eax
    mov edi, [esp+36]
    xor eax, eax
    cpuid
    mov [edi+0], ebx
    mov [edi+4], edx
    mov [edi+8], ecx
    popad
    xor eax, eax
    ret 4
}, ΑΛΗΘΕΣ)
ΟΡΙΣΕ Διαίρεση ΚΩΔΙΚΑ Παράδειγμα1(0) {ΜΑΚΡΥΣ Α, ΜΑΚΡΥΣ Β} ΩΣ ΑΠΛΟΣ
ΤΥΠΩΣΕ Διαίρεση(34, 10)=3.4
ΠΙΝΑΚΑΣ Επιστροφή(12) ΩΣ ΨΗΦΙΟ
Διεύθυνση_κλήσης=Συνθέτης=>LabelPtr("ASM_TEST_CPUID")
ΔΕΚΑΕΞ "Διεύθυνση κλήσης για το ASM_TEST_CPUID = ";Διεύθυνση_κλήσης
ΟΡΙΣΕ CPUID ΚΩΔΙΚΑ Διεύθυνση_κλήσης {ΜΑΚΡΥΣ ΔείκτηςΣεΣτοιχείοΠίνακα}
ΚΑΛΕΣΕ CPUID(ΔΙΕΥΘΜ(Επιστροφή(0)))
ΓΙΑ Ι=0 ΕΩΣ ΜΗΚΟΣ(Επιστροφή())-1
    ΤΥΠΩΣΕ ΧΑΡ(Επιστροφή(Ι));
ΕΠΟΜΕΝΟ
ΤΥΠΩΣΕ
ΔΙΑΡΘΡΩΣΗ ΚΕΝΗ επιστροφήΑλφαριθμητικό ΩΣ ΨΗΦΙΟ*12
ΚΑΛΕΣΕ CPUID(επιστροφήΑλφαριθμητικό(0))
ΤΥΠΩΣΕ ΧΑΡ(επιστροφήΑλφαριθμητικό[0, 12])




Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου

You can feel free to write any suggestion, or idea on the subject.