很明显,WSL不支持32位系统调用
谢谢Timothy Baldwin!
我做了一个简单的程序来返回数组的最高元素,但$ echo $?
回声1而不是222
我用作GNU汇编程序
/*
%edi will hold the current position in the list.
%ebx will hold the current highest value in the list.
%eax will hold the current element being examined
*/
# data_items - contains the item data. A 0 is used
# to terminate the data
.section .data
data_items: #These are the data items
.long 3,67,34,222,45,75,54,34,44,33,22,11,66,0
.section .text
.globl _start
_start:
movl $0, %edi # zero into index register
movl data_items(,%edi,4), %eax #load the first bit
movl %eax, %ebx # since this is the first item, %eax is the biggest
start_loop: # start loop
cmpl $0, %eax # check if element==0
je loop_exit
incl %edi # load next element
movl data_items(,%edi,4), %eax
cmpl %eax, %ebx # compare value
jle start_loop # jump to beginning if element is not the largest
movl %eax, %ebx # move the value as the largest
jmp start_loop # go to beginning
loop_exit:
movl $1, %eax # exit
int $0x80 #call kernel
答案 0 :(得分:0)
您的代码大部分都是正确的,但错误是由错误的Jcc
指令引起的。所以改变行
jle start_loop # jump to beginning if element is not the largest
到右Jcc
指令
jge start_loop # jump to beginning if element is not the largest
并且您的代码按预期工作。