3 Replies - 2373 Views - Last Post: 06 September 2012 - 10:12 PM

#1 portb2  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 12-June 12

Problem checking if number is multiple of 5

Posted 17 June 2012 - 12:50 AM

ORG $2000
Array DC.B 5,8,9,25
result DS.B 1
count DC.B 4
ORG $8000
LDS #$4000
LDAA #4
LDX #Array
JSR Division
STAA result
back BRA back

Division CLRA
LDD #Array
LDX #$5
IDIV
CMPD #0
BEQ result
BRA notmult
INC result
notmult INX
DEC count
BNE Division


*** Edit ***
Changed topic title. Please use a descriptive topic title and put your question in the post.

This post has been edited by GunnerInc: 17 June 2012 - 07:37 AM
Reason for edit:: Added code tags and moved to Assembly

Is This A Good Question/Topic? 0
  • +

Replies To: Problem checking if number is multiple of 5

#2 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,282
  • Joined: 28-March 11

Re: Problem checking if number is multiple of 5

Posted 17 June 2012 - 07:45 AM

So what exactly is your problem? What errors are you getting? What output are you expecting and what are you receiving?

Your on the right track:
Load number from array (Not sure if you are doing it correctly)
divide that number by 5
check the remainder and if 0 then it is a multiple of 5, otherwise it is not.

Does LDD increment the array pointer every time you use it? If not, then you need to increment your array pointer each loop iteration until the end of array.
Was This Post Helpful? 0
  • +
  • -

#3 turboscrew  Icon User is offline

  • D.I.C Addict

Reputation: 100
  • View blog
  • Posts: 619
  • Joined: 03-April 12

Re: Problem checking if number is multiple of 5

Posted 04 September 2012 - 07:17 AM

Better late than never?

This looks a lot like old Motorola assembly (680x-series) or
6502.

I think

Quote

LDD #Array

means: load to register (D) immediate the value of symbol "Array".
Was This Post Helpful? 0
  • +
  • -

#4 turboscrew  Icon User is offline

  • D.I.C Addict

Reputation: 100
  • View blog
  • Posts: 619
  • Joined: 03-April 12

Re: Problem checking if number is multiple of 5

Posted 06 September 2012 - 10:12 PM

Aha, 68HC11?

Why would someone jump to the data address (BEQ result)?
Also, the subroutine doesn't seem to return (no RTS).
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1