얻기 이것은 간단한 질문은 희망입니다. 바로 지금, 내가 가진 :리눅스 86 ASM 사용자 입력
section .data
greet: db 'Hello!', 0Ah, 'What is your name?', 0Ah ;simple greeting
greetL: equ $-greet ;greet length
colorQ: db 'What is your favorite color?' ;color question
colorL: equ $-colorQ ;colorQ length
suprise1: db 'No way '
suprise1L equ $-suprise1
suprise3: db ' is my favorite color, too!', 0Ah
section .bss
name: resb 20 ;user's name
color: resb 15 ;user's color
section .text
global _start
_start:
greeting:
mov eax, 4
mov ebx, 1
mov ecx, greet
mov edx, greetL
int 80 ;print greet
getname:
mov eax, 3
mov ebx, 0
mov ecx, name
mov edx, 20
int 80 ;get name
askcolor:
;asks the user's favorite color using colorQ
getcolor:
mov eax, 3
mov ebx, 0
mov ecx, name
mov edx, 20
int 80
thesuprise:
mov eax, 4
mov ebx, 1
mov ecx, suprise1
mov edx, suprise1L
int 80
mov eax, 4
mov ebx, 1
mov ecx, name
mov edx, 20
int 80
;write the color
;write the "suprise" 3
mov eax, 1
mov ebx, 0
int 80
을 그래서 무엇의 이름과 색상을 요청하고, 어떤 방법 --name-- --color--도 내 좋아하는 색깔입니다 "라고 말할 것입니다
.내가 도움이 필요한 것은 사용자가 입력 한 후 위의 "이름"과 "색상"변수의 길이를 찾는 방법입니다. 그렇지 않은 경우, 최대 값을 알기 때문에 길고 불쾌한 공백이 많이 생깁니다. 그들이 할 수있는 크기는 내가 전에 선언 한 것입니다.
가 어떠한 도움을 주셔서 감사합니다.
나는 read 명령어 다음에 eax에서 "returned"값을 사용하려고 시도했지만 이것은 원래 버퍼를 얼마만큼 선언했는지 리턴한다. – nmagerko