home *** CD-ROM | disk | FTP | other *** search
- ; buffer sizes
- IBUFF * 16*1024
-
- ; define register bindings
- R0 RN 0
- R1 RN 1
- R2 RN 2
- R3 RN 3
- R4 RN 4
- R5 RN 5
- R6 RN 6
- R7 RN 7
- R8 RN 8
- R9 RN 9
- R10 RN 10
- R11 RN 11
- R12 RN 12
- R13 RN 13
- R14 RN 14
- R15 RN 15
- PC RN 15
-
- ; define SWIs (I hate ObjAsm!)
- OS_File * &08
- OS_GetEnv * &10
- OS_Exit * &11
- OS_GenerateError * &2B
-
- ; include header file
- GET CompUtils:ExpCode.asm.h.Universal
-
- ; ==========================================================================
-
- AREA MyCode,CODE,READONLY
-
- IMPORT |Image$$ZI$$Limit|
-
- start
- ENTRY
-
- ; set up stack, workspace and workspace end
- SWI OS_GetEnv
- MOV R13,R1 ; stack ptr
- LDR R12,=|Image$$ZI$$Limit| ; workspace ptr
- SUB R11,R13,#1024 ; workspace limit
- LDR R6,=ExpCode ; ptr to ExpCode
-
- ; claim the source buffer
- MOV R0,#IBUFF
- STR R0,[R6,#ExpCode_SrcLength]
- BL claim
- STR R0,[R6,#ExpCode_SrcBufferPtr]
-
- ; set up output flags
- MOV R0,#OUTPUT_LINEAR
- STR R0,[R6,#ExpCode_OutputFlags]
-
- ; set up data offset
- MOV R0,#0
- STR R0,[R6,#ExpCode_DataOffset]
-
- ; set up source filename ptr
- ADR R0,infile
- STR R0,[R6,#ExpCode_FilenamePtr]
-
- ; initialise the code
- BL ExpCode_InitCode
- SWIVS OS_GenerateError
-
- ; claim the destination buffer
- LDR R0,[R6,#ExpCode_SampleLength]
- STR R0,[R6,#ExpCode_DestLength]
- BL claim
- STR R0,[R6,#ExpCode_DestBufferPtr]
-
- ; decompress the sample
- BL ExpCode_ProcessCode
- SWIVS OS_GenerateError
-
- ; finally, save the output and exit
- MOV R0,#10
- ADR R1,outfile
- MOV R2,#&FF0
- ORR R2,R2,#&00D
- LDR R4,[R6,#ExpCode_DestBufferPtr]
- LDR R5,[R6,#ExpCode_SampleLength]
- ADD R5,R4,R5
- SWI OS_File
-
- ; exit
- SWI OS_Exit
-
-
- ; --------------------------------------------------------------------------
-
- infile = "RAM:$.Infile",0
- ALIGN
-
- outfile = "RAM:$.Outfile",0
- ALIGN
-
- ; --------------------------------------------------------------------------
-
- claim
- ; r0 = size to claim
- ; r12 = ptr to available workspace
- ; r11 = ptr to end of available workspace
- ; on exit, r0 = ptr to block claimed
- ; an error occurs if not enough memory is available
-
- ADD R12,R12,R0 ; update ptr
- SUB R0,R12,R0 ; ptr to new block
- CMP R12,R11 ; enough memory?
- MOVLE PC,R14 ; exit if so
-
- ; generate an error
- ADR R0,claim_error
- SWI OS_GenerateError
-
- claim_error
- & 1
- = "Not enough memory available",0
- ALIGN
-
-
-
- END
-