Re: A86: can one program be on two pages?
[Prev][Next][Index][Thread]
Re: A86: can one program be on two pages?
On Sat, 4 Jul 1998 20:11:21 EDT TGaArdvark@aol.com writes:
>
>Then again, you could always just DISABLE THE INTERRUPTS first.
why not just stop arguing and try it? this one doesn't quite work. it
crashes on return. help fix it, maybe? (i use tasm by the way) it's
also a bit messy 'cause i wasn't expecting to post it...
also - if you really need to read variables, use the rom slot for ram.
-josh
;big prog loader for programs up to 30k
_SET_ABS_SRC_ADDR = $4647
_SET_MM_NUM_BYTES = $464F
_create_string = $472F
_inc2_ptr_ahl = $4C3F
_SET_ABS_DEST_ADDR = $5285
_mm_ldir = $52ED
_conv_addr = $4633
_delvar = $475F
_memory_error = $4160
.org $d748
;save $c000-$d748
ld hl,savedata-1
rst 20h
xor a
ld hl,$C000
call _SET_ABS_SRC_ADDR
ld hl,$1748
call _SET_MM_NUM_BYTES
call _create_string
ld a,b
ld h,d
ld l,e
push af
push hl
call _inc2_ptr_ahl
call _SET_ABS_DEST_ADDR
call _mm_ldir
pop hl
pop af
call _conv_addr ;we've got to find this later
or $40
ld (savedatapage),a
ld (savedatahl),hl
;find program
ld hl,progname-1
rst 20h
rst 10h
ld a,b
ld h,d
ld l,e
call _conv_addr
or $40
out ($05),a ;load it to rom slot
res 7,h
set 6,h ;fixup hl to point to the right place
ld a,$41
out ($06),a ;load ram page 1
ld e,(hl)
inc hl
ld d,(hl)
inc hl
inc hl
inc hl
ld a,$77
cp d
jr c,toobig ;more than 30k
push hl
push de
;move callcode into place
ld hl,callcode
ld de,$f800
ld bc,codesize
ldir
pop bc
pop hl
ld de,$8000
jp callcode+callfixup ;=$f800
toobig: ld hl,savedata-1
rst 20h
rst 10h
call _delvar
jp _memory_error
progname: .db 8,"bigprog1"
callfixup = $f800-$
callcode:
call copydata+callfixup
ld a,$d ;load rom page $d
out ($05),a
call $8000 ;run program
ld a,(savedatapage+callfixup)
out ($05),a ;load save data
ld hl,(savedatahl+callfixup)
ld de,$c000
ld bc,$1748 ;restore page 0 info
call copydata
ld a,$0d ;load rom page $d
out ($05),a
ld hl,savedata-1 ;delete temp var
rst 20h
rst 10h
; call _delvar
ret
savedata: .db 8,1,"bigprog"
savedatapage: .db 0
savedatahl: .dw 0
;hl=from (can span pages)
;de=to
;bc=size
copydata:
push hl
push de
ld de,$8000 ;has to be in rom slot
or a
sbc hl,de ;get space left on page
push hl
sbc hl,bc ;space on page-total
jr c,extrabig ;->it's bigger than that
pop hl
pop de ;strait copy
pop hl
ldir
ret
extrabig:
;hl=space on page-total
ld de,1 ;carry is set
ex de,hl
sbc hl,de ;get extra space
pop bc
pop de
ex (sp),hl ;save extra space
ldir ;copy first page bit
pop bc ;hl=extra space (left over)
in a,($05)
inc a
out ($05),a ;go to next page
ld hl,$4000 ;start at beginning of page
jr copydata
codesize = $-callcode
.end
_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]
References: