mirror of
https://github.com/elliotnunn/mac-rom.git
synced 2024-12-28 01:29:20 +00:00
4325cdcc78
Resource forks are included only for .rsrc files. These are DeRezzed into their data fork. 'ckid' resources, from the Projector VCS, are not included. The Tools directory, containing mostly junk, is also excluded.
124 lines
3.1 KiB
Plaintext
124 lines
3.1 KiB
Plaintext
;
|
|
; File: Strings.a
|
|
;
|
|
; Copyright: © 1992 by Apple Computer, Inc. All rights reserved.
|
|
;
|
|
; Change History (most recent first):
|
|
;
|
|
; <SM2> 10/28/92 SWC Changed INCLUDEs to a LOAD of StandardEqu.d.
|
|
;
|
|
|
|
|
|
LOAD 'StandardEqu.d'
|
|
|
|
|
|
|
|
;FUNCTION C2PStr(cString: UNIV Ptr): Str255;
|
|
|
|
BLANKS ON
|
|
STRING ASIS
|
|
|
|
C2PStr proc EXPORT
|
|
move.l 4(sp),d0 ; address of s
|
|
MOVE.L D0,8(SP) ; Already know this will be returned value!
|
|
beq.s @4 ; test for Nil
|
|
|
|
move.l d0,a0 ; address of s
|
|
move.l a0,a1 ; also address of s
|
|
move.b (a1)+,d0 ; first character
|
|
beq.s @4 ; test of length zero
|
|
|
|
@1 move.b (a1),d1 ; byte about to be clobbered
|
|
move.b d0,(a1)+ ; move the last one forward
|
|
move.b d1,d0 ; move clobbered to last
|
|
bne.s @1 ; watch for 0 and end of C string
|
|
|
|
sub.l a0,a1 ; number of bytes moved
|
|
move.l a1,d0 ; string length + 1
|
|
subq #1,d0 ; string length
|
|
|
|
cmpi.l #255,d0
|
|
ble.s @2
|
|
move.l #255,d0
|
|
@2 move.b d0,(a0) ; Pascal string length
|
|
|
|
@4 MOVE.L (SP)+,A1 ; return address
|
|
ADDQ #4,SP ; remove parameter from stack
|
|
JMP (A1) ; bye-bye
|
|
|
|
|
|
;PROCEDURE C2PStrProc(cString: UNIV Ptr);
|
|
|
|
C2PStrProc proc EXPORT
|
|
move.l 4(sp),d0 ; address of s
|
|
beq.s @4 ; test for Nil
|
|
|
|
move.l d0,a0 ; address of s
|
|
move.l a0,a1 ; also address of s
|
|
move.b (a1)+,d0 ; first character
|
|
beq.s @4 ; test of length zero
|
|
|
|
@1 move.b (a1),d1 ; byte about to be clobbered
|
|
move.b d0,(a1)+ ; move the last one forward
|
|
move.b d1,d0 ; move clobbered to last
|
|
bne.s @1 ; watch for 0 and end of C string
|
|
|
|
sub.l a0,a1 ; number of bytes moved
|
|
move.l a1,d0 ; string length + 1
|
|
subq #1,d0 ; string length
|
|
|
|
cmpi.l #255,d0
|
|
ble.s @2
|
|
move.l #255,d0
|
|
@2 move.b d0,(a0) ; Pascal string length
|
|
|
|
@4 MOVE.L (SP)+,A1 ; return address
|
|
ADDQ #4,SP ; get rid of parameters: one long
|
|
JMP (A1) ; bye-bye
|
|
|
|
|
|
;FUNCTION P2CStr(pString: UNIV Ptr): StringPtr;
|
|
|
|
P2CStr proc EXPORT
|
|
MOVE.L (SP)+,A1 ; return address
|
|
MOVE.L (SP)+,D0 ; address of s
|
|
MOVE.L D0,(SP) ; Already know this will be returned value!
|
|
beq.s @3 ; test for Nil
|
|
|
|
move.l d0,a0 ; address of s
|
|
clr.l d0 ; clear for length
|
|
move.b (a0),d0 ; Pascal string length
|
|
bra.s @2 ; check for zero length
|
|
|
|
@1 move.b 1(a0),(a0)+ ; slide byte down one
|
|
@2 dbf d0,@1 ; loop for length of string
|
|
|
|
clr.b (a0) ; C string terminator
|
|
@3
|
|
JMP (A1) ; bye-bye
|
|
|
|
|
|
;PROCEDURE P2CStrProc(pString: UNIV Ptr);
|
|
|
|
P2CStrProc proc EXPORT
|
|
MOVE.L (SP)+,A1 ; return address
|
|
MOVE.L (SP)+,D0 ; address of s
|
|
beq.s @3 ; test for Nil
|
|
|
|
move.l d0,a0 ; address of s
|
|
clr.l d0 ; clear for length
|
|
move.b (a0),d0 ; Pascal string length
|
|
bra.s @2 ; check for zero length
|
|
|
|
@1 move.b 1(a0),(a0)+ ; slide byte down one
|
|
@2 dbf d0,@1 ; loop for length of string
|
|
|
|
clr.b (a0) ; C string terminator
|
|
@3
|
|
JMP (A1) ; bye-bye
|
|
|
|
|
|
|
|
|
|
END
|