Hey Hutch, had a question about the package thus far.

Heh, I dont really want to start a HLL flame war here so be nice folks!

Was curious as to if (for some of us that actually dont mind HLLs) that a new macro type could be introduced. Was thinking along the lines of operators. It would effectively split the line at the operator and you could have two globals to access them (maybe @LEFT and @RIGHT or something) like so:



:= OPERATOR
invoke @RIGHT
mov @LEFT, eax
ENDO


Would allow some really cool stuff. I guess the one above allows syntax like.

hDC := GetDC, hWnd

Just a thought. I always wanted a language where you could define you own ops. C++ overloading is close, but you cant define new ones...
Posted on 2002-06-04 15:16:26 by Graebel
I noticed NaN using something just like this in his code. I don't think its a bad idea either... when I switch working from HLL to asm I forget to put the "mov blah, eax" in there

(And when I switch FROM asm, I forget to put the "retval =" before the call too).

Since it's all the same code, its just a matter of taste IMHO. It's quite readable, just its not my taste.

Hey, if I'm gonna be the weird guy in the office who made the effort and actually writes in assembler, am I gonna make it easier for the HLL wonks to read my code? ;-)
Posted on 2002-06-04 19:24:55 by Ernie
in Forth you can define your own ops and language words that are primitives (have same power as any language word) from.... 1979 .. i guess ;)

maybe C++ will evolve to that in 2050 ? ;)

PS
=========
At the same time (1979) old FIG-Forth had a Virtual Machine made of only 3-4 asm instructions and all other primitives (i gues basic 10) can be implemented in Forth also... someday near our days they re invented Java

Ah and it also has OOP, its a compiler its an interpreter and.. has inline ASM and... etc etc all in about 4K of code

standard 8086 ASM with using OOP Forth source code has only 64 lines of code or 2 pages of text
Posted on 2002-06-04 19:28:37 by BogdanOntanu
I use the following macro...


$Invoke MACRO Func,args:VAR
IFB args
Invoke Func
ELSE
Invoke Func,args
ENDIF
EXITM <eax>
ENDM


This was based on NaN's $METHOD macro which I realized was a plain cool way of doing things.

It's done this way:
;hDC=GetDC(hWnd);
mov hDC,$Invoke(GetDC,hWnd)

As for an 'OPERATOR' macro.... well that depends on whether MS will add such a macro to ml.exe...
I believe hutch has decided to always pack masm v.6.14 with all future releases of the MASM32 package but I'm not sure.

PS


PS
=========
At the same time (1979) old FIG-Forth had a Virtual Machine made of only 3-4 asm instructions and all other primitives (i gues basic 10) can be implemented in Forth also... someday near our days they re invented Java

Ah and it also has OOP, its a compiler its an interpreter and.. has inline ASM and... etc etc all in about 4K of code

standard 8086 ASM with using OOP Forth source code has only 64 lines of code or 2 pages of text


At approx. the same time too (late 70's IIRC) Infocom was converting Zork to the Apple ][... since the original Zork was for a UNIX computer, they had to chop off some of the original Zork, and implement a virtual computer on the Apple ][ which ran a LISP-like language they developed on UNIX specifically for Zork. Imagine that: cramming several hundred kilobytes of programming into a 32Kb computer. Zork's VM's words were 5-bits just to compress the data (so three words fit into 2 bytes).

So basically a virtual computer is rather oldish concept, except that they just didn't call it a virtual machine then. So no one remembers and they think 'the virtual machine concept is new'.
Posted on 2002-06-04 22:06:44 by AmkG
Using a version of NaN's @invoke macro named FUNC, you can do the following,

mov hDC, FUNC(GetDC, hWnd)

Looks like an ASM solution to me. :)

The := is a Pascal operator from memory for assignment.

Regards,

hutch@movsd.com
Posted on 2002-06-05 02:56:50 by hutch--
Maybe someone can do a preprocessor for these kind of things.
I'm thinking, the syntax would be something like:

'*' OPERATOR a,b
mov eax,a
imul eax,b
EXITM <eax>
ENDM

However, that would make coding hard since you don't know which registers are used and such.
Posted on 2002-06-05 03:52:16 by gliptic
But macros ARE the pre-processor for asm.

I just wrote a nice customiseable asm prgram for an embedded app... not a single direct line of code in the whole .asm file. It's all equates and macro invocations.

Now even dumb people can custom compile my code for special features.
Posted on 2002-06-05 21:59:34 by Ernie
Heh, you learn something new every day...

I've been thu the Macro section of the MASM ref a 100 times now, and never came across (nor thought of) defining an OPERATOR..

Pretty cool, i have to say... ;)

I need to piddle a bit with this new idea... but i can see it cleaning up the user interface with COM/OOP very nicely ;)

Thanx for the thought Graebel!
Posted on 2002-06-05 22:16:13 by NaN
The problem I see with defining operators is that MASM filters the characters that you can use so most of the common ones that you can type in from a keyboard give you a syntax error or an invalid character when you try and define them.

This basically leaves you with words only which will not deliver the defined operators required. Its an interesting idea though but probably only possible with a seperate preprocessor similar to the recent work by Randy Hyde.

Regards,

hutch@movsd.com
Posted on 2002-06-06 03:08:46 by hutch--
If you write a sort of "preprocessor", wich parses the ASM file before giving it to MASM, your problem is done. Just parse the ASM source, replace the operator stuff with the needed code, save it as a tmp file and assemble this one. The source will stay the same... only the assembled file is another :)
Posted on 2002-06-06 03:17:50 by bazik