I have assembly code and I want to implement it into a C program. I've been using masm to get my assembly code working, and I'm using gcc to compile C code.
I'm using NetBeans in Windows XP.
I want the command prompt to go fullscreen, then draw a line, like this does:
.model small
.stack
.code
main proc far
mov ax,@data
mov DS,ax
mov ah,00h
mov al,12h
int 10h
mov ah,02h
mov dh,14
mov dl,37
int 10h
mov di,65
mov ah,0ch
mov bh,00h
mov al,09h
mov Cx,290
mov dx,200
arriba: int 10h
inc cx
dec di
Jnz arriba
mov di,65
mov ah,08h
int 21h
mov ax,4c00h
int 21h
main endp
end main
That code works if I use masm, but I don't know how to get it working inside my C program... thanks in advance!
You can't mix DOS interrupts with the Windows API. You probably need to use DirectX's full screen mode instead.
Generally mixing assembler with C can be done with GCC by defining functions written in asm in separate assembler file, which if compiled to .o and then linked together with C program, which calls the function that was in object compiled from assembler.
For that you need to know calling convention, how parameters are passed in stack or registers and write header which defines function prototype, which is implemented in assembler.
Some examples how to mix asm with C:
http://www.cs.lmu.edu/~ray/notes/nasmexamples/
Other way would be to use GCC inline assembler syntax: http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html
Note that originally GNU Assembler syntax is quite different than masm and many other x86 assemblers. However looks like this has been fixed in v. 2.10 (http://en.wikipedia.org/wiki/GNU_Assembler)
Also @Neil's answer stands, you cannot do DOS Interrupts from windows program.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.