Omnimaga

Calculator Community => TI Calculators => ASM => Topic started by: stevon8ter on March 23, 2012, 09:57:50 am

Title: Ok, I'm a noob
Post by: stevon8ter on March 23, 2012, 09:57:50 am
Ok, here is what I tried:

Code: [Select]
.NOLIST
#define   EQU   .equ
#define   equ   .equ
#define   END   .end
#define   end   .end
#include "ti83plus.inc"
.LIST

     .org 9D93h
     .db $BB,$6D
StartProg:
Conditional:
      ld a,3
      cp 7
      jp z,IsSeven
      cp 3
      jp z,IsThree
      jp nz,IsNoneOfThese
IsSeven
ld a,0
      ld (CURCOL),a
      ld a,0
      ld (CURROW),a
      ld hl,txtHell
      B_CALL(_PutS)
      ret
txtHell:
.db "7",0
IsThree
 ld a,0
      ld (CURCOL),a
      ld a,0
      ld (CURROW),a
      ld hl,txtHel
      B_CALL(_PutS)
      ret
txtHel:
.db "3",0
IsNoneOfThese
 ld a,0
      ld (CURCOL),a
      ld a,0
      ld (CURROW),a
      ld hl,txtHello
      B_CALL(_PutS)
      ret
txtHello:
      .db "Hello World",0
.end

and it didn't work, so i also tried this:

Code: [Select]
.NOLIST
#define   EQU   .equ
#define   equ   .equ
#define   END   .end
#define   end   .end
#include "ti83plus.inc"
.LIST

     .org 9D93h
     .db $BB,$6D
StartProg:
Conditional:
      ld a,3
      cp 7
      jp z,IsSeven
      cp 3
      jp z,IsThree
      jp nz,IsNoneOfThese
IsSeven
ld a,0
      ld (CURCOL),a
      ld a,0
      ld (CURROW),a
      ld hl,txtHell
      B_CALL(_PutS)
      ret
IsThree
 ld a,0
      ld (CURCOL),a
      ld a,0
      ld (CURROW),a
      ld hl,txtHel
      B_CALL(_PutS)
      ret
IsNoneOfThese
 ld a,0
      ld (CURCOL),a
      ld a,0
      ld (CURROW),a
      ld hl,txtHello
      B_CALL(_PutS)
      ret
txtHello:
      .db "Hello World",0
txtHel:
.db "3",0
txtHell:
.db "7",0
.end

TASM (i haven't tried with the doors CS DSK) always gives an error: unknow command: B_CALL(_PutS)
Title: Re: Ok, I'm a noob
Post by: Xeda112358 on March 23, 2012, 10:16:40 am
Try adding this:
Code: [Select]
#define   B_CALL(xxxx)    .db $EF \ .dw xxxx
Title: Re: Ok, I'm a noob
Post by: stevon8ter on March 23, 2012, 10:21:18 am
Ok, I'll try, and does it has to be in the TI83 inc file or in the sourcefile?

Ok, i've put it in the included file, my conclusion: it was there, but in b_call en not B_CALL :P
Title: Re: Ok, I'm a noob
Post by: Xeda112358 on March 23, 2012, 10:24:59 am
It can be in either :)
Title: Re: Ok, I'm a noob
Post by: stevon8ter on March 23, 2012, 10:51:32 am
Ok, and what if I wanted an user-input that asks for a number? What B_CALL should it be? Or is it something else?

Ok, in asmin28days, they're talking about this

Code: [Select]
.module    ConvDec8
ConvDec8:
    LD    C, 0

_Loop:
    CALL  GetChar
    CCF             ; End if no more characters
    RET   NC

    SUB   '0'       ; Throw out all characters below '0'
    JR    C, _Check

    CP    10        ; Throw out all characters above '9'
    CCF
    RET   C

    LD    D, A       ; Save value in D
    LD    A, C       ; Load running total
    CP    26        ; Halt if there would be an overflow (260+)
    JP    NC, Ungetc ; Return gotten character

    LD    E, C       ; Save current number in case of overflow
    ADD   A, A       ; Multiply by 10
    ADD   A, A
    ADD   A, C
    ADD   A, A
    ADD   A, D       ; Add gotten character

    LD    C, A       ; Halt if overflow (256 to 259)
    JR    NC, _Loop

    LD    C, E
    JP    Ungetc

_Check:
    CP    ' ' - '0' ; If a space is encountered exit without error
    RET   Z
    SCF
    RET


but in what register is it saved?

Ans I get an error: with : GetChar  and  Ungetc
Title: Re: Ok, I'm a noob
Post by: Xeda112358 on March 23, 2012, 10:58:47 am
XD It isn't usually that easy to do in assembly XD

As for the routine, that converts a string of tokens to a number and stores it to register a (it isn't an input routine). If I have time later, I will write some code for an input routine, but it is not too simple.

Also, avoid double-posting unless it has been about a day and your question wasn't answered (you can just use the edit button).
:D

EDIT: Those calls aren't there in your code, that is why you get an error
Title: Re: Ok, I'm a noob
Post by: stevon8ter on March 23, 2012, 11:02:16 am
Ok, thanks, but as I allready mentioned, I'm a N00B :P

But I'll try to do the whole 28days.

But usually I like it to get a bunch of examples and then some explanation with it.

Like in this one http://www.arasian.com/support/education/tutorial&t=2&s=9 (http://www.arasian.com/support/education/tutorial&t=2&s=9)

Euhm, guys, what's the best vti to use to test my progs?


Euhm, other question: why does this gives a RAM clear?
Code: [Select]
.NOLIST
#define   EQU   .equ
#define   equ   .equ
#define   END   .end
#define   end   .end
#include "ti83plus.inc"
.LIST

     .org 9D93h
     .db $BB,$6D
StartProg:
B_CALL(_ClrLCDFull)

GetKeyLoop:
     B_CALL(_GetKey)
     cp k1
     jp z,Numb1
     cp k3
     jp z,Numb3
     cp k7
     jp z,Numb7
     jp GetKeyLoop

Conditional:
      cp 7
      jp z,IsSeven
      cp 3
      jp z,IsThree
      jp nz,IsNoneOfThese

IsSeven
ld a,0
      ld (CURCOL),a
      ld a,0
      ld (CURROW),a
      ld hl,txtHell
      B_CALL(_PutS)
      ret

IsThree
 ld a,0
      ld (CURCOL),a
      ld a,0
      ld (CURROW),a
      ld hl,txtHel
      B_CALL(_PutS)
      ret

IsNoneOfThese
 ld a,0
      ld (CURCOL),a
      ld a,0
      ld (CURROW),a
      ld hl,txtHello
      B_CALL(_PutS)
      ret

txtHell:
.db "7",0

txtHel:
.db "3",0

txtHello:
      .db "Hello World",0

Numb1:
ld a,1

Numb3:
ld a,3

Numb7:
ld a,7

.end
Title: Re: Ok, I'm a noob
Post by: calcdude84se on March 23, 2012, 12:49:23 pm
When the processor jumps to Numb1, Numb3, or Numb7, it will load A with the appropriate number, but it will continue, not only to the next LD (if there is one), but also past the end of the program. At that point, it's no longer your code that's executing, and the processor's going to encounter something that leads it to crash.
Title: Re: Ok, I'm a noob
Post by: stevon8ter on March 23, 2012, 02:02:07 pm
Do you have any tips to fix it?

and what if I place a jump to conditions after the 3 ld's?

It worked :P
Title: Re: Ok, I'm a noob
Post by: Scipi on March 23, 2012, 02:42:45 pm
You could have a jump back to the conditions (I don't remember much from HotDog's tutorials, but I think you could also just place a ret after each so it automatically returns to where it was before)

Unless I'm thinking of something different...
Title: Re: Ok, I'm a noob
Post by: C0deH4cker on March 23, 2012, 06:14:45 pm
You could have a jump back to the conditions (I don't remember much from HotDog's tutorials, but I think you could also just place a ret after each so it automatically returns to where it was before)

Unless I'm thinking of something different...
yeah, basically just add a ret after each of the ld cmds, but make sure to use call instead of jp.
Title: Re: Ok, I'm a noob
Post by: stevon8ter on March 25, 2012, 10:36:14 am
Yeah, with the script I posted it only worked with another jp to the conditionals
Title: Re: Ok, I'm a noob
Post by: Xeda112358 on March 25, 2012, 11:24:30 am
***This does not have anything to do with your code above!***
Here is some example code you can play with:
Code: [Select]
;Get the value in Ans
     B_CALL(_RclAns)  ;Ans→OP1
     B_CALL(_ConvOP1) ;OP1 converted to DE, E→A

;At ths point, A contains the value of Ans

     ld hl,37         ;37→HL
     cp 13            ;If A=13
     call z,SetHLto4  ;Then call the routine
     cp 7             ;If A=7
     call z,SetHLto11 ;Then call the routine
     B_CALL(_DispHL)
     ret
;======
SetHLto4:
     ld hl,4         ;4→HL
     ret             ;Return
SetHLto11:
     ld hl,11        ;11→HL
     ret             ;Return     
Does this help at all?
Title: Re: Ok, I'm a noob
Post by: calcdude84se on March 25, 2012, 11:57:09 am
yeah, basically just add a ret after each of the ld cmds, but make sure to use call instead of jp.
In this case that wouldn't work because he doesn't want to return back to where he was, but rather jump to Conditional.
stevon8ter: your code, as it stands, converts keypresses to values, and uses those values to determine what code to execute. In this case, it would make much more sense just to use the keypresses directly to determine where to jump to execute the other code. (That is, Numb1 etc. and Conditional are unnecessary. IsSeven etc. should be jumped to directly from GetKeyLoop.)
Title: Re: Ok, I'm a noob
Post by: stevon8ter on March 27, 2012, 08:56:12 am
To all of you: thank you, and I'll be a long time offline :( going on vacation and have there no intenet.

And xeda: I thank you very much, I like the way you do it, givin an example and I can learn out of it, all people may do that :P
And sometimes i'll ask for an expelnation
Title: Re: Ok, I'm a noob
Post by: Xeda112358 on March 27, 2012, 02:47:19 pm
Cool :) I started a tutorial a long time ago (that I never finished). It had a similar style, but it was aimed at BASIC programmer learning to program in hex/assembly. Here is an example from it:
Code: [Select]

-------------------------------------------------------------------
Experiment 4  Memory Editing (v.1)
-------------------------------------------------------------------
214093 ;ld hl,plotSScreen ;9340h is the address* of the graph screen buffer*
3EAA ;ld a,$AA ;$AA→a Feel free to change the "AA"
77 ;ld (hl),a ;a→(hl) This stores the value of "a" to the address at "hl"
23 ;inc hl ;hl+1→hl
77 ;ld (hl),a ;same as before
C9 ;ret ;Stop

To Use:
Simply run the program. This will edit the top left corner of the
graph screen.

Explanations:
 Address- People can send you mail from anywhere because they know
your address. Your address tells where you are. Similarly, in
assembly, an address tells where each byte of memory is. Using a
hex number between 8000h and FFFFh will give you access to the RAM
(which can be edited). This is the address. It just so happens
that the graph screen has all of its data stored at address 9340h
There are 768 bytes of data for the screen and 768=0300h. So
plotSScreen (Plot Save Screen) is 9340h to 963Fh. Whenever you see
(), whatever is inside the parentheses is the address. If you see:
        ld (xx),y
"y" is being stored at address "xx" and if you see this:
        ld y,(xx)
Then the value at address "xx" is stored to y

PlotSScreen-The way the data is set up is that each byte is 8
pixels. If the value is 3Eh, then in binary it is 00111110. All of
the 1's are dark pixels and all of the 0's are light pixels. These
are stored in rows, so there are 12 bytes per row (96/8=12). With
64 rows, there is 768 bytes in plotSScreen (12*64=768).

That is the most complicated one out of the four sections finished (I planned to have 25 to 50, but then I never finished).
Title: Re: Ok, I'm a noob
Post by: stevon8ter on March 28, 2012, 02:19:32 pm
Ok, you should really finish that tutorial, or give me all you have untill now :P
Title: Re: Ok, I'm a noob
Post by: stevon8ter on March 29, 2012, 12:34:03 pm
I'm really meaning it, you should finish it, it's explicated very very well.
I'm leaving tommorow on vacation so I won't be able to answer on this topic (and others) for about a week and a half.
Title: Re: Ok, I'm a noob
Post by: Xeda112358 on March 29, 2012, 09:19:49 pm
Okay, next week I don't have much work, so I can try :) Thank you!
Title: Re: Ok, I'm a noob
Post by: stevon8ter on May 18, 2012, 04:55:42 pm
Ok first i wanna apologise for being offline much to long

Second: are u making any progresses on the tutotial, just asking, don't need it really soon so take it easy ;)

Third: is there an ipod app to create and test asm progs?
Title: Re: Ok, I'm a noob
Post by: Xeda112358 on August 29, 2012, 12:44:28 pm
Sorry, I haven't had much time at all to work on this stuff :/