NASM Forum > Example Code

How to read a string using call read_int or call read_char and split to array?


So i am new to assembler and am struggling trying to read a value such as 10001010 using either
call read_int
call read_char
and then taking that input from the keyboard and splitting into an array such as

Is this even possible?
thank you for any advice, and i appreciate any coding help.  Here is what i have so far.

%include "/usr/local/share/"

segment .data
    message       db "Enter code?: ",0
    var1          dd 123
    bitmask       dd 1,1,1,0,0,0,1,1
    mask          dd 11100011
segment .bss
    cook resd 8

segment .text
   global  asm_main

   push   ebp
   mov    ebp, esp
   ;********** CODE STARTS HERE **********

        mov eax, 0
        mov ebx, 0
        cmp ebx, 8
        jge endinit
        mov DWORD [cook + ebx * 4], eax
        inc ebx
        jmp topinit

        cld ;clear destination flag
        mov eax, message        ;display message
        call print_string
        ;call read_char
        call read_int

        mov DWORD [var1], eax

        call read_char  ;\n

        mov eax, DWORD [var1]
        dump_regs 1
        call print_int

        jmp endloop2
        call print_nl

   ; *********** CODE ENDS HERE ***********
   mov      eax, 0
   mov      esp, ebp
   pop      ebp


[0] Message Index

Go to full version