DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Assembly (http://www.daniweb.com/forums/forum125.html)
-   -   Assembly newbie question (http://www.daniweb.com/forums/thread22904.html)

pek May 1st, 2005 2:11 pm
Assembly newbie question
 
Can anyone help me on this:

I'm starting programing assembly (in TASM), I'm trying to do this example:

- Print numbers from 1 to 10 within a cycle.

I've managed to print them from 1 to 9 but when it gets to number 10 it prints the corresponding caracter ":" and not number 10! How can I print numbers with 2 or more digits?

This is the code I've made (ex1.asm):

.MODEL SMALL
.STACK 100h

.DATA
PROGRAMA DB "IMPRIMIR OS NUMEROS DE 1 A 10 NUM CICLO.",10,10,"$"
NUM DB 0

.CODE
;initializes data segment
MOV AX, @data
MOV DS, AX

MOV DX, OFFSET PROGRAMA
MOV AH, 09h
INT 21h

;for 1 to 10
MOV CX, 10
REPETIR:
INC NUM ;adds 1 to the number in NUM
MOV DL, NUM
ADD DL, "0"
MOV AH, 02h
INT 21h ;prints the number
MOV DX, 0Ah ;new line
MOV AH, 02h
INT 21h ;prints the new line

LOOP REPETIR

;terminates the program
MOV AX, 4C00h
INT 21h
END

Thanks in advance for any help.


All times are GMT -4. The time now is 10:30 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC