News:

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

Main Menu

Code can be compiled but it crashes on run

Started by cioltealin, May 20, 2018, 08:45:58 PM

Previous topic - Next topic

dedndave

i don't know what assembler you are using - it doesn't seem to be MASM
if you use MASM and a 16-bit linker, this should work

        .MODEL  Small
        .STACK  4096
        .DOSSEG
        .386
        OPTION  CaseMap:None

;####################################################################################

        .DATA

s$Msg   db 'Hello World !',0Dh,0Ah,24h

;************************************************************************************

        .DATA?

;####################################################################################

        .CODE

;************************************************************************************

_main   PROC    FAR

        mov     dx,@data
        mov     ds,dx

        mov     dx,offset s$Msg
        mov     ah,9
        int     21h

        mov     ax,4C00h
        int     21h

_main   ENDP

;####################################################################################

        END     _main


notice that the first instructions set the DS register to the data segment, something your program is missing


jj2007

Quote from: felipe on May 21, 2018, 03:59:18 AM
:greenclp:

:lol:

You have a problem in the other thread, perhaps you should concentrate on your projects.

cioltealin

Thanks a lot !
The users of this community are very friendly . Tbh when I asked the question I didn't expected a single answer in 12 hours.

:t

felipe

Quote from: jj2007 on May 21, 2018, 04:05:43 AM
Quote from: felipe on May 21, 2018, 03:59:18 AM
:greenclp:

:lol:

You have a problem in the other thread, perhaps you should concentrate on your projects.

What's exactly my problem sir? What are my projects? I don't have any boss here sorry...  :eusa_naughty:

mineiro

cioltealin, if you look for example posted by dedndave you will notice a thing that some persons forgot.
When we declare a string, we use as suffix 0dh,0ah,24h. This means carriage return(0dh), line feed(0ah) and end of string(24h). Windows and linux uses the same EOS (default is 00h) while ms-dos not, it uses a dollar sign ($ == 24h). By default linux use only LF while windows and ms-dos uses CRLF as new line sign.
I'd rather be this ambulant metamorphosis than to have that old opinion about everything

felipe

cioltealin you can try to run your programs with dosbox, maybe will work... :idea:

Don't know if anybody think i was laughing from you, but i was not. I was laughing on the comment from aw27 about your teacher...Just to clarify a little bit and trying to avoid misunderstandings... :redface: