Toddler's Corner > Romper Room

Playing

(1/5) > >>

jj2007:
Playing with copying Unicode directly from RichMasm to the forum (in the current version, the ???? have to be replaced manually).

        Sound "大桥在混乱的水.mp3"   ; Unicode names are allowed

Could be worse :biggrin:

jj2007:
QuadMath example:

include \masm32\MasmBasic\MasmBasic.inc         ; download
  SetGlobals REAL16 oDest, Pi16, numInt:DWORD
  Init quad
  MovVal Pi16, "3.1415926535897932384626433832795028841971"
  ; int 3
  movups oDest, QuadMath(frexpq, Pi16, &numInt)
  nops 8
  PrintLine "QuadMath frexp: mantissa=", Tb$, Quad$(oDest), Str$(", expo=%i", numInt)
  Inkey Str$("expected mantissa (PI/4):\t%Je\n", PI/4)
EndOfCode

Output:

--- Code: ---QuadMath frexp: mantissa=       7.85398163397448309615660845819876e-01, expo=2
expected mantissa (PI/4):       7.853981633974483097e-01
--- End code ---

Source (*.asc - opens with WordPad or RichMasm) & exe attached, plus an exe with an int 3 inserted for easier debugging.

jj2007:
Just for fun, a little test with the disassembled FreeBasic fbc.exe:

include \masm32\MasmBasic\MasmBasic.inc         ; download
  SetGlobals ctEsp, ctPush, ctPop
  Init
  PrintCpu 0
  .if !Exist("DisAsFbc.txt")
        UnzipInit "http://www.webalice.it/jj2006/DisAsFbc.zip"  ; UnzipInit expects a filename or URL, returns a comment (if present); edx has records
       .if Sign?
                Print eax       ; print an error message
       .else
                UnzipFile(0, CurDir$())
                UnzipExit
        .endif
  .endif
  NanoTimer()
  Recall "DisAsFbc.txt", L$()
  Print Str$("%i ms to read the file into an array\n", NanoTimer(ms))
  Print Str$("Now checking %i lines for 'esp':\n", L$(?))
  NanoTimer()
  For_ ct=0 To L$(?)-1
        .if Instr_(L$(ct), "esp")
                inc ctEsp
        .endif
  Next
  Print Str$("%i ms to count 'esp'\n", NanoTimer(ms))
  Inkey Str$("There are %i matches for 'esp'", ctEsp)
EndOfCode


--- Code: ---Intel(R) Core(TM) i5-2450M CPU @ 2.50GHz
14 ms to read the file into an array
Now checking 250281 lines for 'esp':
24 ms to count 'esp'
There are 14399 matches for 'esp'
--- End code ---

Source & exe (30.5k) attached.

jj2007:
Generates a long string of lowercase characters and counts how often esp appears:

include \masm32\MasmBasic\MasmBasic.inc         ; download
  Init
  totalsize=50000000
  mov ecx, totalsize
  Let edi=New$(ecx)
  .Repeat
        add Rand(26), 97        ; range 97... 122
        mov [edi+ecx], al
        dec ecx
  .Until Sign?
  PrintLine Left$(edi, 50)
  NanoTimer()
  Inkey Str$("Counting %i occurrences of 'esp' in the string", Count(edi, "esp")), Str$(" took %2f seconds", NanoTimer(ms)/1000)
EndOfCode

jj2007:
Docs: e.g. wLet, Recall - search inside the page for more.


include \masm32\MasmBasic\MasmBasic.inc
  SetGlobals lines, pos1, w$, break
  Init
  NanoTimer()
  Recall "mshtmlc.biUC", L$()   ; read a Unicode file (5,026,824 bytes)
  Print Str$("reading %i lines", L$(?)), Str$(" took %i ms\n", NanoTimer(ms))
  For_ ct=0 To L$(?)-1
        Let w$=wRec$(L$(ct))    ; translate Utf8$ to true Unicode
       .if wInstr(w$, "end type") && !break
                wMsgBox 0, eax, "Mark this line (no=delete):", MB_YESNOCANCEL
                .if eax==IDYES
                                wLet L$(ct)="** marked ** "+w$
                .elseif eax==IDCANCEL
                                or break, -1
                .else
                                Delete L$(ct)
                .endif
        .else
                wLet L$(ct)=w$
        .endif
  Next
  Open "O", 1, "modified_mshtmlc.biUC"
  Print 1, Chr$(0FFh, 0FEh)
  For_ ct=0 To L$(?)-1
        wPrintLine 1, wStr$("%i\t", ct), L$(ct)
  Next
  Close
  Inkey "bye"
EndOfCode

Navigation

[0] Message Index

[#] Next page

Go to full version