Hi, I am having trouble when I read in an integer from the keyboard and I try to display it to the screen back as the same integer. It pops out as an ASCII character. Am I doing this wrong or is there a way to read it as an integer and not a character, or do I need to convert it back? Thanks
; Compiling this code for 32-bit use:
; nasm -f elf file.asm
; gcc -m32 -o file file.o
;
;~.~. Definitions for readability: ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
%define SYS_EXIT 1
%define SYS_READ 3
%define SYS_WRITE 4
%define STDIN 0
%define STDOUT 1
%define STDERR 2
%define MAX_NUMBER 5000
SECTION .data
format: db "The number is %d." , 10
SECTION .bss
input: resd MAX_NUMBER
SECTION .text
extern printf
global main
main:
nop
GetInput:
mov EAX, SYS_READ
mov EBX, STDIN
mov ECX, input
int 80H
mov DWORD[input + EAX - 1], 0
Calculate:
mov EAX, DWORD[input]
Display:
push EAX
push format
call printf
add ESP, 8
ret