flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > movv macro

Author
Thread Post new topic Reply to topic
asmgges



Joined: 17 Jun 2003
Posts: 86
Location: France
asmgges 30 Jan 2004, 17:13
Hi ! Very Happy
Here a macro
Code:
macro movv op1,op2
  {
    push op2
    pop  op1
  }  
    

"Mov" op2 in op1

Use:
Code:
Movv [var1],[var2]    
Movv dword[reg+d],dword[reg+d]
Movv [Var],addr
Movv dword[reg+d],addr
    

How to make in the macro not to be obliged to write size dword[reg+d] but just [reg+d]
By knowing always works there 32bits....
Thanks
Friendly.....Gges
Post 30 Jan 2004, 17:13
View user's profile Send private message Visit poster's website Reply with quote
asmgges



Joined: 17 Jun 2003
Posts: 86
Location: France
asmgges 30 Jan 2004, 19:26
3/4 of solution
Code:
d equ dword

;;;;;;; movv dword[reg+d],dword[reg+d] 
movv d[reg+d],d[reg+d]


    

better no ?
For many lines of code, it's less tired for fingers
Friendly..Gges
Post 30 Jan 2004, 19:26
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8354
Location: Kraków, Poland
Tomasz Grysztar 30 Jan 2004, 19:51
You can use pushd and popd mnemonics.
Post 30 Jan 2004, 19:51
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 30 Jan 2004, 20:12
ehm, how often do you move value between two memory variables? Me only very rarely and usualy through some register (and in place where all registers are used i usually dont move much data between two memory variables without modification)
Post 30 Jan 2004, 20:12
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
asmgges



Joined: 17 Jun 2003
Posts: 86
Location: France
asmgges 30 Jan 2004, 20:25
Privalov thanks
I should look at my book of instructions from time to time Confused
There is so for a long time that I did not use them that I have forgotten.

vid
It is just a personal suitability and it is shorter.
I do not have to worry if a register is available or not.

Friendly..Gges
Post 30 Jan 2004, 20:25
View user's profile Send private message Visit poster's website Reply with quote
Bitdog



Joined: 18 Jan 2004
Posts: 97
Bitdog 09 Feb 2004, 06:21
macro movB op1,op2
{
push byte op2
pop pop op1
}

macro movW op1,op2
{
push word op2
pop word op1
}

macro movD op1,op2
{
push dword op2
pop dword op1
}

Untested guess ?
I'm not sure about PUSH BYTE [VAR]
but I've seen it before....
Post 09 Feb 2004, 06:21
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 09 Feb 2004, 06:31
1. you have error in movB - pop pop
2. push byte [] is allright
3. isn't 'movv dword a1, dword a2' enough? (in fact, isnt writing push/pop without macros enough)
Post 09 Feb 2004, 06:31
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Bitdog



Joined: 18 Jan 2004
Posts: 97
Bitdog 11 Feb 2004, 09:24
Hello,
1. I got to popping & did know when to be stoppin.
2. Definately untested code ideas.
3. The PUSH POP works for immediates & seg regs where MOV doesn't.
4. I got another big idea......

Today I thought I would try to solve the .asm code size problem.
One can't see the forrest through the trees with .asm code.
It's so spread out that a screen full doesn't show the goal,
it only shows a lot of push pop meaningless move instuction type junk.
Yet you can look at & decypher a C code screen for quite a while,
& see the full function, from beginning to end.
So how does one compress .asm code ?
My NC DOS editor allows any char 0-255 to be shown exactly like it is,
and it uses CRLF 13,10 for EOL where a .doc editor only uses LF= 10
BUT, Fasm & Nasm allow .doc style code as input.
SO, I can group many lines into one line
using CTRL+Q+J to make the LF char = 10
I try to get the rows of LF even, then add a comment & CRLF.
The lines are grouped according to their function as described by the comment,
and by "if they need a label or not".

I don't know the full implications of this yet?
One down side is my Fasm assembler line errors are different than my editor line count,
because it counts each LF=10 character as another line.
If there was a newline character in the Fasm assembler,
I could group lines like the example below.
It takes a bit of getting use to, to read fluently.
I like it & use it, but will it stand the test of time ?

Example below has 11 lines converted to 4.
The message board formatting doesn't allow LF=10 char,
so I substuted the | more char.
To try it, save as x?, then change the | to LF=10 with Ctrl+Q+J or Ctrl+J ?
With your Norton Commander editor Smile
It almost looks like 3 instructions per line, makes 3 neat columns of code?

Code:
isNEAR: LODSW | CMP AX,0x3D00 | JZ doHDR | JB doSMAL ;chk mach code JMP size
doBIG:  CALL POPSTR | DB "The header is > 64 bytes.",13,10,36
doSMAL: CALL POPSTR | DB "The header is < 64 bytes.",13,10,36
POPSTR: POP DX | MOV AH,9 | INT 21h        ; print string adr on stack
doHDR:

    


I was going to add a SHIFT+ENTER to my KBD TSR asm editor
that added a
space,LF=10,space
so I could group lines easily.

Just some ideas to kick around anyway.
Bitdog
Post 11 Feb 2004, 09:24
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.