Omnimaga
Calculator Community => TI Calculators => ASM => Topic started by: TiAddict on May 31, 2011, 01:43:16 pm
-
Can someone show me a program that will count 1~1000 really fast?
i tried like this, but it wont work.
Start:
Bcall ClrScrnFull
Bcall HomeUp
Count:
ld hl,(number)
ld de,(check)
or a
push hl
sbc hl,de
ret z
pop hl
inc hl
bcall dispHL
ld (num),hl
jp count
number:
db 0
check:
db 1000
And the mimas gives me an "out of range" error when i try to compile. and i changed the db to dw, and it worked, but it wont count.
Please detailed explanation :D
Edit: oh yea i just noticed that when i use sbc, it will make hl equal to negative.. i dont know how to fix that.
-
LD BC,1000
@
LD HL,BC
B_CALL(_DispHL)
DEC BC
JP PE,{-1@}
@
RET
iirc that should work decently. :)
-
:o
it gives me error that LD HL,BC is invalid.
i think i should try like this:
LD H,C
LD L,B
-
:o
it gives me error that LD HL,BC is invalid.
i think i should try like this:
LD H,C
LD L,B
Other way around. You want the value in B to go to H and likewise C to L, so: LD H,B and LD L,C.
-
bcall(_dispHL) destroys HL. So store HL back into (num) before you call it. For the most part, you should usually assume that a bcall will destroy all your registers.
-
thank you! :D
-
push hl
sbc hl,de
ret z
pop hl
This could be disastrous! If you return after you pushed hl, the top of the stack contains the number hl instead of the return address so the program will jump to some random place in memory. You should only return after the stack is back to where it was before:
push hl
sbc hl,de
pop hl
ret z
-
oh. Thanks Quigibo :D. and can someone show me a code to convert program to sting? (program name in str0, converts to string 1)