Assembly newbie question

Reply

Join Date: May 2005
Posts: 1
Reputation: pek is an unknown quantity at this point 
Solved Threads: 0
pek's Avatar
pek pek is offline Offline
Newbie Poster

Assembly newbie question

 
0
  #1
May 1st, 2005
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC