i'm a newbee and i don't know a lot of asm coding! i would like to know what is a macro!
Posted on 2001-05-11 16:13:00 by freakboy
One way to think of a macro is it's a program you write for the compiler. When you write an .asm program, you start by writing a text file. This text is passed to the compiler, that generates rough machine code. The linker polishes this crude code and packages it in a form that windows recognises as a program so it can be run. The compile step is actually a very involved step. The compiler may need to make many runs thru your text to figure out what you mean by the symbols you made for it. One of the first things it does is 'expand' your macros. A macro may be a simple text substitution, or it may be a variable loop with goto's and counters and lots of stuff. A macro may either make code, make definitions, or a combination. The orgional "Art of Assembly" had a decent section on macros. Sorry, I've yet to read the new version.
Posted on 2001-05-11 18:42:00 by Ernie
I've always considered a macro to be a "chunk" of code that you can use over and over, either in the same program, or in different programs, that you "call" with a unique name. Take a look at some of the examples that come with MASM32. Here's a very simple macro: m2m MACRO M1, M2 push M2 pop M1 ENDM This defines a macro named "m2m" short for "memory to memory move". So instead of having to code: push abc pop xyz you can use the "shortcut": m2m xyz,abc This one is easy, but macros can be very involved. For example, you can use conditional assembly statements, like IFIDN and IFNB inside a macro, to analyze it's operands, and generate different code, depending on what the user passed in those operands. Macros provide the programmer with a "high level" method of generating reusable code. But unlike procedures or functions, that are "preassembled" and called by the program. a macro generates code BEFORE it's assembled, either the same code every time, or code that can vary, depending on several factors. :)
Posted on 2001-05-11 22:42:00 by S/390
Boolean Algebra? I dont know if you need a site to realy learn it, its rather simple.. you just need to know the rules, and i assume you already have the basics like "and", "or", and "xor": I will start you with the manipulative rules for boolean equations:

(.) == and  (+) == or  (^) == xor (!)== not

Law of Ones and Zeros: 
  x+0 = x
  x.0 = 0
  x^0 = x  <-- Good for toggling bit control (Toggle Off) 

  x+1 = 1
  x.1 = x
  x^1 = (!x) <-- Toggle On

Indepotent Laws (same value):
  x+x = x
  x.x = x
  x^x = 0

Double Negatives:
  x+(!x)= 1
  x.(!x)= 0
  x^(!x)= 1

Commutative Laws:
  x+y == y+x
  x.y == y.x
  x^y == y^x

Associatative Laws:
  x+(y+z) == (x+y)+z
  x.(y.z) == (x.y).z
  x^(y^z) == (x^y)^z

Distributive Laws:
  (x+y).z == (x.z)+(y.z)
  (x.y)+z == (x+z).(y+z)
  (x^y).z == (x.z)^(y.z)

DeMorgan's (Big one here):
  !(x+y) == (!x).(!y)    ( Change operators, toggle individual variables)

   (x.y)+(y.z)+(z.(!x)) == (x.y)+(z.(!x))

   (x.y)+(z.(!x)) == (x+z).(y+(!x))
   This is same 'logical' truths as Consensus, but shown in 3 equivalent forms. Multiply out the answer to swap, and you get the first statement of the Consensus.

Duality (not too important, but neat):
   Basically function negation (its equal oposite)

   f == boolean function
   F == its dual

  Dual[ f(a,b,c, operators, + , . ) ]== F(a,b,c, operators, . , + )

  This can be handy when some function is crazy. Rather than hunting out all the boolean theorems and reducing a function, you can derive its dual by replacing +'s with .'s (and 1's with 0's) and reduce with above equations, and then DUAL back to 'f' for a short cut solution (in some cases) ie]

 let nothing == and, ie (ab) == (a.b)

  f = (a+b+c)(d+c+a)(a+d+(!b))
  F = (abc)+(dca)+(ad(!b))        DUAL
    = a( bc + dc + d(!b) )        Distributive
    = a( bc + d(!b) )             Consensus
  f = a + ( (b+c)(d+(!b)) )       Dual to final answer


  !( x ^ y) == (!x)^y == x^(!y)

