News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

How to export the character '$'

Started by Wayne, June 19, 2008, 04:44:02 AM

Previous topic - Next topic

Wayne

I want to export the charcter '$' ,but I can't.
......
string db 'I only have $2!$'
......
mov dx,offset string
mov ah,09h
int 21h
......
The output is  "I only have"
I'm a beginner of assemble.
Thank you. :(

hutch--

Wayne,

I moved the topic to the DOS forum so you would get more answers. A rough guess is you need to use the escape character to display what you want. The escape character in MASM is "!"


string db 'I only have !$2!$'
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

ChrisLeslie

I would roll your own little loop with function 2h instead of function 9h, incrementing dx and terminating at zero. Or use bios int10h function 9h or 0ah for more control over attributes - Make sure though that your string has zero termination. - Chris

jj2007

Why make it simple when you can find a complicated solution, too?

include \masm32\include\masm32rt.inc

.code
MyApp     db "Test app:", 0
MyString   db "I only have ", 36, "2", 0

start:   invoke MessageBox, NULL, addr MyString, addr MyApp, MB_OK
   exit
end start

Neil

Here is another lower level way of doing things, with greater control over positioning & colour:-


string db 'I only have $2!$'



mov ax,b800h      ;Get
push es               ;video
mov es,ax           ;buffer
Sub di,di             ;Display address (top left)
mov cx,16           ;16 characters
mov ah,31           ;Attribute - white on blue
lea si,string          ;point at string

AA:
lodsb                 ;get character
stosw                ;Display character & attribute
dec cx               ;loop counter = loop counter-1
jne AA               ;All done? No, loop again
pop es               ;Yes, restore segment
sub ah,ah          ;Function wait for
int 016              ;& get keypress, required so that you can see output

jj2007

Sorry, I had not realised that you wanted to do it in DOS...

BytePtr

Wayne
Look at this thread at CodeGuru. I helped one member there with same problem
http://www.codeguru.com/forum/showthread.php?t=362535

My post is last and you will find solution there.

Wayne

To:hutch
        It can't solve my problem,the output didn't change,but,thanks all the same.

MichaelW

To output the '$' character you must use a function that does not treat it as a control character. Interrupt 21h function 9, Display String, appeared in first version of MS-DOS (also in the first version of PC-DOS), and was superceded by function 40h, Write File or Device, in version 2.0. Write File or Device is slightly more difficult to use than Display String, but not by much as you can see in BytePtr's example. The handle specified in register BX is one of the standard devices that the system provides open handles to:

Standard input (STDIN) 0
Standard output (STDOUT) 1
Standard error (STDERR) 2
Standard auxiliary (STDAUX) 3
Standard printer (STDPRN) 4

The handle in this case, STDOUT, is effectively a handle to the screen. The other commonly used handle, STDIN, is effectively a handle to the keyboard, normally used with the Read File or Device function.
eschew obfuscation