First, I was unable to use interrupts using inline ASM and now I can't do so even in pure assembly linked in C!
I have written a function in ASM (just for testing purpose for now) that will print its own string using DOS 21h interrupt. Here's the code first:
Code:
%ifdef OBJ_TYPE
segment .data public align=4 class=data use32
%else
segment .data
%endif

message db "Hello", 0
message2 db "World", "$"


;
; code is put in the _TEXT segment
;
%ifdef OBJ_TYPE
segment text public align=1 class=code use32
%else
segment .text
%endif

global _print

;////////////////////////////////////////////////////////////////////////////////////////
;Function to print a string directly to the video memory
;////////////////////////////////////////////////////////////////////////////////////////

_print:
push ebp ;Save the value of base pointer
mov ebp, esp ;Set ebp to point to the current offset in the stack

pusha

mov edx, message
mov ah, 9h
int 21h

exit:
popa
mov esp, ebp
pop ebp
ret
Now, I convert it to an object file and link to to my C file which is this:
PHP Code:
#include <stdio.h>
void print() __attribute__((cdecl));
int main()
{
printf("CHello");
    print();
    
getch();
    return 
0;

It just crashes the program when I call print(). It actually crashes at the line which calls the DOS 21h interrupt (int 21h) from the assembly code. How would I go about fixing it? I moved to pure assembly because I couldn't get the interrupts to work in inline assembly and now it's not working even in this situation!