Omnimaga

Calculator Community => TI Calculators => ASM => Topic started by: TiAddict on August 13, 2012, 10:41:46 pm

Title: Why wouldnt this work?!
Post by: TiAddict on August 13, 2012, 10:41:46 pm
So this program creates a prgm which name is in str1, and puts memory (10 bytes) into that prgm.
Start:
Ld Hl, Str1Address
Rst 20h ( B_Call Mov9ToOp1)
Rst 10h ( B_Call ChkFindSym)
Ex De, HL
Ld C, (HL)
Inc HL
Ld B,(HL)
Inc HL
Ld De, Op1
Ld A,5
Ld (DE),A
Inc DE
Ldir
xor A
Ld (DE),A
B_Call ChkFindSym
Ld HL, 0
B_Call CreateProg
Push DE
Inc DE
Inc DE
Ld HL,10
B_Call InsertMem
Pop HL
Push HL
B_CALL LdHLind
Ld BC, 10
Add HL, BC
Ex DE, HL
Pop HL
Ld (HL),E
Inc HL
Ld (HL), D
Ldir
Ret

Str1Address:
db. StrngObj, tVarString, 00h,0
Please, dont optimize or anything. I want to see how it's working, and understand ASM Better.
I heard that OPs gets changed alot, but im not sure. Anyways, this Program does create a prgm, but it's not exactly the same as "string" inside Str1. So can you help me? Thank you :)
Title: Re: Why wouldnt this work?!
Post by: willrandship on August 14, 2012, 12:16:28 am
So wait, is this supposed to put the string you're assembling with in as the Program's contents in a basic editor? If so, I bet the problem is that you're confusing Strings (ASCII-ish) and tokens (not so ASCII-ish) That would garble some stuff, but not all. For instance, a space in ASCII is randM or something in prgm tokens, but I think all the uppercase letters are the same.

But I'm no good at real assembly.
Title: Re: Why wouldnt this work?!
Post by: TiAddict on August 14, 2012, 01:43:11 am
So this program is suppose to MAKE a program where, the name is in String1. And to THAT program (name from str1), i want to put in 10 bytes. and no there's no problem with that! :(
Title: Re: Why wouldnt this work?!
Post by: willrandship on August 15, 2012, 05:16:57 pm
Quick question: When you say 'not working' could you clarify? Does it crash? Does it get the characters mixed up? Does it do absolutely nothing? That would help diagnose what is actually happening.

Oh, and keep in mind str1 is stored in tokens, not ASCII.
Title: Re: Why wouldnt this work?!
Post by: chickendude on August 17, 2012, 11:48:58 am
I don't think you ever load the name stored inside the string. Try something like this (based off your code):
Code: [Select]
Start:
ld hl,Str1Address
rst 20h ;( B_Call Mov9ToOp1)
rst 10h ;( B_Call ChkFindSym)
ret c
inc de ;skip size bytes
inc de
ex de,hl
ld bc,8 ;copy up to 8 bytes of the string for program name
ld de,stringName+1 ;store the program name at stringName+1 (so as not to overwrite ProgObj)
ldir
ld hl,stringName ;start of program name
rst 20h ;put into OP1
ld hl,10 ;10 bytes of (random) data
B_Call _CreateProg
ret

Str1Address:
.db StrngObj, tVarStrng, 0

stringName:
.db ProgObj,"        "
Title: Re: Why wouldnt this work?!
Post by: calc84maniac on August 17, 2012, 11:56:21 am
chickendude, I'm not so sure that would work, because program names need to be null-terminated but strings are not. You might end up creating a program with its name including the size bytes and some data of the next variable. In this case, you will need to read the size bytes of the string and ldir based on that, then null-terminate manually. (You might be able to avoid manual null-termination if the destination buffer is already filled with null bytes.)
Title: Re: Why wouldnt this work?!
Post by: chickendude on August 17, 2012, 12:16:10 pm
I remember reading that a program name needs to be either 8 characters or null-terminated. Instead of filling the name buffer with spaces i suppose you could just fill it with eight 0's.

EDIT: Ah but you're right, since the entire buffer is overwritten with the ldir anyway. So yeah, it'd be best to read the size of the string and only load that many characters.