Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print integer to console in x86 assembly

Tags:

People also ask

What is integer in assembly language?

An integer is a whole number with no fractional part. In assembler, the variables are created by data allocation directives. Assembler declaration of integer variable assigns a label to a memory space allocated for the integer.

What does Atoi do in assembly?

The atoi() function converts a character string to an integer value. The input string is a sequence of characters that can be interpreted as a numeric value of the specified return type. The function stops reading the input string at the first character that it cannot recognize as part of a number.


When I add two values in 16 bit assembly, what is the best way to print the result to console?

At the moment I have this code:

;;---CODE START---;;
mov ax, 1   ;put 1 into ax
add ax, 2   ; add 2 to ax current value
mov ah,2  ; 2 is the function number of output char in the DOS Services.
mov dl, ax ; DL takes the value.
int 21h    ; calls DOS Services

mov ah,4Ch   ; 4Ch is the function number for exit program in DOS Services.
int 21h      ; function 4Ch doesn't care about anything in the registers.
;;---CODE END---;;

I think that dl value should be in ASCII code, but I'm not sure how to convert ax value after addition into ASCII.