User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Assembly section within the Software Development category of DaniWeb, a massive community of 391,551 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,602 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Assembly advertiser:
Views: 2537 | Replies: 11 | Solved
Reply
Join Date: Nov 2006
Posts: 7
Reputation: Jamaican Beauty is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Jamaican Beauty Jamaican Beauty is offline Offline
Newbie Poster

Help First Timer and trying to learn the basics (Please help me ASAP)

  #1  
Nov 8th, 2006
Hello, I'm a begginer at this asm code stuff and I've had to write a couple of simple and basic begginers programs. Well the one that I have to do now has to have an output that looks like this:

*
**
***
****
*****
and it must be a nested loop meaning a loop inside of a loop.

In this program we have to use a counter, line feed, carriage return, and nested loop. My teacher said that there should be two counters. I'm trying but every time my output looks like:

*
*
*
*
*
*
*
or it looks like

*
*
*
*
*
*
*
*
*
*
Can someone please tell me what the heck I'm doing wrong????!!!! PLEASE ASAP

This is my code:

org 100h



mov bl,0
L1: mov al,'*'
mov ah,0eh ;prints to screen
int 10h



mov al,10 ;line feed
mov ah,0eh
int 10h

inc bl ;counter
cmp bl,5

jne L1


mov al,13 ;carriage return
mov ah,0eh
int 10h

mov bl,0
inc bl
cmp bl,5

jne L1
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 10,542
Reputation: Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of 
Rep Power: 36
Solved Threads: 860
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Most Valuable Poster

Re: First Timer and trying to learn the basics (Please help me ASAP)

  #2  
Nov 9th, 2006
you need two counters -- the first counter counts the number of lines to be printed, the second counter counts the number of stars that are printed on the current line. Your code is putting a CR/LF after every star. This should happen only after the stars have been printed on the current line. You need two loops and two counters to accomplish that.
Last edited by Ancient Dragon : Nov 9th, 2006 at 12:04 am.
I think it's about time we voted for senators with breasts. After all, we've been voting for boobs long enough. ~Clarie Sargent, Arizona senatorial candidate
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
Reply With Quote  
Join Date: Nov 2006
Posts: 7
Reputation: Jamaican Beauty is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Jamaican Beauty Jamaican Beauty is offline Offline
Newbie Poster

Re: First Timer and trying to learn the basics (Please help me ASAP)

  #3  
Nov 9th, 2006
I see what you are saying but now I'm just getting my self confused. I tried something different. I put two print out screens. I don't think there is suppose to be two those, and I got something that looked like this:

*
**
**
**
**
**
**
**
**
**

It's like my counters are not added up right, like it's stuck. Do yall have any suggestions for me please???
Hey if yall see someone that responded others can respond to, the more I hear it maybe you could translates what someone else is already said, but I could better understand you. :-)

my code:

org 100h

L2: mov al,13 ;cr
mov ah,0eh
int 10h

mov al,'*'
mov ah,0eh ;prints to screen
int 10h

inc bl ;counter
cmp bl,5


jne L1

L1: mov al,10 ;line feed
mov ah,0eh
int 10h


mov al,'*'
mov ah,0eh ;prints to screen
int 10h


inc bl ;counter
cmp bl,5



jne L2

Reply With Quote  
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 10,542
Reputation: Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of 
Rep Power: 36
Solved Threads: 860
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Most Valuable Poster

Re: First Timer and trying to learn the basics (Please help me ASAP)

  #4  
Nov 9th, 2006
I think it should be something like this -- I didn't assemble or test it.
;
mov  bx,1 ; row counter
loop_start::
xor cx,cx ; column counter
l1:
 mov al,'*'
mov ah,0eh ;prints to screen
int 10h 
inc cx
cmp cx,bx ; have we printed enough stars ?
jne l1  ; no, then do it again
:print CR/.LF
;
; save our two loop counters
push bx
push cx
mov al,10 ;line feed
mov ah,0eh
int 10h 
mov al,13 ; CR
mov ah,0eh
int 10h
; restore our two loop counters
pop cx
pop bx
; process row counter
inc bx
cmp bx,5
jne loop_start
Last edited by Ancient Dragon : Nov 9th, 2006 at 6:12 am.
I think it's about time we voted for senators with breasts. After all, we've been voting for boobs long enough. ~Clarie Sargent, Arizona senatorial candidate
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
Reply With Quote  
Join Date: Nov 2006
Posts: 7
Reputation: Jamaican Beauty is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Jamaican Beauty Jamaican Beauty is offline Offline
Newbie Poster

Re: First Timer and trying to learn the basics (Please help me ASAP)

  #5  
Nov 9th, 2006
Well yes it worked and I'm happy to see that it loops like it should on the paper, but now I have to look at it some more and see how I could substitue some codes for something else, b/c we never used the xor. I don't even know what that does. What exactly is "XOR"? Then I have to make it loop twice so I can get the same print out:

*
**
***
****
*****
*
**
***
****
*****

So I'll try and maybe you can help me if I can't get it. :-)
Reply With Quote  
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 10,542
Reputation: Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of 
Rep Power: 36
Solved Threads: 860
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Most Valuable Poster

Re: First Timer and trying to learn the basics (Please help me ASAP)

  #6  
Nov 9th, 2006
xor ax,ax
is the same as this
mov ax,0
except that xor is a tiny bit faster
Last edited by Ancient Dragon : Nov 9th, 2006 at 1:13 pm.
I think it's about time we voted for senators with breasts. After all, we've been voting for boobs long enough. ~Clarie Sargent, Arizona senatorial candidate
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
Reply With Quote  
Join Date: Nov 2006
Posts: 7
Reputation: Jamaican Beauty is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Jamaican Beauty Jamaican Beauty is offline Offline
Newbie Poster

Re: First Timer and trying to learn the basics (Please help me ASAP)

  #7  
Nov 9th, 2006
Oh I see now. Well I doctored it up and I really understand it now. I looked at every step and saw how it really worked and what I was doing wrong. I even understand the jumps a little bit better now to thanks to your help. I took out the push's and pop's because they really didn't not have any effect on the code. I really really want to thank you a lot for helping me out and allow me to understand this program better. I hope that if I have any other program problems you will be around to help me out. :-) Thanks

This is my what the code now looks like:

main: mov bl,1 ;this command counts the rows
L2: mov cl,0 ;this command counts the column

L1: mov al,'*' ;puts a star into register al
mov ah,0eh ;prints to screen
int 10h

inc cl ;helps with the number of stars
cmp cl,bl ;that will be printed

jne L1 ;jumps to L1 if register cl and
;register bl are not equal



mov al,10 ;line feed
mov ah,0eh
int 10h

mov al,13 ;carriage return
mov ah,0eh
int 10h


inc bl ;keeps up with counting the rows
cmp bl,6 ;and tells how many rows are left
;to be print



jne L2 ;Jumps to L2 when register bl is "not"
;equal to 6





jmp main ;jumps back to the very first step
;of the code to allow it to repeat
;indefinitely when all the rows has
;been accounted for
Reply With Quote  
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 10,542
Reputation: Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of 
Rep Power: 36
Solved Threads: 860
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Most Valuable Poster

Re: First Timer and trying to learn the basics (Please help me ASAP)

  #8  
Nov 9th, 2006
Originally Posted by Jamaican Beauty View Post
I took out the push's and pop's because they really didn't not have any effect on the code.
I got into the habbit of pushing all registers that I want to save before calling any interrups or functions because (1) general purpose registers ax, bx, cx and dx are subject to change without notice and (2) you don't know if the function or interrupt called will change them. Better safe then sorry.
Last edited by Ancient Dragon : Nov 9th, 2006 at 7:40 pm.
Reply With Quote  
Join Date: Nov 2006
Posts: 7
Reputation: Jamaican Beauty is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Jamaican Beauty Jamaican Beauty is offline Offline
Newbie Poster

Re: First Timer and trying to learn the basics (Please help me ASAP)

  #9  
Nov 13th, 2006
I understand that oh ok
Reply With Quote  
Join Date: Nov 2006
Posts: 7
Reputation: Jamaican Beauty is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Jamaican Beauty Jamaican Beauty is offline Offline
Newbie Poster

Re: First Timer and trying to learn the basics (Please help me ASAP)

  #10  
Dec 8th, 2006
Hey Ancient Dragon? How's it going?
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Assembly Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Assembly Forum

All times are GMT -4. The time now is 9:24 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC