Assembly language

How to take input in assembly language ?

1 Like

assembly is scary!

is it waquar ! but I find it interesting . :slight_smile:

System call via interrupt (int 0x80):


    ;; to read input
    read:
      mov eax, 0x3     ; syscall number 3 e.g. read
      mov ebx, 0x2     ; stdin 
      mov ecx, input   ; pointer to byte array of storage for the input, create in the data segment
      mov edx, [in_length]  ; the length of the (input) storage byte array
      int 0x80         ; system interrupt
    write:
      mov eax, 0x4     ; syscall number 4 e.g. write
      mov ebx, 0x1     ; stdout
      mov ecx, message ; pointer to a byte array where the message to write is stored
      mov edx, [out_length]  ; length of the message
      int 0x80
      ...
      ;; the data we need
      section   .data
      input:   10 times db 0x0
      in_length:    equ $-input
      output:  db   "Some message here",0xa,0 ; don't forget line feeds and zero's
      out_length:    equ $-output
    

Note ‘read’ data is a string! You will need to parse it by subtracting ascii ‘0’/ 48 from every byte value in an input integer. Floating point is more complicated.

Here’s a nice table