News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Calling assembly from VB6?

Started by malform, September 10, 2005, 04:20:50 PM

Previous topic - Next topic

malform

In the 80's I learned 6502 assebly for Commodore. I would like to learn [modern] assembly. So far I only have a book from 1988, and a recent version of MASM. I somewhat understand assembly but cannot do anything with the MASM [assembler] yet. Where is a good book or tutorial on MASM?

I have done some Visual Basic 6, a little Win32API. Can assembly be called from VB6, perhaps as a DLL or ActiveX component?

gavin

Hi welcome to the forums Malform.

I can't answer your vb related question, but if you want a good place to learn read the examples and help files included with masm.
And have an old browse of the forums. :U
Then go on over to Iczelion's Win32 Assembly Homepage.

Here.win32assembly.online.fr/
He has some great tutorials .

Mark Jones

Quote from: malform on September 10, 2005, 04:20:50 PM
Can assembly be called from VB6, perhaps as a DLL or ActiveX component?

Hi, MASM32 is fully capable of producing native Win32 .dll's so this should not be a problem. The only issue might be platform-dependent procedure calling convention (C, stdcall, fastcall...) so just be sure to call the MASM32 .dll properly and it will work. :)

That said, you might want to avoid DOS assembler unless you really have a need for it. Win32 assembler is vastly different and most will say it is much easier. :U
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

AeroASM

There are two kinds of DLL that are important here:

Normal DLLs: can't be made with VB, can be made with MASM. The win32 apis reside in normal dlls and you can call them from VB by "Declare"ing them.

ActiveX DLLs: These are normal DLLs with lots of baggage and OOP functionality; not normally very useful for small applications, take up a lot of memory and can only be made with Microsoft C++ or VB compilers.

You write your asm, compile it with MASM into a (normal) dll (e.g. test.dll), then use it in VB just like a normal API.

There is an example of how to make a dll with MASM in \masm32\tutorial\dlltute

tenkey

ActiveX DLLs can be made with MASM. But you'll need to look at the gory details of ActiveX components. Or use one of the MASM OOP packages that some folks have created.
A programming language is low level when its programs require attention to the irrelevant.
Alan Perlis, Epigram #8

sluggy

malform,
i used to do quite a bit of VB<-->asm coding, and wrote quite a few answers to people on this subject on the Win32ASM board. Here are some of the links i dug up:

1, 2, 3, 4, 5, 6, and
another one where i ended up flaming a guy because he was giving incorrect advice about a problem. The subject is not that tricky, these threads cover most things you need to know, the only things they don't really cover is passing variants and how to deal with arrays and arrays of structures.

malform

Thank you all.

I marked this thread as a favorite, I will be using these links. :U

ninjarider

malform,
which commadore system did u learn assembly for

malform

Commodore 64, the 6502 processor. It would work on a plus-4 as well, but the user memory locations were different.

Remember what it looks like?

$1000 LDA $2100,X
$1003 BEQ $1011      '0 ends string
$1005 CMP #$30       'Check for special characters
$1007 BCS  $100B
$1009 LDA #$2E        'Replace with a "."
$100B JSR  $FFD2      'This is like INT21
$100E INX
$100F BNE $1000
$1011 RTS

To call routine, preserving all registers:

$2000 PHS             'Push status register onto stack
$2001 PHA             'Push accumulator onto stack
$2002 TXA             'Transfer X register to accumulator
$2003 PHA
$2004 TYA
$2005 PHA
$2006 LDX #$29      'Offset to Start of string
$2008 JSR$1000
$200B PLA              'Pull status and registers
$200C TAY
$200D PLA
$200E TAX
$200F PLA
$2010 PLS
$2011 RTS