Created
February 6, 2024 09:09
-
-
Save 0x61nas/d578f321fdf2b6c95f0429bbd999b2a9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; MOV instruction | |
; Used to move a byte, word(16bit), double word(32bit), or quad word(64bit) from the source(second operand) to the dist(first operand). | |
; **Note** that the MOV instruction cannot move data directly from one address in memory to different address in memory | |
; to do that you need to _two separate MOV instructions: frst move the datat from the memory to some registry and then move it from that registry to the dist memory. | |
; Assemble with: | |
; nasm -f elf64 -g -F dwarf mov101.asm | |
; ld -o mov101 mov101.o | |
section .data | |
section .text | |
global .start | |
start: | |
mov rbp, rsp ; for debugging | |
nop ; debugging | |
; Immediate addrissing | |
mov rax, 42h ; put 0x42 in RAX | |
; **NOTE** Immediate data must be of an appropriate size of opperand. Fore example, you can't MOV 16-bit immediate value to a 8-bit register. | |
mov dh, 067efh ; NASM shows a wroning, 'cause DH is a 8-bit reg | |
mov cl, 087efh ; This is wrong too, because CL is a 8-bit reg | |
; NASM allows some interesting forms of immediate values. like strings | |
mov eax, 'Anas' | |
nop | |
section .bass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment