The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ookami on February 18, 2011, 11:50:58 AM

Title: Str$ (db) ?
Post by: ookami on February 18, 2011, 11:50:58 AM
Str$ macro works only with dd variables, but not less or more.

What should I do to display with  print db, dw, ax, etc ?

Thanks

Sorry for all my noob's questions...
Title: Re: Str$ (db) ?
Post by: dedndave on February 18, 2011, 01:47:54 PM
there are a few different ways to do it
one way is to use MOVSX, assuming you want to treat them as signed values
;for a byte
        movsx   eax,byte ptr MyByte
        print   str$(eax)
;for a word
        movsx   eax,word ptr MyWord
        print   str$(eax)

MOVSX converts signed bytes or words to dwords by sign-extending them
MOVZX is similar - it converts unsigned bytes or words to dwords by zero-extending them
Title: Re: Str$ (db) ?
Post by: jj2007 on February 18, 2011, 02:17:48 PM
Quote from: ookami on February 18, 2011, 11:50:58 AM
Str$ macro works only with dd variables, but not less or more.

The Masm32 library macro is lowercase str$() and is indeed meant for dwords.
In contrast, the MasmBasic (http://www.masm32.com/board/index.php?topic=12460) Str$ macro swallows almost everything, including byte and word registers, xmm regs, REAL vars, qwords etc.
Title: Re: Str$ (db) ?
Post by: ookami on February 18, 2011, 02:31:09 PM
Thank you. :bg