How to run X86 NASM on Macbook Air with M1 Chip?
Asked Answered
C

0

6

I have a course on assembly programming and x86 NASM is what they are following for the course.

For the online evaluation I have to make the following commands work on my computer to execute my .asm file on the terminal.

nasm -f elf file_name.asm
ld -melf_i386 file_name.o -o file_name 
./file_name

I have installed UTM and followed the instructions given here to set up my virtual machine on my 2020 M1 Macbook Air.

After installing NASM and trying to run a file called file_name.asm using the commands mentioned above I get the following response.

/usr/bin/ld: unrecognised emulation mode: elf_i386
Supported emulations: aarch64linux aarch64elf aarch64elf32 aarch64elf32b aarch64elfb armelf armelfb aarch64linuxb aarch64linux32 aarch64linux32b armelfb_linux_eabi armelf_linux_eabi

I understand that this has something to do with the chip compatibly and might work if I changed elf_i386 to anything even in the error response, with slight variations.

I also understand NASM can be run natively on MAC OS with slight variations of the same without using a Virtual Machine, But the requirements of my course is that I should be running NASM on Linux with and I should be using the above mentioned commands to run the .asm. file.

I have been stuck on this for a few days and would be grateful if anyone can help me with this issue. Thanks in Advance.

Here is the the output of entering lscpu into the terminal for reference of my cpu architecture on the Virtual Machine.

Architecture:                    aarch64
CPU op-mode(s):                  64-bit
Byte Order:                      Little Endian
CPU(s):                          4
On-line CPU(s) list:             0-3
Thread(s) per core:              1
Core(s) per socket:              4
Socket(s):                       1
NUMA node(s):                    1
Vendor ID:                       0x00
Model:                           0
Stepping:                        0x0
BogoMIPS:                        48.00
NUMA node0 CPU(s):               0-3
Vulnerability Itlb multihit:     Not affected
Vulnerability L1tf:              Not affected
Vulnerability Mds:               Not affected
Vulnerability Meltdown:          Not affected
Vulnerability Spec store bypass: Vulnerable
Vulnerability Spectre v1:        Mitigation; __user pointer sanitization
Vulnerability Spectre v2:        Not affected
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Not affected
Flags:                           fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 asimddp sh
                                 a512 asimdfhm dit uscat ilrcpc flagm sb dcpodp flagm2 frint

Camera answered 23/2, 2022 at 10:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.