;----------------------------------------------------------- ; This procedure requests an integer an displays ; it using scanf and printf. ; The value entered is returned to the C program. ;----------------------------------------------------------- .MODEL SMALL EXTRN _printf:PROC EXTRN _scanf:PROC .DATA scan_format db "%d",0 printf_format1 db "Please enter an integer: ",0 printf_format2 db "x = %d",10,13,0 ;10 and 13 are Carriage return and line feed x dw ? .CODE .486 PUBLIC _read_int _read_int PROC enter 0,0 ; printf to output the prompt message push OFFSET printf_format1 call _printf add SP,2 ; clear the stack ; scanf call push OFFSET x ; push x pointer push OFFSET scan_format call _scanf add SP,4 ; clear the stack push x ; push x value push OFFSET printf_format2 call _printf add SP,4 ; clear the stack mov AX,x ; return value to C main leave ret _read_int ENDP END