A86: Code (again)
[Prev][Next][Index][Thread]
A86: Code (again)
For some reason, I guess I must just be dumb or something, but I can't figure
out how to just step through the program, because what's showing up in the
little window is nothing like my program.
My question this time is thus: The program properly displays the intro text,
and halts, then goes immediatley into a link error (on VTI) along with some
garbage. On Emu86, it just prints "Number is prime." then adds some
garbage...
Does anyone know why this is happening?
New source below:
Glen
tutorial1.cjb.net
#include "Ti86.inc"
.org _asm_exec_ram
nop
jp ProgStart
.dw 0
.dw ShellTitle
ShellTitle:
.db "Prime86 ASM",0
ProgStart:
call _clrLCD
call _homeup
ld hl,TX_STR
call _puts
call _newline
halt
ld hl,NUM_PRMPT
ld de,_ioprompt
ld bc,13
ldir
ld a,210
ld (N),a
xor a
ld (K),a
ld b,46
LOOP_START:
ld a,b
call Initial_Check
ld a,(A)
ld l,a
ld h,0
ld a,(I)
call _divHLbyA
cp 0
jp COMPOSITE
jr Initial_Check_2
Initial_Check:
ld hl,ntilde
ld e,a
ld d,0
add hl,de
ld a,(hl)
ld (I),a
ret
Initial_Check_2:
ld a,(N)
call _setxxOP1
call _FPSQUARE
call _convOP1
ld b,a
ld a,(A)
cp b
jp nc,PRIME
ld a,(A)
call _setxxOP1
call _SQROOT
call _convOP1
ld (J),a
ld b,46
LOOP_2_START:
ld a,b
push bc
ld a,(J)
ld b,a
call LOOP_3_START
pop bc
djnz LOOP_2_START
LOOP_3_START:
ld a,(I)
ld c,a
ld a,(K)
add a,c
call _setxxOP1
ld l,a
ld h,0
ld a,(A)
call _divHLbyA
cp 0
jp COMPOSITE
call SUB_B
ret
SUB_B:
ld a,b
push af
ld a,(N)
ld b,a
pop af
sub b
ld (J),a
ret
PRIME:
call _clrLCD
call _homeup
ld hl,PRIM_TEXT
call _puts
jp END_PROG
COMPOSITE:
ld a,(A)
ld b,a
call _convOP1
cp b
jp PRIME
call _clrLCD
call _homeup
ld hl,COMPOSITE_TEXT
call _puts
jp END_PROG
N:
.db 0
K:
.db 0
A:
.db 0
J:
.db 0
I:
.db 0
TX_STR:
.db "Prime86 ASM"
.db "v.1 by Darkness"
.db "Thanx STL,TL,JMO,ABK!",0
PRIM_TEXT:
.db "Number is prime.",0
COMPOSITE_TEXT:
.db "Number is not prime.",0
ntilde:
.db 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,209
NUM_PRMPT:
"Number: ",0
END_PROG:
.end