News:

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

Main Menu

newbie 32-bit program, it builds but crashes when run

Started by ggmasm32, January 12, 2016, 08:10:55 PM

Previous topic - Next topic

ggmasm32

Moving up the 32-bit ladder, tried to compile 32-bit console application. I managed to build but it just crashes when run, do you see anything wrong?, appreciate in advance!


.686p

;    include macros32.inc
;    include exp32.inc

; experimental asm file to test out anything in this file.
; past tests can be de-activated using DISABLE_<TESTNAME> software switch in
; exp.inc

.model flat, stdcall            ; windows is always 32-bit flat

option casemap:none

.STACK 100h

.DATA
msg db "Hello World!$"

.CODE

;   M_EXTERNDEF

exp32 PROC
;   mov     ax, @DATA
;   mov     ds, ax

    mov     ah, 02h
    mov     dl, 31h
    int     21h

    mov     ah, 4ch
    int     21h
exp32 ENDP
    END exp32




Make target:



#===32-bit programs===

LINK32FLAGS=/subsystem:CONSOLE
ASM32FLAGS=/c /coff /Fl /Zi /Zd
LINK32=link.exe
ASM32=ml

exp32: $(EXP32).exe stat

$(EXP32).exe: $(EXP32).obj
    $(LINK32) $(LINK32FLAGS) $(EXP32).obj

$(EXP32).obj: $(EXP32).asm inc
    $(ASM) $(ASM32FLAGS) $(EXP32).asm



jj2007

#1
Why don't you study \Masm32\examples\exampl01 instead of assuming (wrongly) that Windows will do you the favour to tolerate your 16-bit coding habits? This forum has a search function here. Try int 21h to see that it works only for 16-bit code. If your computer is a recent model, you can't execute 16-bit code. Swallow that pill, you have to read the * manual.

Edit= Profanity.

Grincheux

It is not a console application but a ms-dos program.

Quote
Microsoft® MASM
Assembly-Language Development System
Version 6.1
For MS-DOS ® and Windows ™ Operating Systems


.MODEL small, pascal
.STACK 200h

.DATA
msg BYTE "This writes to the screen$"
.CODE
.STARTUP
mov dx, offset msg ; DS:DX points to msg
mov ah, 09h ; Request Function 9
int 21h
mov ah,4c00h
int 21h
END


ggmasm32

Quote from: Grincheux on January 12, 2016, 09:02:23 PM
It is not a console application but a ms-dos program.

Quote
Microsoft® MASM
Assembly-Language Development System
Version 6.1
For MS-DOS ® and Windows ™ Operating Systems


.MODEL small, pascal
.STACK 200h

.DATA
msg BYTE "This writes to the screen$"
.CODE
.STARTUP
mov dx, offset msg ; DS:DX points to msg
mov ah, 09h ; Request Function 9
int 21h
mov ah,4c00h
int 21h
END


thanks!

ggmasm32

#4
Quote from: jj2007 on January 12, 2016, 09:00:16 PMWhy don't you study \Masm32\examples\exampl01 instead of assuming (wrongly) that Windows will do you the favour to tolerate your 16-bit coding habits? This forum has a search function here. Try int 21h to see that it works only for 16-bit code. If your computer is a recent model, you can't execute 16-bit code. Swallow that pill, you have to read the manual.

Hey thx for pointing out! Also take it easy too!!

Edit = Profanity in quoted text

Mikl__

or make COM-file
bat-filecls
set filename=name_of_your_asm_file
ml /c /Cp %filename%.asm
link16 /t %filename%.obj,,,,,
del %filename%.obj

asm-file.MODEL tiny
.CODE
org 100h
start:mov dx, offset msg
mov ah,9
int 21h
mov ah,0
int 16h
ret
msg BYTE "This writes to the screen$"
end start