challenge for MACRO experts & ASM gurus 
Author Message
 challenge for MACRO experts & ASM gurus

Hello folks,

today I encountered a nice challenge with some MACRO stuff, and so
far I was not able to solve the problem. Please, look at this demo
MACRO, and let me explain a few thing below:

        UMOV     macro    _destin,_source
                 db       0Fh
                 mov      _destin,_source
                 endm

The idea behind it is rather simple: I want a MOV to be assembled,
and then used to create an UMOV instruction out of it.

After looking at Intel manuals, I found that the wanted MOV starts
with 88/89/8A/8Bh. Then some other bytes follow.

After looking at several UMOV descriptions, I found that UMOV will
start with 0F 10/11/12/13h, and then the same bytes will follow as
with the normal MOV instruction.

So the macro needs some stuff, which will modify the 1st byte of a
MOV. This is very simple in theory: just AND this byte with 03h so
that it goes from 88/89/8A/8Bh to 00/01/02/03h, and then OR 10h it
so that it finally goes to 10/11/12/13h.

So the question #1 is: How do I do that in my "basic" macro?

Okay, some of you might come up with a solution for that. But then
the next problem is waiting for you: I want to be able to eg.

        UMOV     es:[1234h],al

in my code. And this ES: segment override prefix must be placed as
the first byte of the UMOV then before the 0Fh. So how can this be
solved in my "basic" macro?

So -- are you ready for this challenge?  :-)

--
Christian Ludloff



Fri, 08 Jan 1999 03:00:00 GMT  
 challenge for MACRO experts & ASM gurus

Christian,

Quote:
>After looking at Intel manuals, I found that the wanted MOV starts
>with 88/89/8A/8Bh. Then some other bytes follow.

>After looking at several UMOV descriptions, I found that UMOV will
>start with 0F 10/11/12/13h, and then the same bytes will follow as
>with the normal MOV instruction.

So you basically want to replace the opcode proper.
There is a clue in Intel's own P5MASM.MAC at my web.
Notice how Intel used the existing SIDT instruction to assemble
the entire instruction, then used ORG to replace the opcode proper
with that of CMPXCHG8B, exploiting the fact that the instructions
are otherwise identical.

[P5MASM.MAC]

;
;                       INTEL CONFIDENTIAL
;
;       P5 CODE MACRO FILE FOR USE WITH MICROSOFT MASM 5.1 OR LATER
;       ASSEMBLER.        
;[..snip..]
; NOTE:  This macro uses the SIDT instruction to generate the correct
;        addressing scheme, i.e., memory variable w/ or w/o indexing,
;        bracketed register expression, etc.  It then replaces the
;        second opcode byte with the opcode for CMPXCHG8B (0C7H).

CMPXCHG8B MACRO operand  
        local L1, L2
L1:     SIDT operand
L2:     org L1 + 1
        db 0C7H
        org L1 + 5
ENDM

Hmm ... something tells me I should not have posted this for some reason.
Oh well, nevermind.

+----------------------------------------------------------------------------+

+----------------------------------------------------------------------------+



Sat, 09 Jan 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Another challenge for the AWK guru

2. 1 Envy guru, and 1 telecom expert needed, ASAP

3. AskMerlin, your AI expert system guru oracle advisor

4. A Challenge for Tcl Experts

5. LISP - The Challenge of Nested Macros

6. Gracious help needed for ASM challenge !

7. deadly ASM challenge

8. small asm challenge

9. ANNC: New Site Featuring Profiles of IBM ASM Experts

10. ASM Expert Needed: Paid assignment.......

11. ASM Expert Needed: Paid assignment.......

12. Macro lambda lists: &key and &body

 

 
Powered by phpBB® Forum Software