I have a program that asks the user for a string. If they were to input 1010, I would need to be able to get access to the "1", "0", "1", and "0" each individually. How would I go about doing this? I'm fairly new to assembly, so a lot of these concepts are still foreign to me.
.section .data
input_prompt:
.asciz "Enter a string of 0s and 1s: "
invalid_message:
.asciz "Invalid input: program terminating\n"
newline:
.byte 10
state:
.int 0 # initial state (EE)
.section .bss
input:
.byte 0
.section .text
.globl main
main:
# Print the input prompt
movl $4, %eax # syscall: write
movl $1, %ebx # file descriptor: stdout
lea input_prompt, %ecx # Prints: "Enter a string of 0s and 1s: "
movl $29, %edx # message length
int $0x80 # invoke syscall
# Read user input
movl $3, %eax # syscall: read
movl $0, %ebx # file descriptor: stdin
lea input, %ecx # buffer to store input
movl $1, %edx # buffer size
int $0x80 # invoke syscall
This is my code that prompts and reads a user input, but is there any way to loop their inputted string? For example, in C you can use getchar() within a loop. Is there a getchar() equivalent that would be applicable for my scenario here, in assembly? (GCC)