下面的代码使用nasm和GNU链接器进行编译,但它不会执行打印askInput2
的位置。我在网上搜索过,找不到任何有关如何解决的信息。
section .data
count db 48 ;Ascii value of '0'
askInput db 'Enter a number to multiply: '
lenAskInput equ $ - askInput
askInput2 db 'Enter a number for it to be multiplied by: '
lenAskInput2 equ $ - askInput2
RETURN dw 0xa, 0xd
section .bss
input resb 1
input2 resb 1
output resb 10
section .text
global _start
_start:
inc byte [count] ;count = 1 (49)
inc byte [count] ;count = 2 (50)
;Display count
mov eax, 4
mov ebx, 0
mov ecx, count
mov edx, 1
int 0x80
mov eax, 4
mov ebx, 0
mov ecx, RETURN
mov edx, 1
int 0x80
dec byte [count] ;count = 1 (49)
mov eax, 4
mov ebx, 0
mov ecx, count
mov edx, 1
int 0x80
mov eax, 4
mov ebx, 0
mov ecx, RETURN
mov edx, 1
int 0x80
mov eax, 4
mov ebx, 0
mov ecx, askInput
mov edx, lenAskInput
int 0x80
mov eax, 3
mov ebx, 2
mov ecx, input
mov edx, 1
int 0x80
mov eax, 4
mov ebx, 0
mov ecx, askInput2
mov edx, lenAskInput2
int 0x80
;Does not execute past here
; This is for testing
mov eax, 4
mov ebx, 0
mov ecx, 49
mov edx, 1
int 0x80
;
mov eax, 3
mov ebx, 2
mov ecx, input2
mov edx, 1
int 0x80
mov dl, [input]
mov al, [input2]
mov al, 3
mul dl
add ax, '0'
mov [output], ax
mov eax, 4
mov ebx, 0
mov ecx, output
mov edx, 10
;Exit the program
mov eax, 1
mov ebx, 0
int 0x80
构建命令:
nasm -f elf incothers.asm
ld -m elf_i386 -o incothers incothers.o