EASy68K  
It is currently Sun Sep 22, 2019 8:43 am

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Loop that doesn't loop
PostPosted: Sun Sep 01, 2019 9:53 am 
Offline

Joined: Sun Sep 01, 2019 9:41 am
Posts: 1
I've set out a task for myself to write a program that asks the user to input a number and then prints is the number bigger or smaller than zero. If the user inputs 0, program terminates.

At the moment, program does what I intended to do, but only once. It doesn't loop.

Can anyone point out why is this happening?

This is the code I wrote:

Code:
ORG $1000   

   START:
   
   nextNumber:
        jsr printIntroText
        jsr numberIn
       
        move.l d1, d5           *D5 holds the entered number
       
        cmp #0, d5
        beq endProgram
       
        jsr newLine
        jsr printFirstPart
       
        move.l d5,d1
        jsr numberOut

        cmp #0, d5
        blt printIsSmaller
        bge printIsBigger

        jsr newLine

        bra nextNumber
       
   endProgram:
       
   SIMHALT
                       
   charOut:
        move.b #6, d0
        trap #15
        rts

   newLine:
        move.b #$0A, d1
        jsr charOut
        move.b #$0D, d1
        jsr charOut
        rts
   
   numberIn:
        move.b #4, d0
        trap #15
        rts
       
   numberOut:
        move.b #3, d0
        trap #15
        rts

**********STRING CONSTANTS       
numEnter:
        dc.l    'Enter number:',0
       
numberString:
        dc.l    'The number ',0
       
isBigger:
        dc.l    ' is bigger than zero.',0
       
isSmaller:
        dc.l    ' is smaller than zero.',0

**********PRINT STRINGS     
printIntroText:
        lea numEnter, a1
        move.b #14, d0
        trap #15
        rts
       
printFirstPart:
        lea numberString, a1
        move.b #14, d0
        trap #15
        rts
       
printIsSmaller:
        lea isSmaller, a1
        move.b #14, d0
        trap #15
        rts
       
printIsBigger:
        lea isBigger, a1
        move.b #14, d0
        trap #15
        rts   

   END    START       



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

All times are UTC


Who is online

Users browsing this forum: No registered users and 5 guests


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:  
cron
Powered by phpBB® Forum Software © phpBB Group