FreeBasic: ASM Beispiele
Aus Wikibooks
Grundsatz: Diese Programme sind alle mehr oder wenige Unsinn. Der Input und der Print Befehl benötigen viel mehr Zeit als die Rechnung, desweiteren setzt Freebasic eine Rechnung sehr ähnlich um!
dim a as byte dim b as byte dim c as byte input a input b asm mov al,[a] mov bh,[b] mul bh mov [c], AX end asm ? c sleep
Dim A as Integer Dim B as Integer Dim C As LongInt Input A Input B asm mov eax, [A] 'lade A nach eax mov ebx, [B] 'lade B nach ebx mul ebx ' eax * ebx mov [C], eax 'Lo-Teilergebnis mov [C+4], edx 'Hi-Teilergebnis end asm ? C sleep
[Bearbeiten] Kommazahlen
dim A as single dim B as single dim C as single input A input B ASM fld dword ptr [A] fmul dword ptr [B] fstp dword ptr [C] END ASM print C sleep
dim A as single dim B as single dim C as single input A input B ASM fld dword ptr [A] fdiv dword ptr [B] fstp dword ptr [C] END ASM print C sleep
dim A as double dim B as double dim C as double input A input B asm fld qword Ptr [A] fld qword Ptr [B] fdiv st(0), st(1) fst qword ptr[C] end asm print C sleep

