Author Topic: Does mov actually move, or just copy?  (Read 7257 times)

Offline macaswell

  • Jr. Member
  • *
  • Posts: 16
Does mov actually move, or just copy?
« on: December 18, 2010, 12:27:25 AM »
So, I'm trying to implement command line arguments in my OS, and I came across a situation of which I've never heard of.

Does the operand 'mov' actually move the data, or just copy the data?

Such as (this code will not work on any os):
Code: [Select]
start:
     mov [tmp0], str0
     mov si, [tmp0]          ; is tmp0 now empty?
     call print_string

     tmp0     times 255 db 0
     str0       db 'Hello, World!', 0

Will that empty [tmp0]?

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Does mov actually move, or just copy?
« Reply #1 on: December 18, 2010, 04:55:36 AM »
"mov" just copies. How would you define "empty"? Re-filled with zeros?

I'm amazed you wrote Casnix without knowing this. I got as far as:

Code: [Select]
mov sp, 0FFFFh

... and stopped reading. You really want to keep your stack aligned!

Best,
Frank