So I've tried to create and access AppVars in a MirageOS Asm program, but for some weird reason, the program doesn't seem to recognize that the AppVar exists, even when I've manually checked that it does. My code looks something like this...


Code:

GetAppVar:               ;finds appvar and gets data from it
ld HL, Name9Bytes
rst rMov9ToOp1
rst rFindSym
jr c, AppVarNotExist

;verify Appvar is in RAM, etc...
;and try to extract data

AppVarNotExist:

;unimportant stuff

;...

Done:                         ;when program is finished, save data and quit
ld HL, Name9Bytes
rst rMov9ToOp1
rst rFindSym
jr nc, DoneVarExists

ld HL, SizeVar
b_call(_CreateAppVar)

DoneVarExists:

;save data

call quittoshell


Also, the AppVar that's created is apparently 20 bytes when I check it in the memory menu, but the value of SizeVar, which is the HL parameter passed to the CreateAppVar b_call, is like, 4 bytes.

Anybody know what's going on?
An appvar's size is calculated from the size of the data and the VAT entry (which holds the name, archived/unarchived, etc.). So, even though you want to create a 4 byte appvar, the VAT entry causes it to become 20 bytes in the memory menu.

EDIT:
Also, you should use B_CALL ChkFindSym, not rst rFindSym.
FindSym is for real variables and the like; CheckFindSym is for programs, appvars, and lists. Number one, CreateAppVar does not set the first two bytes of the program to, in this example, $14, $00; that is your responsibility! Secondly, at the risk of advertising, may I ask why you're writing a MOS program instead of a DCS program? Smile
Thanks a lot guys! I've replaced the restart with CheckFindSym and the program worked!

@Kerm

Unfortunately, Latenite doesn't support DCS, and I have no idea how to write a DCS port, so I'm sticking to MirageOS for now. Sorry Smile
Did you also add setting the size field? And regarding Latenite, I'm pretty sure someone made the proper configuration files at some point. Also, Doors CS supports all the MirageOS libraries plus hundreds more, and is of course much more stable, so you'd just need to replace the MOS header with the DCS header and all would be good. Smile
Uh, I thought the _Create bcalls do initialize the size bytes? I'm pretty sure anyway, I have no reason to believe otherwise from my experience.

The size difference in the memory menu is because it includes the VAT entry when computing the total size.
Oh duh, of course they do, sorry. Smile I was thinking of _InsertMem and _DelMem, which of course do not update size fields. Razz
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement