Is there a command word for copy? For example you have mov, jmp, call, etc. I want to copy the contents of one variable to another.

psuedo:

mov bx, dx
mov memory, bx
copy accum, memory //?????

I want to copy what is in accum and put it in memory.

How do you say one thing equals another in assembly?

I thank you in advance.
Posted on 2002-11-09 18:26:53 by ProLin
The question you're asking is quite wierd actually. Since you'r talking
about copy instuctions in assembly. Ofcourse there are quite alot
of them, however the 'mov' does actually copy from dest,src. :rolleyes:
And you have already used the 'mov' instruction in your displayed code.

Posted on 2002-11-09 18:53:55 by natas
Hi

Natas might be a newbie but he is right :)

MOV instruction is actually a copy instruction that is why ZILOG named it LD (LoaD instead of MOVe).

To copy a value from a memory variable to another memory variable you can use:

mov eax,
mov ,eax

or the form used sometimes in MASM examples:

push
pop

This second method has the advantage of not touching/destroying the contents of no register, while the first one destroys the content of eax.

Old style CPU or PIC sometimes refer to eax (or W) as Accumulator because it is the most versatile register in its set and also sometimes beeing the default source and destination of many actions.

On modern CPUs however this special features of eax have a tendency to disappear in the wind...while some still exist even today...in DIV, LODSB, STOSB and other instructions.

to define equates like #define in C you can use the EQU directive:

my_constant EQU 5 ; i.e. my_value

You can then use the symbolic reference to my_constant in your code instead of the number 5 itself.

This will ease any later changing from 5 to 7 everywhere in code if needed.

Bogdan
Posted on 2002-11-09 20:23:21 by BogdanOntanu
Thank you for the input. I will try different techniques. I did try using eax, but MASM611 is giving me an error. Do you have to add anything to the top of the program to use eax? I'm new to assembly also.
Posted on 2002-11-09 21:04:30 by ProLin
I installed the new masm. I'll have to wait to mess around with it. It seems overwhelming right now. Thank you.

When using this in my program:

mov eax, accum
mov memory,eax

I get this error:

error A2085: instruction or register not accepted in current CPU mode


I have WinXP, pentium 4 if that helps. I don't think it should matter?
Posted on 2002-11-09 21:53:11 by ProLin
error A2085: instruction or register not accepted in current CPU mode
My best guess would be that you havent set the assembler directives etc. In other
words you havent used a 'skeleton'.
;###################

;# W32ASM SKELETON #
;###################
.386
.MODEL FLAT , STDCALL
OPTION CASEMAP : NONE

INCLUDE \MASM32\INCLUDE\WINDOWS.INC
INCLUDE \MASM32\INCLUDE\KERNEL32.INC
INCLUDELIB \MASM32\LIB\KERNEL32.LIB

.DATA
.DATA?
.CONST

.CODE
START:
invoke ExitProcess,0

END START

I cannot determine you'r current level of knowledge when it comes to assembly.
But if you want one good advise? I would have to suggest that you read all of
Iczelion's tutorials. (http://spiff.tripnet.se/~iczelion/tutorials.html)

Good luck! you'll have a blast once you get past the 'oh my god! there is so much to read' phase. :grin:
Posted on 2002-11-09 22:05:16 by natas
Mine sure isn't like that. It has worked for all my other small programs. Heres my skeleton:


.model small ;the memory model

.stack 100h ;reverse stack space (256 bytes here)

.data ;denotes that data declarations follow

.code

main:

/////blah blah blah/////

;end program

mov ah, 4ch ; function to cause int 21h to end the program
mov dl, 0 ;return code, can be any byte ordercode
int 21h ;interrupt call

end main ;end program
Posted on 2002-11-09 22:13:01 by ProLin
Well, it looks to me that you have been programming in
DOS and not Windows. The rules change a bit when you
change from DOS to Windows assembly programming.

So no wonder you had some problems getting your code
to work.
:)

EDIT: MASM32 Is a 32-Bit assembler(not 16-bit like DOS).
Posted on 2002-11-09 22:21:31 by natas

Mine sure isn't like that. It has worked for all my other small programs. Heres my skeleton:


.model small ;the memory model

.stack 100h ;reverse stack space (256 bytes here)

.data ;denotes that data declarations follow

.code

main:

/////blah blah blah/////

;end program

mov ah, 4ch ; function to cause int 21h to end the program
mov dl, 0 ;return code, can be any byte ordercode
int 21h ;interrupt call

end main ;end program


Don't end your program with explicit 16 bit dos commands. Use a skeleton from one of the tutorials and end it that way with 32 bit API calls.

Also your "accumulater" in your code before i hope is a variable
Posted on 2002-11-09 22:24:11 by IwasTitan
Sorry guys, I thought that all assembly was run in dos. Newbie mistake. Let me check out some more things. This stuff is driving me nuts!!:grin:
Posted on 2002-11-09 22:28:15 by ProLin
If you really want to do asm in 16 bit, get the 16bit linker to link yor files.
Posted on 2002-11-10 00:07:58 by roticv
The reason for the EAX error is because the MASM default is to assemble for the 16-bit 8086 CPU. The EAX register, and all the other 32-bit mode stuff, didn't exist until the 80386. So you need to tell MASM by using the .386 (or .486 .586 etc.) directive, like in the example from natas.

:)
Posted on 2002-11-10 12:11:12 by S/390