sfl-examples/slide-examples/assembly/ex08.asm

31 lines
893 B
NASM

bits 64
SECTION .data
; empty
SECTION .text
global _start
_start:
%include "header.asm.inc"
mov rax, 0xFFFFFFFFFFFFFFFF ; maxint
; moving data into sub-registers
mov al, 0x11 ; rax -> 0xFFFFFFFFFFFFFF11
mov ah, 0x22 ; rax -> 0xFFFFFFFFFFFF2211
mov ax, 0x3333 ; rax -> 0xFFFFFFFFFFFF3333
; There is one exception, though:
; Intel's reference tells us that "32-bit operands generate
; a 32-bit result, zero-extended to a 64-bit result in the
; destination general-purpose register.", thus:
mov eax, 0x44444444 ; rax -> 0x0000000044444444
; moving with zero-extension (movzx)
mov rax, 0xFFFFFFFFFFFFFFFF ; maxint
mov bx, 0x55
mov al, bl ; rax -> 0xFFFFFFFFFFFFFF55
movzx rax, bx ; rax -> 0x0000000000000055
%include "sysexit.asm.inc"