[A83] What's wrong with this code?


[Prev][Next][Index][Thread]

[A83] What's wrong with this code?




I hope there is someone who can tell me what's wrong with this code. It 
searches whether a number is a primenumber or not.

========================================================================

.NOLIST
#define end .end
#define END .end
#define equ .equ
#define EQU .equ
#include "squish.inc"
#include "ti83asm.inc"
#include "tokens.inc"
.LIST
.org $9327

call _runindicoff
call _clrlcdfull

input:
ld de,$821C                ;store destination for prompt in 'de'
ld hl,prompt               ;store startadress from prompt in 'hl'
ld bc,16                   ;store length of prompt in 'bc'
ldir                       ;get the prompt to it's destination
ld a,1                     ;store 1 in 'a', to indicate the input will be 
numerical
ld (asm_ind_call),a        ;store 1 in the indicator
call pgmio_exec            ;ask for input and store it in 'op1'
call _clrlcdfull           ;clear the screen
call _homeup               ;go to the top of the screen
call _trunc                ;get the integer part of the input, to prevent it 
from being a decimal number
call _op1toop3             ;store the input in 'op3'
call _op2set4              ;store 4 in 'op2'
call _cpop1op2             ;see if the input is less then 4 (1, 2 and 3 are 
primenumbers)
jp c,prime                 ;if 'op1' is less then 4 (so a primenumber), goto 
'prime'
call _op2set3              ;
ld hl,op1                  ;bla bla bla, you can think the rest by yourself, 
huh?

mainloop:
call _op3toop1
call _fpdiv
call _ckint
jp z,noprime
call _op2toop1
call _plus1
call _plus1
call _op1toop2
call _op3toop1
call _sqroot
call _cpop1op2
jp nc,mainloop

prime:
call _op3toop1
call _formdisp
ld hl,$0001
ld (pencol),hl
ld hl,primenumber
call _puts
ret

noprime:
call _op3toop1
call _formdisp
ld hl,$0700
ld (pencol),hl
ld hl,noprimenumber
call _vputs
ret

prompt:
.db "(Prime)number:  ",0

primenumber:
.db "is a primenumber",0

noprimenumber:
.db "is not a primenumber",0

.end
END

========================================================================

Well, that was it. There might be some minor errors, such as no chekking for 
unreal numbers or whatever...

Jelle Fresen

_________________________________________________________________
Chat on line met vrienden en probeer MSN Messenger uit: 
http://messenger.msn.nl




Follow-Ups: