The MASM Forum

General => The Campus => Topic started by: suleman on January 21, 2013, 07:15:53 PM

Title: problem in calling interept
Post by: suleman on January 21, 2013, 07:15:53 PM
hi,
i m new in assembly language. i perform simple tasks but when i call some interrupts then system halts and show "stop working dialog box and program close.

.code                       ; Tell MASM where the code starts
start:
    call main
    exit

main proc
    LOCAL x: DWORD
    mov dl, 2
    mov ah, 2
    int 21h
    mov x, input("dsfasd")
main endp

program have no syntax error and built successfully.
this is working on win7 ultimate
Title: Re: problem in calling interept
Post by: hutch-- on January 21, 2013, 07:51:39 PM
Interrupts are not directly supported in protected  mode in Win32 or Win64. You are trying to build DOS real mode code. What you need to use are Windows API function calls.
Title: Re: problem in calling interept
Post by: suleman on January 21, 2013, 07:58:08 PM
but i want to learn how interrupts work. what should i do
Title: Re: problem in calling interept
Post by: japheth on January 21, 2013, 08:35:35 PM
Quote from: suleman on January 21, 2013, 07:58:08 PM
but i want to learn how interrupts work. what should i do

1. Find out what OS you have. If it is 64-bit, you'll have to install an emulation platform for 16-bit ( DOSBox is the simplest bet). If your OS is 32-bit, you may probably use the Windows built-in NTVDM to run 16-bit code.

2. Forget the include files contained in Masm32 - they're supposed for Win32 only; don't use "exit" or "input" macros.

3. re-post your program in the DOS 16-bit sub-forum.
Title: Re: problem in calling interept
Post by: dedndave on January 22, 2013, 03:00:59 AM
mov dl,2
also, ASCII 2 is a heart char or something - an old "control character"
if you want to see the number 2 on the screen, use 32h, the ASCII "2" char

this is a 16-bit program - use a 16-bit linker to build it
        .MODEL  Small
        .386
        .STACK  1024
        OPTION  CaseMap:None

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

;        .DATA

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

;        .DATA?

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

        .CODE

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

_main   PROC    FAR

;----------------------------------

;DS = DGROUP (not required for this program)

;        mov     ax,@data
;        mov     ds,ax

;----------------------------------

        mov     dl,32h
        mov     ah,2
        int     21h

;----------------------------------

;terminate program

        mov     ax,4C00h
        int     21h

_main   ENDP

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

        END     _main