Results 1 to 7 of 7

Thread: help needed on registers!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2004
    Location
    Some where on Earth
    Posts
    98

    help needed on registers!

    Hi guys!
    I found out a problem in my assembly that i cant push a 8 bit register into the stack. i dont know why buy please do have a look at the code below

    Code:
    DrawBox proc
                  
                    mov bx,0
                    mov dl,79
                    mov al,num[bx]
                    sub dl,al            
                    
                    add cx,dl           ;<----Problem here
                    push cx
                    
                    call PointCursor
                    pop ax
                    
                    mov ah,09h
                    mov bh,00h
                    mov al,20h
                    mov cx,10D
                    mov bl,20h
                    int 10h
    
                    ret
    
    DrawBox endp
    i tried to 'add cx,dl' to change it to 16 bit but failed. Can any 1 please do help me with this register problem. i just need to push the correct value i minus into the stack without error. Thanks!!
    Anime is what i LIVE for, BREATH for, and DIE for!

  2. #2
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: help needed on registers!

    Not sure I completely understand what you're trying to do. But:
    Code:
    mov cl,dl
    mov ch,dh
    push cx
    ?

    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2004
    Location
    Some where on Earth
    Posts
    98

    Re: help needed on registers!

    Hi «°°phReAk°°»

    Thanks for your reply. I've found out what's the problem already. Thanks!
    Anime is what i LIVE for, BREATH for, and DIE for!

  4. #4
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: help needed on registers!

    Mind showing the solution to us? I'd like to know exactly what you meant..

    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2004
    Location
    Some where on Earth
    Posts
    98

    Re: help needed on registers!

    sure! here is the code
    Code:
    DrawMiddleBox proc
    
    					push bx
    					mov bx,00h
    					mov bl,num[bx]
    					call PointCursor2
    					pop ax
    
    					mov bx,2
    					mov cl,num[bx]		;move the height coordinate into cl
    					mov dl,num[bx]		;move the height coordinate into bl
    					mov bx,0			;get the inputed value from user
    					add dl,num[bx]		;plus the height coordinate with the value inputed
    					mov num1[1],dl		;temp storage
    
    					mov num1[0],cl
    
    				DrawLoop:				;loop again to draw the next line
    						mov bx,0
    						mov al,num[bx]	;draw the number of boxes needed
    						mov ah,0
    
    						mov cx,ax
    						mov ah,09h
    						mov bh,00h
    						mov al,20h
    						
    						mov bl,00h
    						int 10h
    
    					add num1[0],1				;increment cl by 1
    					
    					call PointCursor3
    					mov cl,num1[0]
    					mov dl,num1[1]
    					cmp cl,dl
    					jl DrawLoop		;jump back loop if cl is smaller or equal to bl
    										
    					ret
    
    DrawMiddleBox endp
    my code is abit complicated to understand. But i've made alot of changes to my code from the 1st code i've posted. I used an array to store my values 1st becore pushing any value to the stack.
    Hope you understand what im trying to do. hehe
    Anime is what i LIVE for, BREATH for, and DIE for!

  6. #6
    Hyperactive Member Maven's Avatar
    Join Date
    Feb 2003
    Location
    Greeneville, TN
    Posts
    322

    Re: help needed on registers!

    Quote Originally Posted by RedDevil
    sure! here is the code
    Code:
    DrawMiddleBox proc
    
    					push bx
    					mov bx,00h
    					mov bl,num[bx]
    					call PointCursor2
    					pop ax
    
    					mov bx,2
    					mov cl,num[bx]		;move the height coordinate into cl
    					mov dl,num[bx]		;move the height coordinate into bl
    					mov bx,0			;get the inputed value from user
    					add dl,num[bx]		;plus the height coordinate with the value inputed
    					mov num1[1],dl		;temp storage
    
    					mov num1[0],cl
    
    				DrawLoop:				;loop again to draw the next line
    						mov bx,0
    						mov al,num[bx]	;draw the number of boxes needed
    						mov ah,0
    
    						mov cx,ax
    						mov ah,09h
    						mov bh,00h
    						mov al,20h
    						
    						mov bl,00h
    						int 10h
    
    					add num1[0],1				;increment cl by 1
    					
    					call PointCursor3
    					mov cl,num1[0]
    					mov dl,num1[1]
    					cmp cl,dl
    					jl DrawLoop		;jump back loop if cl is smaller or equal to bl
    										
    					ret
    
    DrawMiddleBox endp
    my code is abit complicated to understand. But i've made alot of changes to my code from the 1st code i've posted. I used an array to store my values 1st becore pushing any value to the stack.
    Hope you understand what im trying to do. hehe

    I noticed two things really about you're code. The first one was you move 0 to a register in order to clear it out. My advice to you is to use xor instead.

    Instead of saying mov bx, 00h, say: xor bx, bx. It will set everything to 0 and also clear any dependencies that the register has.

    I also don't see any real reason to push anything onto the stack. So why not just say mov ax, bx instead of using push and pop.
    Education is an admirable thing, but it is well to remember from time to time that nothing that is worth knowing can be taught. - Oscar Wilde

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Aug 2004
    Location
    Some where on Earth
    Posts
    98

    Re: help needed on registers!

    Hi Maven!

    Thanks for your opinion! I'm still very n00b at assembly and still learning. I'll take your advice and see what changes i need to do. Thanks again!
    Anime is what i LIVE for, BREATH for, and DIE for!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width