News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

qword to unicode?

Started by HSE, April 27, 2022, 01:07:01 AM

Previous topic - Next topic

HSE

Hi All!

Somebody have a 64 bit procedure to convert signed qword integers to unicode string?

Thanks in advance, HSE.
Equations in Assembly: SmplMath

hutch--

Hector,

What about one of the MSVC functions ?

HSE

Hi Hutch!

Quote from: hutch-- on April 27, 2022, 01:10:26 AM
What about one of the MSVC functions ?

No, because I want that for programs running directly from UEFI.

It's not a critical problem because I can load integer to FPU, and float to unicode work well, but I think a more direct solution could be better.
Equations in Assembly: SmplMath

Biterider

#3
Hi HSE
What format? Decimal, Hex, Bin?


Biterider

HSE

Equations in Assembly: SmplMath

jj2007

include \Masm32\MasmBasic\Res\JBasic.inc ; ## builds in 32- or 64-bit mode with UAsm, ML, AsmC ##
q2aBuffer db 80 dup(?)
.code
q2a:
push rsi
push rdi
  mov rsi, offset q2aBuffer+32
  lea rdi, [rsi-32]
  FBSTP REAL10 ptr [rsi]
  mov ecx, REAL10
@@: movzx edx, byte ptr [rsi+rcx]
test edx, edx
je NoNumber
mov al, dl
sar al, 4
and al, 15
add al, "0"
stosw
mov al, dl
and al, 15
add al, "0"
stosw
NoNumber:
dec ecx
jns @B
  pop rdi
  pop rsi
  ret
MyQ QWORD 123456789012345678
Init ; OPT_64 1 ; put 0 for 32 bit, 1 for 64 bit assembly
  PrintLine Chr$("This program was assembled with ", @AsmUsed$(1), " in ", jbit$, "-bit format.")
  fild MyQ
  call q2a
  jinvoke printf, Chr$("Result=%ls"), offset q2aBuffer
EndOfCode


Output:
This program was assembled with ml64 in 64-bit format.
Result=123456789012345678

HSE

Hi JJ!

Very strange:
\Masm32\MasmBasic\Res\JBasic.inc(554) : fatal error A1000:cannot open file : \Masm32\MasmBasic☺
That is from command line because RichMasm have some path problem.

Using procedure:  numero  qword 15
result:q2aBuffer = 1F5F [q2u.asm, 226]
Equations in Assembly: SmplMath

jj2007

Which assembler?
Does \Masm32\MasmBasic\Res\JBasic.inc exist?
Can you post the code that produces garbage for numero 15?
Here everything works fine, and I see no reason why it shouldn't work :rolleyes:

HSE

Quote from: jj2007 on April 27, 2022, 07:19:53 AM
Which assembler?
*** Start D:\masm32\MasmBasic\Res\bldallRM.bat ***
*** 64-bit assembly ***

*** Assemble, link and run q2a ***

*** Assemble using \masm32\bin64\ml64  ***
El sistema no puede encontrar la ruta especificada.
*** Assembly error ***


Quote from: jj2007 on April 27, 2022, 07:19:53 AM
Does \Masm32\MasmBasic\Res\JBasic.inc exist?
The error is in JBasic.inc

Quote from: jj2007 on April 27, 2022, 07:19:53 AM
Can you post the code that produces garbage for numero 15?
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

% include @Environ(OBJASM_PATH)\Code\Macros\Model.inc   ;Include & initialize standard modules
SysSetup OOP, WIDE_STRING, NUI64, DEBUG(CON)            ;Load OOP files and basic OS support

    .data

        ConInput    CHR 10 DUP(0)                       ;Get some space for the console input buffer
        dBytesRead  DWORD       0

        numero      qword     15
        q2aBuffer   db 80 dup(?)
       
    .code

q2a:
    push rsi
    push rdi
    mov rsi, offset q2aBuffer+32
    lea rdi, [rsi-32]
    FBSTP REAL10 ptr [rsi]
    mov ecx, REAL10
@@: movzx edx, byte ptr [rsi+rcx]
test edx, edx
je NoNumber
mov al, dl
sar al, 4
and al, 15
add al, "0"
stosw
mov al, dl
and al, 15
add al, "0"
stosw
NoNumber:
dec ecx
jns @B
  pop rdi
  pop rsi
  ret

start proc

    SysInit
    DbgClearAll                                           

    fild numero
    call q2a

    DbgStrA q2aBuffer

    DbgText "Press \[ENTER\] to continue..."
    invoke CreateFile, $OfsCStr("CONIN$"), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0
    invoke ReadFile, xax, addr ConInput, sizeof(ConInput), addr dBytesRead, NULL

    SysDone
    invoke ExitProcess,0

    ret

start endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

end


Equations in Assembly: SmplMath

jj2007

Quote from: HSE on April 27, 2022, 07:42:24 AM
*** Start D:\masm32\MasmBasic\Res\bldallRM.bat ***
*** 64-bit assembly ***

*** Assemble, link and run q2a ***

*** Assemble using \masm32\bin64\ml64  ***
El sistema no puede encontrar la ruta especificada.
*** Assembly error ***
So you are using an OPT_Assembler \masm32\bin64\ml64 in your source... sorry, that won't work. RichMasm assumes that all your tools reside in \masm32\bin\*. Copy ml64.exe there, and use OPT_Assembler ml (or let RichMasm use the default \masm32\bin\UAsm64.exe) :cool:

Quote
Quote from: jj2007 on April 27, 2022, 07:19:53 AM
Does \Masm32\MasmBasic\Res\JBasic.inc exist?
The error is in JBasic.inc

Right - sorry. So what is at the error line 554 in your JBasic.inc, causing fatal error A1000:cannot open file : \Masm32\MasmBasic☺?

  Open "I", #0, repargA(fname)
  xchg rsi, rax
  jinvoke GetFileSize, rsi, addr bytesWritten
  inc rax
  xchg rax, rdi           <<<<<<<<<<<<<<<<<<<<<<<<< line 554 <<<<<<<<<<<<<<<<<<
  jinvoke HeapAlloc, MbProHeap, HEAP_GENERATE_EXCEPTIONS, rdi
  mov MbFileReadPtr, rax
  jinvoke ReadFile, rsi, rax, rdi, addr bytesWritten, 0
  mov rdx, MbFileReadPtr


Quote
Quote from: jj2007 on April 27, 2022, 07:19:53 AM
Can you post the code that produces garbage for numero 15?
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
...

I can't see where it fails, can you post the exe, please?

HSE

Quote from: jj2007 on April 27, 2022, 09:21:43 AM
... sorry, that won't work. RichMasm assumes that all your tools reside in \masm32\bin\*

All 64 bits tools are in bin64 folder because Masm64 SDK standard, but not problem. We can wait until you make the corrections  :biggrin: :biggrin: :biggrin:

Quote from: jj2007 on April 27, 2022, 09:21:43 AM
Right - sorry. So what is at the error line 554 in your JBasic.inc, causing fatal error A1000:cannot open file : \Masm32\MasmBasic☺?

:biggrin: I have DualMacs.inc but I lost DualWin.inc somewhere. And I never see some pt.inc. For sure I miss some update.

Quote from: jj2007 on April 27, 2022, 09:21:43 AM
I can't see where it fails, can you post the exe, please?
Adjunted.
Equations in Assembly: SmplMath

jj2007

Quote from: HSE on April 27, 2022, 09:50:16 AM
Quote from: jj2007 on April 27, 2022, 09:21:43 AM
I can't see where it fails, can you post the exe, please?
Adjunted.
Quote@@:   movzx ecx, byte ptr [rsi+rdx]
   jecxz NoNumber
   mov eax, ecx
   sar al, 4
   and al, 15
   add al, "0"
   stosw

jj2007

In this forum, beating the CRT by at least a factor 5 is our favourite pastime :biggrin:

This program was assembled with ml64 in 64-bit format.
561 ticks for crt swprintf
Result=123456789012345678
109 ticks for q2a
Result=123456789012345678


This program was assembled with ml in 32-bit format.
687 ticks for crt swprintf
Result=123456789012345678
109 ticks for q2a
Result=123456789012345678

HSE

 :biggrin:numero      qword 5000

q2aBuffer = 50 [q2u.asm, 69]
Equations in Assembly: SmplMath

jj2007

Quote from: HSE on April 27, 2022, 09:54:53 PM
:biggrin:numero      qword 5000

q2aBuffer = 50 [q2u.asm, 69]

Result=5000
:biggrin:

Post your exe...