|
-
Jan 28th, 2007, 03:54 PM
#1
Thread Starter
New Member
count loop
Hi,
I can print A - Z fine using the following :
Code:
.model small
.stack 100h
.data
.code
mov ah, 02h ; DOS function call 2, character output
mov dl, 41h ; the character 041h (i.e.'A')
mov cx, 26 ; start the counter at 26 in cx
again: int 21h ; print character
inc dl ; the next character into dl
add dl,1 ;
loop again ; subtract 1 from cx, if not zero jump back to again
finish: mov ax, 4C00h ; Terminate program
int 21h ; correctly
end
What I'd like to do now is print 1 - 100 in the following order
1
2
3
4
5
6
etc etc ...
Any help would be very much appreciated.
thanks in advance
-
Jan 28th, 2007, 05:16 PM
#2
Re: count loop
It's exactly the same, only instead of just printing a single character, you need to print a string, and that string must contain the stringized number.
So you need two subroutines, probably. One converts a number to a string. The other prints a string.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 30th, 2007, 11:42 AM
#3
Member
Re: count loop
Well, I don't know if it is any help to solve the problem for you but you preserve six bytes in data section for your string. Three bytes for the numbers, two for cr and lf and one for string termination.
Code:
msg db 6 dup(0,0,31h,0Dh,0Ah,"$") ;msg = "1"
Then it is a matter of loops. If you have problem show you code and we will help.
-
May 3rd, 2007, 06:53 AM
#4
Junior Member
Re: count loop
i have the same sorta problem as the first guy but i need to display the alphabet on different lines for example
a
b
c
d
e
f
etc,
ive used the same code as he has, but i need to use the newline (0Ah) and carriage return (0Dh) functions in the loop.
if you could help it would help me alot
thanks in advanced
will
dont believe in all that you've been told!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-
May 3rd, 2007, 01:16 PM
#5
Member
Re: count loop
a = 61h and z = 7Ah. Write a loop from 61h to 7Ah. There you have the small letters.
1) Reserve data space like msg db 4 dup(00h,0Dh,0Ah,"$") in data section.
2) Use for example cx and put first letter value in cx.
3) Put cl in first byte of msg
4) Write to screen
5) jump back untill cx = 7Ah
-
Jul 20th, 2007, 11:45 PM
#6
New Member
Re: count loop
i think you should make a table of characters
and use a pointer to this table
for example:
table db 6 dup 'abcdef'
then in your code: if you want to print the alphabet on different lines:
Code:
.model small
.stack 100h
.data
table db 6 dup 'abcdef'
.code
mov ax,@data
mov ds,ax
cld ;clear DF
lea si,table ;si stores the offset of the first char in table
mov cx,6 ;count loop
mov ah,2
again:
lodsb ;[si] -> al
mov dl,al
int 21h
mov dl,0Ah
int 21h
mov dl,0Dh
int 21h
loop again
according to each LODSB instruction :inc si (automatical)
Last edited by gago; Jul 20th, 2007 at 11:49 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|