News:

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

String program

Started by m987, March 18, 2012, 11:37:32 PM

Previous topic - Next topic

m987

Hi!  I have to write a program that defines symbolic names for several string literals, but my output does not appear on the cmd. I try to include INCLUDE Irvine32.inc, but this error appear multiple .Model directives found, help me please.

TITLE string (string.asm)
; This program defines symbolic names for several string literals

INCLUDE Irvine32.inc

.386
.Model flat, stdcall
string1 textequ <"Dog">
string2 textequ <"cat">

.data
prompt1 BYTE string1
prompt2 BYTE string2

.code
end


MichaelW

#1
In the irvine32.inc that I have the first statement is:

INCLUDE SmallWin.inc

And in SmallWin.inc:

.386
.MODEL flat, stdcall
.STACK 4096

So I think you need to remove the .MODEL directive from your source.

Also, when you define the strings in your data section, you need to add a null terminator, for example:

prompt1 BYTE string1,0

eschew obfuscation

dedndave

well - not all strings need to be terminated with a null
however, you will find it handy for many functions that might be used to display a string

in console mode, we typically use WriteFile to display strings
that function natively requires the length of the string
so - if you use the "sizeof" operator, the null terminator is not required

but - that is clumsy - if you display 100 strings, that is 100 times you have to supply the length
better to use a function that acquires the length of a null-terminated string

MichaelW

At least most of the Irvine32 string-related procedures expect/return null-terminated strings.
eschew obfuscation