I'm trying to set up an Assembly Programming Environment on Windows. I do have Linux installed, but for curiosity sake, and also studying purposes for learning WSL, I'm trying to make it run through WSL2 on Windows 10.
I've tried to setup both Alpine and Ubuntu (base) installing only the following tools:
bash bash-doc bash-completion
util-linux pciutils usbutils coreutils binutils findutils grep
It was installed with either apk add
or apt install
.
Then I've wrote the following example from Programming Ground Up:
.section .data
.section .text
.globl _start
_start:
movl $1, %eax
movl $0, %ebx
int $0x80
I did the compilation and link without any fancy flags, just the minimum like in the book example.
as exit.s -o exit.o
ld exit.o -o exit
I know that those calls like int $0x80
depends on architecture, operation system, etc.
It's returning Segmentation fault
when I try to run it on the WSL image.
Searching around I've got to know that Segmentation fault is probably regarding the program not exiting the execution, like when a section doesn't have a ret
statement.
(In this case, int $0x80
should be enough for activating the kernel and returning/exiting by calling the value 1 set on ax register)
I thought it was because I'm trying to compile and run a 32bit ASM code in a 64bit machine. But, I did a ssh connection to a pub unix server, which is also a Ubuntu x86_64, and the same code could run without any problem.
Is it a WSL2 limitation? Or do this pubnix have something installed or configured for it to accept the 32bit code without any additional flag?