| | |
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.
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.
![]() |
Similar Threads
- Newbie Question - How to generate a link (PHP)
- HttpContext.Current Question (VB.NET)
- newbie... Java load large picture :) Lit'l help plez (Java)
- Assembly Programming Question (Assembly)
- Newbie Question - Hiding php extension (PHP)
- Stupid Newbie Question (C)
- AGP Aperture Size Question (Windows NT / 2000 / XP)
- How to network two Win98 machines (Networking Hardware Configuration)
Other Threads in the Assembly Forum
- Previous Thread: MIPS - I'm Not getting the right answer :( Can anybody Review :)
- Next Thread: shrd instruction and converting integers to ascii
| Thread Tools | Search this Thread |





