how can i input a number composed from 2 digit and i print it!
I tried but i can't

mov ah,1
int 21h
to input one number like 1 or 5 ....

But how can i input number like 34 or 19 ....and i print it!?

7 Years
Discussion Span
Last Post by arya.herro

#This is how u can read an input from keyboard.

#Supposed u have declared an ascii variable :

var: .ascii ""
var_len: .long . - var

movl $3, %eax #3 is the number of the system call "read"
movl $0, %ebx #0 is the keyboard identifier
leal var, %ecx #u put the pointer to that variable in the register ecx.
movl $1, %edx #it reads 1 character (the speed of reading)
int 0x80 #call interrupt 0x80 to execute the system call read.

#this is how u can print ur string now :

movl $4, %eax #4 system call write
movl $1, %ebx #1 stdout
leal var, %ecx
movl var_len, %edx
int $0x80

Edited by magicsign: n/a


thank you magicsign for your reply but i want it in assembly 16bit

mov ah, 1
int 21h          ;read ascii digit
mov str[0], al   ;save digit to string

mov ah, 1
int 21h          ;read ascii digit
mov str[1], al   ;save digit to string

lea dx, str      ;ds:dx -> string
mov ah, 9        ;print the string
int 21h         
mov ax, 4c00h    ;finish
int 21h

str db 2 dup(?), '$'
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.