EASy68K  
It is currently Thu Aug 17, 2017 3:24 pm

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Position cursor
PostPosted: Sat Jun 10, 2017 3:58 am 
Offline

Joined: Sat Jun 10, 2017 3:49 am
Posts: 6
For a school project I need to create a program that does the following; Write a code segment that places a text string starting at the screen coordinates 25,15 (X,Y). Try modifying this code to repeatedly place a text string one line lower and one character to the right.

Begin
X = 25
Y = 15

Place cursor at 25,15
Print text string

While (X <= 30 and Y <= 20)
Print text string
X = X + 1
Y = Y + 1

Print Done message

This is what I have done so far, the only problem that I have is to be able to move the cursor position. When I input my x and Y, my cursor only moves in the row line and not in the column line.

Code:
Begin     
        move.w    #$2500,d1
        move.b    #$15,d1
        bsr     cursor
        lea     prompt6,a1
        bsr     print_string
        add.b  #$1,d1
        bra Begin
While
        cmp.w     #$3000,d1
        BLE       AND
        bra       done
AND
        *move.b    #$15,d1
        CMP.b     #$20,d1
        ble     message
        bra     done
       
       
message
          lea     prompt7,a1      * This is the number entered for variable A
          bsr     print_string
          *move.w  #$ff00,d1
          *bsr     cursor
          bra     addition   
Done
             
          lea     prompt8,a1      * This is the number entered for variable A
          bsr     print_string

addition
          add.w  #$100,d1
          add.b  #$1,d1
          bra    While

cursor
        movem.l d0-d7/a0-a6,-(sp)    * save registers
        move    #curs,d0             * place cursor     
        trap    #15                  * trap for I/O
        movem.l (sp)+,d0-d7/a0-a6    * restore registers
        rts


Top
 Profile  
 
 Post subject: Re: Position cursor
PostPosted: Sat Jun 10, 2017 12:00 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1044
Try to avoid using the BRA instruction, use structured loops instead (WHILE, FOR, REPEAT) it makes the code much easier to read and debug.

COMMENTS, COMMENTS, COMMENTS.

The first 'bra Begin' creates an infinite loop.

_________________
Prof. Kelly


Top
 Profile  
 
 Post subject: Re: Position cursor
PostPosted: Sat Jun 10, 2017 1:14 pm 
Offline

Joined: Sat Jun 10, 2017 3:49 am
Posts: 6
The bra A was something I was trying to make my cursor change position but was not supposed to be in my program.My cursor only moves down, it doesn't move to the right. How can I make my cursor move to the right and at the same time going down a row?


Top
 Profile  
 
 Post subject: Re: Position cursor
PostPosted: Sat Jun 10, 2017 1:47 pm 
Offline

Joined: Sat Jun 10, 2017 3:49 am
Posts: 6
Can someone give me an example of how to move the cursor position on the X axis?


Top
 Profile  
 
 Post subject: Re: Position cursor
PostPosted: Sat Jun 10, 2017 9:53 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1044
Code:
*-----------------------------------------------------------
* Title      : Demo of Trap Task #11, Cursor Position
* Written by : Charles Kelly
* Date       : June-10-2017
* Description: Moves the cursor and displays some text.
*-----------------------------------------------------------
    ORG    $1000
START:
    * The high byte of D1.W holds the COL number (0-255).
    * The low byte of D1.W holds the ROW number (0-128).
    * 0,0 is top left.
    move.b  #11,D0      ; Cursor Position trap task.
    move.w  #$0A0A,D1   ; Column 10, Row 10.
    trap    #15         ; Move cursor.
    move.b  #6,D0       ; Display ASCII character from D1.b
    move.b  #'A',D1     ; Letter 'A'
    trap    #15         ; Display char
    move.b  #23,D0      ; Delay n/100 second. D1.L = n
    move.l  #100,D1     ; 1 second delay
    trap    #15         ; Perform delay
   
    move.b  #11,D0      ; Cursor Position trap task.
    move.w  #$140A,D1   ; Column 20, Row 10.
    trap    #15         ; Move cursor.
    move.b  #6,D0       ; Display ASCII character from D1.b
    move.b  #'B',D1     ; Letter 'B'
    trap    #15         ; Display char
    move.b  #23,D0      ; Delay n/100 second. D1.L = n
    move.l  #100,D1     ; 1 second delay
    trap    #15         ; Perform delay

    move.b  #11,D0      ; Cursor Position trap task.
    move.w  #$1414,D1   ; Column 20, Row 20.
    trap    #15         ; Move cursor.
    move.b  #6,D0       ; Display ASCII character from D1.b
    move.b  #'C',D1     ; Letter 'C'
    trap    #15         ; Display char
    move.b  #23,D0      ; Delay n/100 second. D1.L = n
    move.l  #100,D1     ; 1 second delay
    trap    #15         ; Perform delay

    move.b  #11,D0      ; Cursor Position trap task.
    move.w  #$0A14,D1   ; Column 10, Row 20.
    trap    #15         ; Move cursor.
    move.b  #6,D0       ; Display ASCII character from D1.b
    move.b  #'D',D1     ; Letter 'D'
    trap    #15         ; Display char
    move.b  #23,D0      ; Delay n/100 second. D1.L = n
    move.l  #100,D1     ; 1 second delay
    trap    #15         ; Perform delay

    * Clear screen
    move.b  #11,D0      ; Clear screen
    move.w  #$FF00,D1
    trap    #15         ; Perform clear
   
    bra     START       ; <<<<< INFINITE LOOP >>>>>   

    SIMHALT             ; halt simulator

* Variables and constants

    END    START        ; last line of source

_________________
Prof. Kelly


Top
 Profile  
 
 Post subject: Re: Position cursor
PostPosted: Sun Jun 11, 2017 1:22 am 
Offline

Joined: Sat Jun 10, 2017 3:49 am
Posts: 6
Thank you very much !!!!!!


Top
 Profile  
 
 Post subject: Re: Position cursor
PostPosted: Sun Jun 11, 2017 5:28 am 
Offline

Joined: Sat Jun 10, 2017 3:49 am
Posts: 6
What do I need to do if I wanna print a string of letter starting at that cursor position?


Top
 Profile  
 
 Post subject: Re: Position cursor
PostPosted: Sun Jun 11, 2017 4:14 pm 
Offline

Joined: Sat Jun 10, 2017 3:49 am
Posts: 6
I did figure it out thank you everything


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group