Holiday mood right now... Here's the code for Linux (but you probably have figured it out already)
;compile: nasm -f elf64 this.asm
;Link : gcc this.o -o this
;-------------------------------
global main
foo:
;lfence
;mov cr0,rax
bar:
section .text
main:
enter 0,0
mov rsi,foo
mov rbx,foo
mov rdx,bar
sub rdx,rsi
jz .done
.more: xor esi,esi
mov sil,[rbx]
mov rdi,fmt
inc rbx
push rdx
push rbx
call printf
pop rbx
pop rdx
sub rdx,1
jnz .more
mov rdi,0ah
call putchar
.done: leave
ret
section .data
fmt db '%02X ',0
extern printf
extern putchar
Added advantages, in addition to the first post;
1. You can see the encoding of almost all system instructions and registers that are otherwise prohibited in normal mode
2. You can test what instructions are currently (not) supported by NASM, as long as you give the correct syntax
3. Gives you instruction size.
4. Boss-ing around NASM authors by showing them 'faulty' encoding even if you are completely clueless yourself. (not recommended. NASM people are not that funny)
But hey, enjoy you holidays.