assembly code

Trying to modify this assembly code using emu8086

Page 1 of 1

3 Replies - 4391 Views - Last Post: 25 February 2011 - 05:14 AM

#1 fatcat   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 13-August 09

assembly code

Post icon  Posted 06 December 2009 - 02:45 PM

Hello everyone, I'm trying modify this code so that a vertical line is displayed from coordinates (50, 50) - (50, 75) in addition to the horizontal line currently displayed by the code.


; video.asm
; uses interrupts to set video mode and draw a line

include 'emu8086.inc'

org  100h; set location counter to 100h

jmp CodeStart

DataStart:
	xStart dw 50	   ; x coordinate of line start
	yStart dw 50	   ; y coordinate of line start
	length dw 25	   ; length of line

CodeStart:

   ; set the video mode 320x200, 256 colors
	mov al, 13h
	mov ah, 0
	int 10h

   ; initialize cx (x coord) to xStart + length
	mov cx, xStart
	add cx, length

	
   ; loop from (xStart+length) to xStart to draw a horizontal line
	LoopStart:	

	   ; draw a pixel
	   ; set color in al, x in cx, y in dx
		mov al, 50
		mov dx, yStart
		
	   ; set sub function value in ah to draw a pixel
	   ; and invoke the interrupt
		mov ah, 0ch
		int 10h
		
	   ; decrement the x coord
		sub cx, 1
		
	   ; test to see if x coord has reached start value
		cmp cx, xStart
	
   ; continue loop if cx >= xStart
	jae LoopStart
	
	ret



** Edit ** :code:

Is This A Good Question/Topic? 0
  • +

Replies To: assembly code

#2 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6644
  • View blog
  • Posts: 30,937
  • Joined: 10-May 07

Re: assembly code

Posted 08 December 2009 - 07:12 PM

View Postfatcat, on 6 Dec, 2009 - 03:45 PM, said:

I'm trying modify this code


Can you provide some detail as to what isn't working?
Was This Post Helpful? 0
  • +
  • -

#3 ThePheonix21   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 54
  • Joined: 25-November 09

Re: assembly code

Posted 16 December 2009 - 08:19 PM

So, where is the list declaration of the microcontroller you are using? Are you using a PIC or some other brand? That's the first thing I see wrong. Another thing I see wrong is that you have your include file set wrong.
The include line should look something like this:
include "drive letter:filepath.inc"


Was This Post Helpful? -1
  • +
  • -

#4 Guest_Guest*


Reputation:

Re: assembly code

Posted 25 February 2011 - 05:14 AM

I ran your code in emu8086 and after some edits to get it to work ran fine with two probs.

Your Jae I changed to JNE and the normal return I altered to force a key press.
org  100h; set location counter to 100h  

 
 mov ah, 0h  ; Set video mode.
 mov al, 13h ; Use VGA (320x200x256) mode.
 int 10h     ; Call interrupt to complete the process.
	     
  	   
  	                             
  	   mov ax,0A000h  ;set the VGA base segment              
  	   mov es,ax      ;ES points to the video memory.                
  	   mov dx,03CEh   ;dx = indexregister                
  	   mov ax,0102h   ;INDEX = MASK MAP,                 
  	   out dx,ax      ;write all the bitplanes.                
  	   mov di,0       ;DI pointer in the video memory.                
  	  
  	   mov dx, 03C5h ;the palette data bytes will all go to this port                

  	   
 DataStart:  

     xStart dw 35       ; x coordinate of line start  

     yStart dw 60       ; y coordinate of line start  

     length dw 15       ; length of line 	   
  	   

    ; initialize cx (x coord) to xStart + length  

     mov cx, xStart + length  ; add cx, length

      

    

        

    ; loop from (xStart+length) to xStart to draw a horizontal line  

     LoopStart:    

    

        ; draw a pixel  

        ; x in cx, y in dx  

         mov al, 44h   ; set color in al yellow

         mov dx, xstart  

                   

        mov ah, 0ch    ; set sub function value in ah to draw a pixel
         
        int 10h      ; and invoke the interrupt

            

        ; decrement the x coord  

         sub cx, 1 
                  

        ; test to see if x coord has reached start value  

         cmp cx, xStart  

        

      

        jne LoopStart ; continue loop if cx not= xStart 

        mov ax, 0 ;finished, wait for the user	
  	 	int 16h    ;to press a key 	
  	 	mov ax, 3h ;before we go back into 80x25 16-color text mode	
  	 	int 10h	
  	 	ret


MOD EDIT: When posting code...USE CODE TAGS!!!

:code:

This post has been edited by JackOfAllTrades: 25 February 2011 - 05:36 AM

Was This Post Helpful? 1

Page 1 of 1