Author Topic: Code can be compiled but it crashes on run  (Read 1283 times)

dedndave

  • Member
  • *****
  • Posts: 8807
  • Still using Abacus 2.0
    • DednDave
Re: Code can be compiled but it crashes on run
« Reply #15 on: May 21, 2018, 03:15:45 AM »
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

Code: [Select]
        .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

felipe

  • Member
  • *****
  • Posts: 1011
  • Eagles are just great!
Re: Code can be compiled but it crashes on run
« Reply #16 on: May 21, 2018, 03:59:18 AM »
Does he know what he wants?  ::)

 :greenclp:

 :lol:
Felipe.

jj2007

  • Member
  • *****
  • Posts: 8893
  • Assembler is fun ;-)
    • MasmBasic
Re: Code can be compiled but it crashes on run
« Reply #17 on: May 21, 2018, 04:05:43 AM »
:greenclp:

 :lol:

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

cioltealin

  • Regular Member
  • *
  • Posts: 6
Re: Code can be compiled but it crashes on run
« Reply #18 on: May 21, 2018, 04:40:19 AM »
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

  • Member
  • *****
  • Posts: 1011
  • Eagles are just great!
Re: Code can be compiled but it crashes on run
« Reply #19 on: May 21, 2018, 05:38:33 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:
Felipe.

mineiro

  • Member
  • ***
  • Posts: 450
Re: Code can be compiled but it crashes on run
« Reply #20 on: May 21, 2018, 05:48:31 AM »
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

  • Member
  • *****
  • Posts: 1011
  • Eagles are just great!
Re: Code can be compiled but it crashes on run
« Reply #21 on: May 21, 2018, 08:02:02 AM »
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:
Felipe.