=( Why won't you answer this simple question??? 
Author Message
 =( Why won't you answer this simple question???

i have to make up a couple of obj modules to make into a library for use
with my c. how does one write the asm routines (in MASM, please)..? my C
doesn't support 386 opcodes and i  need them! SOMEONE must know..

steelgolem



Tue, 31 Aug 1999 03:00:00 GMT  
 =( Why won't you answer this simple question???

Quote:

> i have to make up a couple of obj modules to make into a library for use
> with my c. how does one write the asm routines (in MASM, please)..? my C
> doesn't support 386 opcodes and i  need them! SOMEONE must know..

> steelgolem

Someone might answer if you specified a few things, like what are those
modules supposed to do, are you talking Win32 or something else. The way
you have phrased your question, it's really very hard to answer.

I'm sure someone will answer once you say what you need.

Tore
--



Tue, 31 Aug 1999 03:00:00 GMT  
 =( Why won't you answer this simple question???

: i have to make up a couple of obj modules to make into a library for use
: with my c. how does one write the asm routines (in MASM, please)..? my C
: doesn't support 386 opcodes and i  need them! SOMEONE must know..
:
: steelgolem

Well, realize that in REAL mode you have to stick to 16-bit segments.
But this is supposed to work:

        .model whatever
        .386
        .code
        your-386-instructions-can-go-here

        iNote that the .386 comes AFTER the model statement.

        David



Wed, 01 Sep 1999 03:00:00 GMT  
 =( Why won't you answer this simple question???

Quote:

>i have to make up a couple of obj modules to make into a library for use
>with my c. how does one write the asm routines (in MASM, please)..? my C
>doesn't support 386 opcodes and i  need them! SOMEONE must know..

>steelgolem

What C-compiler and Linker are you planning on using? What Assembly
compiler are you using? The Tasm books talk about how to create go
about using mixed-languages.

You will need to look into using EXTERN and PUBLIC in your ASM code.
Here is an old sample that I had create some time back. Use at your
own risk. These routines worked fine from QuickC  1.52, TC 2 and from
Tasm 2.0.

;This contains many general-purpose graphic
;routines. This is meant to be compiled into
;an Assembly library for a small memory model.

        .Model  small
        .386
        .Data
Public C init_graph
Public C Close_Graph
Public C put_pixel
Public C Put_Line
Public Put_Rectangle
Public Get_Pixel
Public Video_On
Public Video_Off
Public C Set_Mode

        .Code

OldMode dw      0003h
NewMode dw      0013h
X_Size  dw      0
Y_Size  dw      0

init_graph proc  C vmode:word
        mov     ah,0fh
        int     10h

        xor     ah,ah
        mov     cs:[OldMode],ax

        mov     ax,vmode
        xor     ah,ah
        int     10h
        mov     cs:[NewMode],ax
        ret
init_graph endp

Close_Graph proc far
        mov     ax,cs:[OldMode]
        int     10h
        retf
Close_Graph endp

put_pixel proc  C color:word, x:word, y:word
        push    bx              ;AL=Color, CX=X, DX=Y
        push    cx
        push    dx
        push    es

        mov     ax,color
        mov     cx,x
        mov     dx,y

        mov     bx,0a000h
        mov     es,bx

        add     ch,dl
        shl     dx,6
        add     cx,dx
        mov     bx,cx
        mov     es:[bx],al      ;Store the Color
        pop     es
        pop     dx
        pop     cx
        pop     bx
        ret
put_pixel endp

Put_Line proc   C color:word, x_start:word, y_start:word, x_end:word,
y_end:word

        mov     ax,color
        mov     cx,x_start
        mov     dx,y_start

        push    di      ;AL=Color, CX=X-start, DX=Y-start
        push    si      ;DI=X-end, SI=Y-End

        mov     di,x_end
        mov     si,y_end
P_Loop1:
        pusha
        call    put_pixel
        popa
        cmp     cx,di
        jz      short test_dx
        inc     cx
test_dx:
        cmp     dx,si
        jz      short PL_Finish
        inc     dx
        jmp     P_Loop1
PL_Finish:
        cmp     cx,di
        jnz     P_Loop1

        pop     si
        pop     di
        ret
Put_Line endp

Put_Rectangle proc   C color:word, x:word, y:word, x_end:word,
y_end:word
        ;push    cx      ;AL=Color, CX=X-start, DX=Y-start
        ;push    dx      ;DI=X-end, SI=Y-End
        ;mov     cs:[X],cx
        ;mov     cs:[Y],dx
        mov     cx,x
        mov     dx,y
        mov     di,x_end
        mov     si,y_end
        mov     cs:[X_Size],cx
        mov     cs:[Y_Size],dx

        add     cs:[X_Size],di
        add     cs:[Y_Size],si

Put_Top1:
Put_Top:
        call    put_pixel
        cmp     cx,cs:[X_Size]
        jz      short Put_Left1
        inc     cx
        jmp     Put_Top
Put_Left1:
        mov     cx,x
Put_Left:
        call    put_pixel
        cmp     dx,cs:[Y_Size]
        jz      short Put_Right1
        inc     dx
        jmp     Put_Left
Put_Right1:
        mov     dx,y
        mov     cx,cs:[X_Size]
Put_Right:
        call    put_pixel
        cmp     dx,cs:[Y_Size]
        jz      short Put_Bottom1
        inc     dx
        jmp     Put_Right

Put_Bottom1:
        mov     cx,x
        mov     dx,y
        mov     dx,cs:[Y_Size]
Put_Bottom:
        call    put_pixel
        cmp     cx,cs:[X_Size]
        jz      short Pb1
        inc     cx
        jmp     Put_Bottom

Pb1:
        pop     dx
        pop     cx
        retf
Put_Rectangle endp

Get_Pixel proc  far             ;Calling convention:
        push    bx              ;AL=Color, CX=X, DX=Y
        push    cx
        push    dx
        push    es
        mov     bx,0a000h
        mov     es,bx

        add     ch,dl
        shl     dx,6
        xor     ah,ah
        add     cx,dx
        mov     bx,cx
        mov     al,es:[bx]
        pop     es
        pop     dx
        pop     cx
        pop     bx
        retf
Get_Pixel endp

Video_On Proc    Far
        mov     bl,36h  ;Enable Video
        mov     ax,1200h
        int     10h
        retf
Video_On endp

Video_Off Proc   Far
        mov     bl,36h  ;Disable Video
        mov     ax,1201h
        int     10h
        retf
Video_Off endp

Set_Mode Proc   C vmode:word
        mov     ax,vmode
        xor     ah,ah
        int     10h
        ret
Set_Mode endp

        end



Wed, 08 Sep 1999 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Guess why this simple program won't compile/run with your compi

2. Guess why this simple program won't compile/run with your

3. Guess why this simple program won't compile/run with your compil

4. Guess why this simple program won't compile/run with your compiler

5. Newbie simple question - can't find answer

6. Simple Question seeks simple answer

7. Questions-Questions-Questions-Answers-Answers

8. Thanks:Memo Won't Save Answer

9. Maritz: Why Microsoft won't ship Sun's Java Class Libraries

10. simple question but hard to answer

11. Looking for a smalltalk Guru to answer some simple questions

12. Simple ODBC questions I need answered

 

 
Powered by phpBB® Forum Software