Well thats about it!.. They take practice to remember but if your up to some crazy logic stuff than these will help you figure out efficient "if" stuctures etc. A good method in design is truth tables: If i had say 8 conditions to think about a responce in my program ( two varibles since 2^3=8 (binary) ) i would lay out there posibilities in a table:

 a b c | enter the if loop
 0 0 0 | 0     
 0 0 1 | 1
 0 1 0 | 0
 0 1 1 | 1
 1 0 0 | 1
 1 0 1 | 1
 1 1 0 | 0
 1 1 1 | 1

This table can be aranged in a K-Map, to determin a basic initial function (and then evaluated further)

     \ c
   a b\   0  |  1 
   0 0|      |
   0 1|      |
   1 1|      |
   1 0|      |

NOTE: K-maps only work IF AND ONLY IF the column row values change only one bit at a time (See a, b column) and this includes the wrap around from bottom to top (a, b, column) and left to right (c column).  So if i had say 4 variables the top would be cd == 00 01 11 10 as column headers.

Now, finally fillin in your k-map, simply read your above boolean table and add entries:

     \ c
   a b\   0  |  1 
   0 0|  0   |  1
   0 1|  0   |  1
   1 1|  0   |  1
   1 0|  1   |  1


  1 by itself isolated by its oposit on all 4 sides
  2 in a row ( 2^1 = 2)
  4 in a row ( 2^2 = 4)  4 in a box ( 2^2 = 4)
  8 in a row ( 2^3 = 8)  8 in 2 rows of four in a RECTANGLE (2^3=8)
  etc. (as long as they are base 2, and in a rectangle of some sort!)

To finalize, i can see alot of 1's to wrap implicants for:
1) all of column c=1: 4 in a row == (2^2=4)!
   This means the exponent # (2) of varibles are removed to consider them in a final equation. 
   So, all of column 4 would eli
Posted on 2001-05-11 23:53:00 by NaN
In an assembly sense, no '.' shouldnt mean "and". I overlooked this when posting it, it stems from boolean algebra where and is most commonly notated as a 'dot' between variables or nothing at all. As well, 'or' are typically notated as '+'s, not's as a bar above the variable(s), and xor's are an or symbol '+' with a circle around it. I sorta made a hybrid between MASM and standard boolean algebra to accomodate the post :) BTW yes, a(b+c) is 'a' and ('b' or' 'c')... (there is no '-' however) NaN
Posted on 2001-05-12 12:00:00 by NaN
freakboy, Just to expand on what Ernie has told you, you can think of a macro as a form of text conversion BEFORE the assembler converts the code into a binary file. This is often called a PRE-PROCESSOR because it processes the code before it is assembled. If you had to regularly write a piece of code, you can save the repetitive typing by writing a macro. The m2m macro in MASM32 is a good example. There is no single instruction in x86 asembler to copy one memory operand to another, it must be done through an intermediary. Where you would normally use a register or the stack to copy a memory operand to another, if you write a simple macro like the following from MASM32,

      m2m MACRO M1, M2
        push M2
        pop  M1
When you want to copy memory from one place to another, you simply type,

    m2m mem2, mem1
and it copies the memory from mem1 to mem2. This saves you from repetitively typing,

    push M2
    pop  M1
What happens is that BEFORE the code is converted to a binary file, the assembler expands the "m2m mem2, mem1" back into the push M2, pop M1. This is a very simple macro but macros can be used to do far more complex things, they can preprocess blocks of code in an automated manner, automate special types of function calls, perform loop code and other usaeful things. Regards, hutch@pbq.com.au
Posted on 2001-05-12 14:49:00 by hutch--