NASM - The Netwide Assembler

NASM Forum => Other Discussion => Topic started by: shaynox on March 30, 2015, 10:20:12 PM

Title: CPU emulator
Post by: shaynox on March 30, 2015, 10:20:12 PM
Hello, do you know how use avx in machine emulator ? I have already tried qemu/bochs/Hyper-V, but no one work, it's reboot instead read avx instruction then jump into infinite loop.
My test project is in attachment.

(This project is build with windows)
Title: Re: CPU emulator
Post by: shaynox on June 30, 2016, 11:49:29 AM
Well thanks.

The answer was simple finally: code ourselves the instructions into macros.

But I decided to pass this project and use a real machine instead.

Title: Re: CPU emulator
Post by: shaynox on September 18, 2018, 07:55:57 AM
Maybe, but the problem of machine emulator is that they have more than 1 incompatibility with my OS, I forgot how many, there is the LFB address as example that is different, but when using it with real machine, the problem disappear.
Title: Re: CPU emulator
Post by: fredericopissarra on April 11, 2019, 12:09:31 PM
You must check if the emulated processor has support for AVX (or AVX2):

Code: [Select]
  bits  64
  default rel

  section .text

  global  supports_avx
  global  supports_avx2

;
; SysV and MS calling convention mandates RBX must be
; saved between calls. I usualy use asm routines from C functions!
;

supports_avx:
  push  rbx
  mov   eax,1
  cpuid
  xor   eax,eax
  test  ecx,1 << 28
  setnz al
  pop   rbx
  ret

supports_avx2:
  push  rbx
  xor   ecx,ecx
  mov   eax,7
  cpuid
  xor   eax,eax
  test  ebx,1 << 5
  setnz al
  pop   rbx
  ret

Here's some features from Intel's Software Development Manuals: