Re: A83: learned asm


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

Re: A83: learned asm




Okay, here goes...


On Sat, 4 Apr 1998 smithrh@esper.com wrote:

> 
> I have combed the web for all the asm journals I can find. It's been
> months. Now, I want to learn. I have compiled a program before that I
> copied word for word, it just cleared the screen. I was wondering if you
> guys could help me with the errors in my program. It looks like this:
> 
> .NOLIST
> #define equ.equ
> #define EQU.equ
> #define end.end
> #include "ti83asm.inc"
> #include "tokens.inc"
> LIST

.LIST (w/period in front)

> .org 9327h
> 
> 	call _runIndicOff : do i need to describe the org or whatever numbers in
> .NOLIST                                 using #define
> 	call _clrLCDFull
> 	ld a,0
> 	ld (penrow),a
> 	ld a,0
> 	ld (pencol),a
> 	ld hl,hello

Alright, first things first, you're missing the function to actually draw 
the stuff @ hello to screen.  See, what you're doing is loading the 
address where the message is at (hello:) and storing it into hl.  Then, 
there;s a function called _puts that displays the string (which starts at 
whatever address you stored into hl, which in this case is hello:, and 
goes until it finds a terminating zero.) onto the screen in the big, 5x7 
font that you usually see on the home screen of the calc (when in 
regular TIOS/TI_BASIC mode) at location currow,curcol.  However, you can 
also use the func _vputs which displays the other 3x5 fonts that you 
usually see on the graph screen, at penrow,pencol.
Here, let me clarify this with an example:

ld a,0
ld (penrow),0
ld (pencol),0  	;a is already 0 so you don't need another ld a,0
ld hl,input	;this stores the starting address of the message/string 
		;in hl
call _vputs	;displays the string @ hl until  it hits that zero at the 
		;end of the .db
ret		;this is the end of the program

hello:
	.db "HI, ladedadada",00

Noe, If you'll notice, the .db stuff is tagged onto the end of the 
program, after the last ret (usually).  If you would've left it in the 
middle of the program like you had it then when you calc runs it and it's 
goind through all the ld and call commands and then finds this heap of 
funky funky commands (actually the ASCII codes for each letter in your 
message), it crashes.  See, it looks at those numbers and thinks that 
it's just a regular command address and tries to run it/execute it and 
then crashes cuz it's probably trying to ld a,hl, call ldir, and whatever.
See, I don't know if you've realized the concept that it's all just a 
bunch of addresses and bytes.  See all the commands you type in like ld, 
call, etc are actually just names that correspond to the not-so-easy to 
remember addresses.  So, when you type in call _clrLCDfull, TASM compiles 
it and it looks like  CD5547 (or something like that) CD = call and 
4755=_clrLCDfull (also remember that this is ALL in hexadecimal!).  Then 
when the calc comes across it it executes whatever builtin cammand it has 
at address CD (which in this case is call) and call then looks for the 
builtin function at address location 4755h (the h means hexadecimal), 
which in this case is _clrLCDfull.  See?
Whew!  


> hello:
> 	.db "Hi, this is an assembly program"
> 	.db "Nat wrote!"   : used to have my name :)
> 	call _clrLCDFull   : clear screen again
>         jp nat             : goto the label nat
> nat:
> 	.db 00000000b          : This is something i saw in a journal, it seems to
>                                  compile fine. It is supposed to display an
> 8x8 block
> 	.db 01100110b
> 	.db 00000000b
> 	.db 01000001b
> 	.db 00100010b
> 	.db 00011100b
> 	.db 00000000b
> 	.db 00111110b
> 	jp end                : goto end
> end:
> 	.db "I hope you are impressed." 
> 	.db "I wrote this with my Ti-92."
> 	ret
> .end
> End
>

TI-92?
NEwayze, the way you wrote this makes it seem like you think that 
whatever you type into the program just flat out (like .db "hi yadda 
yadda" and .db 10000001%) wil just magically appear on the screen; NO!  
you need certain functions to display them on the screen...
 
> When it compiled it ran through tokens.inc and ti83asm.inc for some reason.

the inc files are the tables that TASM uses to connect the name 
_clrLCDfull with 4755h, etc.

> Then gave me like 3000 errors and some errors about no label for line 10
> and others. As well as stuff about unused MS stuff. I'm not sure my
> computer's about to crash. :) not kidding

The '3000' erros probably came from the .inc files.  Don't worry about 
those, they're just fine!  What you need to change is in your program.  
basically, when you have the define EQU.equ stuff, make sure you use 
spaces!  Like so:
#define equ .equ
#define EQU .equ

what that does is tell TASM that everytime it sees EQU it should treat it 
like it says .equ (which means equate, or =) cuz in the inc files, you'd 
see stuff like 
_clrLCDfull	EQU	4755h


> I tried to fix it by turning it into this:
> 
> .NOLIST
> #define equ.equ
> #define EQU.equ
> #define end.end
> #include "ti83asm.inc"
> #include "tokens.inc"
> LIST
> .org 9327h
> 
> 
> 	call _clrLCDFull
> 	.db "Hi, this is an assembly program"
> 	.db "Nathan Smith wrote!"
> 	ret
> .end
> End

See, there you go again.  Just placing the stuff/strings there in the 
middle of the program doesn't mean that it'll plop it onto the screen!  
You need functions to do it!  Like _puts or _vputs...

> It said that this program was not ti-83 specific and line 0000: No END
> directive before EOF. I guess not being ti-83 specific could be a good
> thing, i don't know.

the END thing means that you should put a few spaces/returns after the 
last End cuz for some reason TASM bitches at you if you don't, as you've 
found out.

> 
> Help would be great, I have a burning desire to start learning how to use
> asm. As soon as I jump these last hurdles i can sail to the world of asm.
> Sorry for a long post if you have complaints. You can send me a personal
> e-mail if you like.
> 
> Thanks a whole lot,
> Nat
> smithrh@esper.com
> 

No prob.  Sorry, I just had a lot to say.  If you need any help, e-mail 
me @ dimitri@dynet.com

		-Dimitri


References: