我尝试了这段代码(使用中断),但它适用于 DOS:
mov eax, 42 ; write 42 to console
mov ecx, 10 ; in decimal
out_int_loop:
xor edx, edx
div ecx
push eax
add dl, '0' ; one digit
mov ah, 2 ; 2 is code for writing character
int 21h
pop eax
cmp eax, 0
jnz out_int_loop