Calculator Community > ASM
How do I load a symbol into a string?
joshuarpl:
I'm trying to put A into Str0, but I don't know how.
Xeda112358:
Do you mean the token, "A" ?
You'll need to verify that the string exists, then verify its size. Then it is simply a matter of writing the token. In this case, it is a 1-byte token and happens to correspond to the ASCII value (0x41).
If all you want is to make Str0="A", the easy way is to check if it exists, delete it if so, then create a new string of size 1, then load the bytes into it.
--- Code: ---; Load the name into OP1
ld hl,$09AA ; internally, Str0 is represented as 0xAA09
ld (OP1+1),hl
; Check if it exists and delete if necessary
rst rFindSym
jr c,make_str0
bcall(_DelvarArc)
make_str0:
; Now create Str0 with size 1. Put the name in OP1 first
ld hl,$09AA
ld (OP1+1),hl
; Size is 1 byte
ld hl,1
bcall(_CreateStrng)
;Pointer to size bytes is in DE. Switch to HL
ex de,hl
; Don't need the size, so skip those two bytes and get to the start of the data
inc hl
Inc hl
; Now write the token
ld (hl),tA ; if using ti83plus.inc. same as $41 or in this specific case, 'A'
;Done!
ret
--- End code ---
Please note that I haven't tested this; I'm on mobile so it was heck to type as it is :D
joshuarpl:
No, I wanna put the contents of the A register into Str0, as a character/symbol, not a number.
Xeda112358:
Oh, just do same code, but push af first, and then instead of ld (hl),tA use pop af \ ld (hl),a
joshuarpl:
,Doesn't seem to work, send me the code to store Ans (as a character) into Str0 maybe?
Navigation
[0] Message Index
[#] Next page
Go to full version