Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Cant get a loop to work!!

I am trying to write an assignmnet to print out a christmas tree, but I cant get a simple loop to work. I have attached the entrire code, some one must have a clue, because there is non this end!!
;----------------------------------
;Title: attemptStar.asm
;Author:
;Date:22/11/2004
;------------------------------------------------------
;attempt to get user name,height and character
;and to use a simple loop to print out the charctersfs
;-----------------------------------------------------
outputCh MACRO ;macro to get single character
MOV AH,02H ;2nd function
MOV DL,#1
INT 21H ;print
#EM ;end macro

USname MACRO ;macro to get user name
MOV AH,0AH ;function to take a string
LEA DX,#1 ;load address of the memory
INT 21H ;print
#EM

putstr MACRO ;macro for printing strings
LEA DX,#1 ;load address into DX register
MOV AH,09H ;function 9 of 21H
INT 21H ;print
#EM


clear MACRO ;macro for clearing the screen
MOV AX,03H
MOV AL,03H
INT 10H
#EM

cursor MACRO ;macro for placing the cursor
INC Row
DEC Column
MOV AH,02H
;MOV BH,00
MOV DH,#1 ;row
MOV DL,#1 ;column
INT 10H
#EM

symbol MACRO ;macro for getting the symbol entered
MOV AH,01H
INT 21H ;print
MOV #1,AL
#EM

printN MACRO ;macro for printing out the symbol
MOV AH,02H
MOV DL,#1
INT 21H
#EM

code_seg SEGMENT
ASSUME CS:code_seg,DS:Code_seg


ORG 0100H


Main: clear
putstr welcome ;welcome message
putstr space ;prints a space
putstr Uname ;asks for users name
USname name2 ;gets users name
putstr space
putstr Height ;message, ask for tree height
symbol Theight ;get high of tree
putstr space
putstr Tree ;ask what symbol user wants to use
symbol charct ;get symbol for drawing the tree
putstr space
MOV DL,00H
MOV CX,[Theight"B"] ;print symbol selected
Begin: printN charct ;this will only work if I set CX,05H
;or any other set amount
ADD DL,01H
SUB CX,01H
JNZ Begin

putstr space



INT 20H


;---------------------------------
;Define the data
;---------------------------------
welcome DB "Welcome, this thing might work","$"
Uname DB 0AH,0DH, "Enter your name ","$"
Height DB 0AH,0DH,10,13,"Enter the Height you would like your Xmas tree ","$"
Space DB 0AH,0DH,"","$"
Tree DB 0AH,0DH, "Enter the symbol you would like your tree drawn with " ,"$"
;yourH DB 0AH,0DH,"This was the height you chose ","$"
;--------------------------------------------------------
charct DB 1

name2 DB 30 DUP ("$")
Theight DB 1
Row DB 1
Column DB
;---------------------------------
Code_seg ENDS
END MAIN
;---------------------------------


Comments

  • shaolin007shaolin007 Member Posts: 1,018
    : I am trying to write an assignmnet to print out a christmas tree, but I cant get a simple loop to work. I have attached the entrire code, some one must have a clue, because there is non this end!!
    : ;----------------------------------
    : ;Title: attemptStar.asm
    : ;Author:
    : ;Date:22/11/2004
    : ;------------------------------------------------------
    : ;attempt to get user name,height and character
    : ;and to use a simple loop to print out the charctersfs
    : ;-----------------------------------------------------
    : outputCh MACRO ;macro to get single character
    : MOV AH,02H ;2nd function
    : MOV DL,#1
    : INT 21H ;print
    : #EM ;end macro
    [red]
    : USname MACRO ;macro to get user name
    : MOV AH,0AH ;function to take a string
    : LEA DX,#1 ;load address of the memory
    : INT 21H ;print
    : #EM
    [b]SEE BELOW[/b]
    [/red]
    : putstr MACRO ;macro for printing strings
    : LEA DX,#1 ;load address into DX register
    : MOV AH,09H ;function 9 of 21H
    : INT 21H ;print
    : #EM
    :
    :
    : clear MACRO ;macro for clearing the screen
    : MOV AX,03H
    : MOV AL,03H
    : INT 10H
    : #EM
    :
    : cursor MACRO ;macro for placing the cursor
    : INC Row
    : DEC Column
    : MOV AH,02H
    : ;MOV BH,00
    : MOV DH,#1 ;row
    : MOV DL,#1 ;column
    : INT 10H
    : #EM
    :
    : symbol MACRO ;macro for getting the symbol entered
    : MOV AH,01H
    : INT 21H ;print
    : MOV #1,AL
    : #EM
    :
    : printN MACRO ;macro for printing out the symbol
    : MOV AH,02H
    : MOV DL,#1
    : INT 21H
    : #EM
    :
    : code_seg SEGMENT
    : ASSUME CS:code_seg,DS:Code_seg
    :
    :
    : ORG 0100H
    :
    :
    : Main: clear
    : putstr welcome ;welcome message
    : putstr space ;prints a space
    : putstr Uname ;asks for users name
    : USname name2 ;gets users name
    : putstr space
    : putstr Height ;message, ask for tree height
    : symbol Theight ;get high of tree
    : putstr space
    : putstr Tree ;ask what symbol user wants to use
    : symbol charct ;get symbol for drawing the tree
    : putstr space
    : MOV DL,00H
    : MOV CX,[Theight"B"] ;print symbol selected
    : Begin: printN charct ;this will only work if I set CX,05H
    : ;or any other set amount
    : ADD DL,01H
    : SUB CX,01H
    : JNZ Begin
    :
    : putstr space
    :
    :
    :
    : INT 20H
    :
    :
    : ;---------------------------------
    : ;Define the data
    : ;---------------------------------
    : welcome DB "Welcome, this thing might work","$"
    : Uname DB 0AH,0DH, "Enter your name ","$"
    : Height DB 0AH,0DH,10,13,"Enter the Height you would like your Xmas tree ","$"
    : Space DB 0AH,0DH,"","$"
    : Tree DB 0AH,0DH, "Enter the symbol you would like your tree drawn with " ,"$"
    : ;yourH DB 0AH,0DH,"This was the height you chose ","$"
    : ;--------------------------------------------------------
    : charct DB 1
    :
    : name2 DB 30 DUP ("$")
    : Theight DB 1
    : Row DB 1
    : Column DB
    : ;---------------------------------
    : Code_seg ENDS
    : END MAIN
    : ;---------------------------------
    :
    :
    :

    [green]
    You need to define your buffer as follows.
    [/green]
    [code]
    name2 db 31 ;tells DOS that your buffer is 30 bytes long plus enter key
    db 0 ;set this to 0 for now
    db 31 dup(0) ;here is the actual buffer space
    [/code]

Sign In or Register to comment.