Difference between revisions of "83Plus:BCALLs:42F7"
From WikiTI
m |
Deep Thought (Talk | contribs) (→Example) |
||
Line 30: | Line 30: | ||
rst rMov9ToOP1 | rst rMov9ToOP1 | ||
B_CALL ChkFindSym ;find the application variable | B_CALL ChkFindSym ;find the application variable | ||
− | jr | + | jr c,AppVarNotFound |
inc de | inc de |
Latest revision as of 20:33, 24 September 2012
Synopsis
Official Name: InsertMem
BCALL Address: 42F7
Adds RAM space into an existing variable.
Inputs
- HL = amount of RAM to insert into the variable
- DE = the memory address where the RAM will be inserted
Outputs
- DE = the memory addressed where the RAM was inserted. Equivilant to the input.
Destroys
- All
Remarks
- This routine will not check to see if there is insufficient RAM. It is highly suggested to do that beforehand, using the bcall EnoughMem.
- The size field of the variable is not updated. The user must do this himself.
- DE cannot be the first byte of the variable's data or else the symbol entry's pointer to the data will become corrupt (the first byte being the size field?).
Example
ld hl,9 B_CALL EnoughMem jr c,NotEnoughMem ;make sure there is enough memory to insert the RAM ld hl,ApplicationVariable rst rMov9ToOP1 B_CALL ChkFindSym ;find the application variable jr c,AppVarNotFound inc de inc de ;move past the size bytes ld hl,9 B_CALL InsertMem ;insert 9 bytes here ex de,hl dec hl ld a,(hl) dec hl push hl ld h,(hl) ld l,a ;ld hl,(de). Load the size of the AppVar in hl ld de,9 add hl,de ;add 9 to hl ex de,hl pop hl ld (hl),e inc hl ld (hl),d ;Store the new size back into the AppVar ApplicationVariable: .db AppVarObj,"APPVAR",0