1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-01-09 13:33:26 +00:00

Add 32 bit integer librbary just to print out file sizes in CAT

This commit is contained in:
David Schmenk 2019-12-24 12:02:56 -08:00
parent 5f8f6f0a97
commit a77c50c90a
12 changed files with 470 additions and 175 deletions

View File

@ -18,7 +18,27 @@ import fileio
const FILE_ERR_INT_TBL_FULL = $25
const FILE_ERR_IO = $27
//
// File entry struc
//
struc t_fileentry
byte store_namelen
byte entry_name[15]
byte entry_type
word entry_keyptr
word entry_blocks
word entry_EOFL
byte entry_EOFH
word entry_create[2]
byte entry_version
byte entry_minver
byte entry_access
word entry_aux
word entry_mod
word entry_headptr
end
//
// File info struc
//
struc t_fileinfo
byte file_access
byte file_type
@ -39,6 +59,7 @@ import fileio
word getfileinfo
word setfileinfo
word geteof
word seteof
word iobufalloc
word open
word close

32
src/inc/int32.plh Normal file
View File

@ -0,0 +1,32 @@
import int32
const t_i32 = 4
predef zero32#0
predef zext16to32#0
predef neg32#0
predef load32(i32ptr)#0
predef loadi16(imm16)#0
predef store32(i32ptr)#0
predef add32(i32ptr)#0
predef addi16(imm16)#0
predef sub32(i32ptr)#0
predef subi16(imm16)#0
predef shl32(imm8)#0
predef shr32(imm8)#0
predef mul32(i32ptr)#0
predef muli16(imm16)#0
predef div32(i32ptr)#2
predef divi16(imm16)#2
predef iseq32(i32ptr)#1
predef iseqi16(imm16)#1
predef isge32(i32ptr)#1
predef isgei16(imm16)#1
predef isle32(i32ptr)#1
predef islei16(imm16)#1
predef isgt32(i32ptr)#1
predef isgti16(imm16)#1
predef islt32(i32ptr)#1
predef islti16(imm16)#1
predef i32tos(i32ptr, strptr)#1
predef puti32(i32ptr)#0
end

View File

@ -28,6 +28,7 @@ struc t_fileio
word getfileinfo
word setfileinfo
word geteof
word seteof
word iobufalloc
word open
word close
@ -41,14 +42,14 @@ struc t_fileio
word readblock
word writeblock
end
predef a2getpfx(path), a23setpfx(path), a2getfileinfo(path, fileinfo), a2setfileinfo(path, fileinfo), a23geteof(refnum), a2iobufs(iobufs), a2open(path), a2close(refnum)
predef a2getpfx(path), a23setpfx(path), a2getfileinfo(path, fileinfo), a2setfileinfo(path, fileinfo), a23geteof(refnum)#2, a23seteof(refnum, eofl, eofh), a2iobufs(iobufs), a2open(path), a2close(refnum)
predef a23read(refnum, buf, len), a2write(refnum, buf, len), a2create(path, type, aux), a23destroy(path), a23rename(path, newpath)
predef a2newline(refnum, emask, nlchar), a2online(unit, buf), a2readblock(unit, buf, block), a2writeblock(unit, buf, block)
//
// Exported function table.
//
word fileio[]
word = @a2getpfx, @a23setpfx, @a2getfileinfo, @a2setfileinfo, @a23geteof, @a2iobufs, @a2open, @a2close
word = @a2getpfx, @a23setpfx, @a2getfileinfo, @a2setfileinfo, @a23geteof, @a23seteof, @a2iobufs, @a2open, @a2close
word = @a23read, @a2write, @a2create, @a23destroy, @a23rename
word = @a2newline, @a2online, @a2readblock, @a2writeblock
//
@ -143,17 +144,30 @@ def a3setfileinfo(path, fileinfo)
perr = syscall($C3, @params)
return perr
end
def a1geteof(refnum)
return 0
def a1geteof(refnum)#2
return 0, 0
end
def a23geteof(refnum)
byte params[6]
def a23geteof(refnum)#2
byte params[5]
params.0 = 2
params.1 = refnum
params:2 = 0
params:4 = 0
params.4 = 0
syscall($D1, @params)
return params:2, params.4
end
def a1seteof(refnum, eofl, eofh)
return 0
end
def a23seteof(refnum, eofl, eofh)
byte params[5]
params.0 = 2
params.1 = refnum
params:2 = eofl
params.4 = eofh
syscall($D0, @params)
return params:2
end
def a1open(path)
@ -468,6 +482,7 @@ when MACHID & MACHID_MODEL
fileio:getfileinfo = @a1getfileinfo
fileio:setfileinfo = @a1setfileinfo
fileio:geteof = @a1geteof
fileio:seteof = @a1seteof
fileio:iobufalloc = @a13iobufs
fileio:open = @a1open
fileio:close = @a1close

View File

@ -2,12 +2,14 @@
// 32 bit integer math routines
//
include "inc/cmdsys.plh"
const t_i32 = 4
//
// Include zero page definitions
//
asm int32Inc
!SOURCE "vmsrc/plvmzp.inc"
ACCUM32 = DSTH+1
ACCUM32 = DSTH+1
DVSIGN = TMP+3
end
export asm zero32#0
LDA #$00
@ -41,20 +43,20 @@ export asm neg32#0
end
export asm load32(i32ptr)#0
LDA ESTKL+0,X ; I32PTR
STA SRCL
STA TMPL
LDA ESTKH+0,X ; I32PTR
STA SRCL
STA TMPH
LDY #$00
LDA (SRC),Y
LDA (TMP),Y
STA ACCUM32+0
INY
LDA (SRC),Y
LDA (TMP),Y
STA ACCUM32+1
INY
LDA (SRC),Y
LDA (TMP),Y
STA ACCUM32+2
INY
LDA (SRC),Y
LDA (TMP),Y
STA ACCUM32+3
INX
RTS
@ -64,53 +66,54 @@ export asm loadi16(imm16)#0
LDA ESTKL+0,X ; IMM16L
STA ACCUM32+0
LDA ESTKH+0,X ; IMM16H
STA ACCUM32+1
BPL + ; SIGN EXTEND
DEY
+ STA ACCUM32+1
STY ACCUM32+2
+ STY ACCUM32+2
STY ACCUM32+3
INX
RTS
end
export asm store32(i32ptr)#0
LDA ESTKL+0,X ; I32PTR
STA DSTL
STA TMPL
LDA ESTKH+0,X ; I32PTR
STA DSTL
STA TMPH
LDY #$00
LDA ACCUM32+0
STA (DST),Y
STA (TMP),Y
INY
LDA ACCUM32+1
STA (DST),Y
STA (TMP),Y
INY
LDA ACCUM32+2
STA (DST),Y
STA (TMP),Y
INY
LDA ACCUM32+3
STA (DST),Y
STA (TMP),Y
INX
RTS
end
export asm add32(i32ptr)#0
LDA ESTKL+0,X ; I32PTR
STA SRCL
STA TMPL
LDA ESTKH+0,X ; I32PTR
STA SRCL
STA TMPH
LDY #$00
LDA (SRC),Y
LDA (TMP),Y
CLC
ADC ACCUM32+0
STA ACCUM32+0
INY
LDA (SRC),Y
LDA (TMP),Y
ADC ACCUM32+1
STA ACCUM32+1
INY
LDA (SRC),Y
LDA (TMP),Y
ADC ACCUM32+2
STA ACCUM32+2
INY
LDA (SRC),Y
LDA (TMP),Y
ADC ACCUM32+3
STA ACCUM32+3
INX
@ -138,52 +141,45 @@ export asm addi16(imm16)#0
end
export asm sub32(i32ptr)#0
LDA ESTKL+0,X ; I32PTR
STA SRCL
STA TMPL
LDA ESTKH+0,X ; I32PTR
STA SRCL
LDY #$00
LDA (SRC),Y
SEC
SBC ACCUM32+0
STA ACCUM32+0
INY
LDA (SRC),Y
SBC ACCUM32+1
STA ACCUM32+1
INY
LDA (SRC),Y
SBC ACCUM32+2
STA ACCUM32+2
INY
LDA (SRC),Y
SBC ACCUM32+3
STA ACCUM32+3
INX
RTS
STA TMPH
LDY #$03
- LDA (TMP),Y
STA SRC,Y
DEY
BPL -
BMI _SUB
end
export asm subi16(imm16)#0
LDY #$00
LDA ESTKL+0,X ; IMM16L
SEC
SBC ACCUM32+0
STA ACCUM32+0
STA SRC+0
LDA ESTKH+0,X ; IMM16H
BPL +
STA SRC+1
BPL + ; SIGN EXTEND
DEY
+ SBC ACCUM32+1
+ STY SRC+2
STY SRC+3
_SUB LDA ACCUM32+0
SEC
SBC SRC+0
STA ACCUM32+0
LDA ACCUM32+1
SBC SRC+1
STA ACCUM32+1
TYA
SBC ACCUM32+2
LDA ACCUM32+2
SBC SRC+2
STA ACCUM32+2
TYA
SBC ACCUM32+3
LDA ACCUM32+3
SBC SRC+3
STA ACCUM32+3
INX
RTS
end
export asm shl32(imm8)#0
LDA ESTKL+0,X ; IMM8
AND #$01F
AND #$1F
CMP #16
BCC +
LDY ACCUM32+1
@ -218,7 +214,7 @@ export asm shl32(imm8)#0
end
export asm shr32(imm8)#0
LDA ESTKL+0,X ; IMM8
AND #$01F
AND #$1F
BEQ +
TAY
LDA #$80
@ -343,7 +339,7 @@ export asm divi16(imm16)#2
+ STA SRC+1
LDA ESTKL+0,X ; IMM16L
STA SRC+0
_DIV STY DIVSGN ; LSB = SIGN OF DVSR
_DIV STY DVSIGN ; LSB = SIGN OF DVSR
DEX ; REMNDR = ESTK..ESTK+1
LDY #$00
STY ESTKL+0,X
@ -369,8 +365,8 @@ _DIV STY DIVSGN ; LSB = SIGN OF DVSR
BPL +
LDA #$81 ; DVDND IS NEG
CLC
ADC DIVSGN
STA DIVSGN
ADC DVSIGN
STA DVSIGN
TYA
SEC
SBC ACCUM32+0
@ -407,7 +403,7 @@ _DIV STY DIVSGN ; LSB = SIGN OF DVSR
STA ESTKH+1,X
LDA ESTKL+0,X ; REMNDR
SBC SRC+0 ; DVSR
STA ESTKL+0 ; SUBTRACT
STA ESTKL+0,X ; SUBTRACT
LDA ESTKH+0,X
SBC SRC+1
STA ESTKH+0,X
@ -421,7 +417,7 @@ _DIV STY DIVSGN ; LSB = SIGN OF DVSR
ROL ACCUM32+3
DEY
BNE -
LDA DIVSGN
LDA DVSIGN ; SET SIGNS OF RESULTS
BPL +
TYA
SEC
@ -436,11 +432,10 @@ _DIV STY DIVSGN ; LSB = SIGN OF DVSR
TYA
SBC ESTKH+1,X
STA ESTKH+1,X
LDA DIVSGN
LDA DVSIGN
+ LSR
BCC +
TYA
SEC
SBC ACCUM32+0
STA ACCUM32+0
TYA
@ -454,7 +449,6 @@ _DIV STY DIVSGN ; LSB = SIGN OF DVSR
STA ACCUM32+3
+ RTS
end
export asm iseq32(i32ptr)#1
LDA ESTKL+0,X ; I32PTR
STA TMPL
@ -535,7 +529,7 @@ _ISGE LDA ACCUM32+0
+ STY ESTKL+0,X
STY ESTKH+0,X
RTS
done
end
export asm isle32(i32ptr)#1
LDA ESTKL+0,X ; I32PTR
STA TMPL
@ -575,32 +569,93 @@ _ISLE LDA SRC+0
+ STY ESTKL+0,X
STY ESTKH+0,X
RTS
done
ISGT LDA ESTKL,X
CMP ESTKL+1,X
LDA ESTKH,X
SBC ESTKH+1,X
BVS +
BMI ISTRU
BPL ISFLS
+
- BMI ISFLS
BPL ISTRU
ISLT LDA ESTKL+1,X
CMP ESTKL,X
LDA ESTKH+1,X
SBC ESTKH,X
BVS -
BMI ISTRU
BPL ISFLS
done
def puti32(i32ptr)#0
end
export asm isgt32(i32ptr)#1
LDA ESTKL+0,X ; I32PTR
STA TMPL
LDA ESTKH+0,X ; I32PTR
STA TMPH
LDY #$03
- LDA (TMP),Y
STA SRC,Y
DEY
BPL -
INY
BEQ _ISGT
end
export asm isgti16(imm16)#1
LDY #$00
LDA ESTKL+0,X ; IMM16L
STA SRC+0
LDA ESTKH+0,X ; IMM16H
STA SRC+1
BPL + ; SIGN EXTEND
DEY
+ STY SRC+2
STY SRC+3
LDY #$00
_ISGT LDA SRC+0
CMP ACCUM32+0
LDA SRC+1
SBC ACCUM32+1
LDA SRC+2
SBC ACCUM32+2
LDA SRC+3
SBC ACCUM32+3
BVC +
EOR #$80
+ BPL +
DEY
+ STY ESTKL+0,X
STY ESTKH+0,X
RTS
end
export asm islt32(i32ptr)#1
LDA ESTKL+0,X ; I32PTR
STA TMPL
LDA ESTKH+0,X ; I32PTR
STA TMPH
LDY #$03
- LDA (TMP),Y
STA SRC,Y
DEY
BPL -
INY
BEQ _ISLT
end
export asm islti16(imm16)#1
LDY #$00
LDA ESTKL+0,X ; IMM16L
STA SRC+0
LDA ESTKH+0,X ; IMM16H
STA SRC+1
BPL + ; SIGN EXTEND
DEY
+ STY SRC+2
STY SRC+3
LDY #$00
_ISLT LDA ACCUM32+0
CMP SRC+0
LDA ACCUM32+1
SBC SRC+1
LDA ACCUM32+2
SBC SRC+2
LDA ACCUM32+3
SBC SRC+3
BVC +
EOR #$80
+ BPL +
DEY
+ STY ESTKL+0,X
STY ESTKH+0,X
RTS
end
export def i32tos(i32ptr, strptr)#1
res[t_i32] save
var iptr, rem
word iptr, rem
char[12] istr
iptr = @istr.11
store32(@save)
load32(i32ptr)
if i32ptr->3 & $80
@ -608,11 +663,20 @@ def puti32(i32ptr)#0
putc('-')
fin
repeat
rem = divi16(10)
drop, rem = divi16(10) // Only care about LSW of remainder
^iptr = rem + '0'
iptr--
until isgti16(0)
until iseqi16(0)
^iptr = @istr.11 - iptr
puts(iptr)
strcpy(strptr, iptr)
load32(@save)
return strptr
end
export def puti32(i32ptr)#0
char[12] i32str
puts(i32tos(i32ptr, @i32str))
end
done

View File

@ -36,6 +36,8 @@ FATWDSK = rel/apple/FATWRITEDSK\#FE1000
FATRDSK = rel/apple/FATREADDSK\#FE1000
FILEIO_APL = rel/apple/FILEIO\#FE1000
CONIO_APL = rel/apple/CONIO\#FE1000
INT32 = rel/INT32\#FE1000
INT32TEST = rel/INT32TEST\#FE1000
SANE = rel/SANE\#FE1000
FPSTR = rel/FPSTR\#FE1000
FPU = rel/FPU\#FE1000
@ -96,7 +98,7 @@ TXTTYPE = .TXT
#SYSTYPE = \#FF2000
#TXTTYPE = \#040000
apple: $(PLVMZP_APL) $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVMJIT) $(PLVM802) $(PLVM03) $(CMD) $(CMDJIT) $(JIT) $(JIT16) $(JITUNE) $(SOSCMD) $(PLASMAPLASM) $(CODEOPT) $(ARGS) $(MEMMGR) $(MEMTEST) $(FIBER) $(FIBERTEST) $(LONGJMP) $(ED) $(MON) $(COPY) $(DEL) $(REN) $(CAT) $(NEWDIR) $(TYPE) $(SOS) $(ROD) $(SIEVE) $(PRIMEGAP) $(MOUSE) $(UTHERNET2) $(UTHERNET) $(ETHERIP) $(INET) $(DHCP) $(HTTPD) $(TFTPD) $(ROGUE) $(ROGUEMAP) $(ROGUECOMBAT) $(GRAFIX) $(GFXDEMO) $(LINESPANS) $(GRLIB) $(DGRLIB) $(GRTEST) $(DGRTEST) $(HGRTEST) $(FILEIO_APL) $(CONIO_APL) $(JOYBUZZ) $(PORTIO) $(SPIPORT) $(SDFAT) $(FATCAT) $(FATGET) $(FATPUT) $(FATWDSK) $(FATRDSK) $(SANE) $(FPSTR) $(FPU) $(SANITY) $(LZ4) $(LZ4CAT) $(RPNCALC) $(SNDSEQ) $(PLAYSEQ)
apple: $(PLVMZP_APL) $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVMJIT) $(PLVM802) $(PLVM03) $(CMD) $(CMDJIT) $(JIT) $(JIT16) $(JITUNE) $(SOSCMD) $(PLASMAPLASM) $(CODEOPT) $(ARGS) $(MEMMGR) $(MEMTEST) $(FIBER) $(FIBERTEST) $(LONGJMP) $(ED) $(MON) $(COPY) $(DEL) $(REN) $(CAT) $(NEWDIR) $(TYPE) $(SOS) $(ROD) $(SIEVE) $(PRIMEGAP) $(MOUSE) $(UTHERNET2) $(UTHERNET) $(ETHERIP) $(INET) $(DHCP) $(HTTPD) $(TFTPD) $(ROGUE) $(ROGUEMAP) $(ROGUECOMBAT) $(GRAFIX) $(GFXDEMO) $(LINESPANS) $(GRLIB) $(DGRLIB) $(GRTEST) $(DGRTEST) $(HGRTEST) $(FILEIO_APL) $(CONIO_APL) $(JOYBUZZ) $(PORTIO) $(SPIPORT) $(SDFAT) $(FATCAT) $(FATGET) $(FATPUT) $(FATWDSK) $(FATRDSK) $(INT32) $(INT32TEST) $(SANE) $(FPSTR) $(FPU) $(SANITY) $(LZ4) $(LZ4CAT) $(RPNCALC) $(SNDSEQ) $(PLAYSEQ)
-rm vmsrc/plvmzp.inc
@ -265,6 +267,14 @@ $(PRIMEGAP): samplesrc/primegap.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMW < samplesrc/primegap.pla > samplesrc/primegap.a
acme --setpc 4094 -o $(PRIMEGAP) samplesrc/primegap.a
$(INT32): libsrc/int32.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/int32.pla > libsrc/int32.a
acme --setpc 4094 -o $(INT32) libsrc/int32.a
$(INT32TEST): samplesrc/int32test.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < samplesrc/int32test.pla > samplesrc/int32test.a
acme --setpc 4094 -o $(INT32TEST) samplesrc/int32test.a
$(SANE): libsrc/sane.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/sane.pla > libsrc/sane.a
acme --setpc 4094 -o $(SANE) libsrc/sane.a

View File

@ -37,6 +37,7 @@ cp rel/apple/JIT16#FE1000 prodos/sys/JIT16.REL
cp rel/apple/JITUNE#FE1000 prodos/sys/JITUNE.REL
cp rel/LZ4#FE1000 prodos/sys/LZ4.REL
cp rel/TFTPD#FE1000 prodos/sys/TFTPD.REL
cp rel/INT32#FE1000 prodos/sys/INT32.REL
cp rel/FPSTR#FE1000 prodos/sys/FPSTR.REL
cp rel/FPU#FE1000 prodos/sys/FPU.REL
cp rel/SANE#FE1000 prodos/sys/SANE.REL
@ -61,6 +62,7 @@ cp ../sysfiles/ELEMS.CODE#060000 prodos/fpsos/sys/ELEMS.CODE.BIN
rm -rf prodos/demos
mkdir prodos/demos
cp rel/INT32TEST#FE1000 prodos/demos/INT32TEST.REL
cp rel/apple/GRTEST#FE1000 prodos/demos/GRTEST.REL
cp rel/apple/DGRTEST#FE1000 prodos/demos/DGRTEST.REL
cp rel/apple/HGRTEST#FE1000 prodos/demos/HGRTEST.REL
@ -105,6 +107,7 @@ cp rel/CODEOPT#FE1000 prodos/bld/CODEOPT.REL
mkdir prodos/bld/samples
cp samplesrc/hello.pla prodos/bld/samples/HELLO.PLA.TXT
cp samplesrc/int32test.pla prodos/bld/samples/INT32TEST.PLA.TXT
cp samplesrc/grtest.pla prodos/bld/samples/GRTEST.PLA.TXT
cp samplesrc/dgrtest.pla prodos/bld/samples/DGRTEST.PLA.TXT
cp samplesrc/hgrtest.pla prodos/bld/samples/HGRTEST.PLA.TXT
@ -149,6 +152,7 @@ cp inc/grlib.plh prodos/bld/inc/GRLIB.PLH.TXT
cp inc/dgrlib.plh prodos/bld/inc/DGRLIB.PLH.TXT
cp inc/fiber.plh prodos/bld/inc/FIBER.PLH.TXT
cp inc/fileio.plh prodos/bld/inc/FILEIO.PLH.TXT
cp inc/int32.plh prodos/bld/inc/INT32.PLH.TXT
cp inc/fpstr.plh prodos/bld/inc/FPSTR.PLH.TXT
cp inc/fpu.plh prodos/bld/inc/FPU.PLH.TXT
cp inc/mouse.plh prodos/bld/inc/MOUSE.PLH.TXT

View File

@ -0,0 +1,72 @@
include "inc/cmdsys.plh"
include "inc/int32.plh"
def testi32#0
word il, ih
res[t_i32] i32
ih = 0
for il = 0 to 10
load32(@il)
muli16(10)
divi16(2)
store32(@i32)
puti32(@i32); putln
next
muli16(-30000)
store32(@i32)
puti32(@i32); putln
loadi16(100)
if islti16(50)
puts("100 < 50\n")
fin
if islti16(500)
puts("100 < 500\n")
fin
if isgti16(50)
puts("100 > 50\n")
fin
if isgti16(500)
puts("100 > 500\n")
fin
if islei16(50)
puts("100 <= 50\n")
fin
if islei16(500)
puts("100 <= 500\n")
fin
if isgei16(50)
puts("100 >= 50\n")
fin
if isgei16(500)
puts("100 >= 500\n")
fin
if islti16(100)
puts("100 < 100\n")
fin
if islti16(100)
puts("100 < 100\n")
fin
if isgti16(100)
puts("100 > 100\n")
fin
if isgti16(100)
puts("100 > 100\n")
fin
if islei16(100)
puts("100 <= 100\n")
fin
if islei16(100)
puts("100 <= 100\n")
fin
if isgei16(100)
puts("100 >= 100\n")
fin
if isgei16(100)
puts("100 >= 100\n")
fin
end
testi32
done

View File

@ -351,22 +351,26 @@ end
def strupper(strptr)#0
byte i, chr
for i = ^strptr downto 1
chr = (strptr).[i]
if chr & $E0 == $E0
(strptr).[i] = chr - $E0
fin
next
if ^strptr
for i = ^strptr downto 1
chr = (strptr).[i]
if chr & $E0 == $E0
(strptr).[i] = chr - $E0
fin
next
fin
end
def strlower(strptr)#0
byte i, chr
for i = ^strptr downto 1
chr = (strptr).[i]
if chr & $E0 == $00
(strptr).[i] = chr + $E0
fin
next
if ^strptr
for i = ^strptr downto 1
chr = (strptr).[i]
if chr & $E0 == $00
(strptr).[i] = chr + $E0
fin
next
fin
end
def txtupper#0
word i, strptr

View File

@ -1,24 +1,61 @@
include "inc/cmdsys.plh"
include "inc/args.plh"
include "inc/fileio.plh"
include "inc/int32.plh"
var arg, refnum, dirbuf
var page, firstblk, entrylen, entriesblk, i, entry, filecnt
char[64] path
char[64] path, filename
res[t_fileinfo] fileinfo
res[t_fileentry] fileentry
//
// Convert byte to two hex chars
//
def putb(b)#0
char h
h = ((b >> 4) & $0F) + '0'
if h > '9'
h = h + 7
fin
putc(h)
h = (b & $0F) + '0'
if h > '9'
h = h + 7
fin
putc(h)
end
def strupper(strptr)#0
byte i, chr
if ^strptr
for i = 1 to ^strptr
chr = strptr->[i]
if chr >= 'a' and chr <= 'z'
strptr->[i] = chr - 'a' + 'A'
fin
next
fin
end
def filefrompath(filestr, pathstr)#0
byte i
for i = ^pathstr downto 1
if pathstr->[i] == '/'
break
fin
next
^filestr = ^pathstr - i
memcpy(filestr + 1, pathstr + 1 + i, ^filestr)
end
//
// Print out a directory entry
//
def printentry()#0
byte type, len
def printentry(entryptr)#0
char type, pad, eofstr[12]
type = ^entry
len = type & $0F
^entry = len
puts(entry)
type = ' '
when entry->$10
puts(entryptr)
when entryptr->entry_type
is $0F // Is it a directory?
type = '/'
break
@ -27,12 +64,22 @@ def printentry()#0
break
is $FE // REL file
type = '+'
break
otherwise
type = ' '
wend
putc(type)
for len = 16 - len downto 0
for pad = ^entryptr to 14
putc(' ')
next
putc('$'); puth(entry->$10)
putc('$'); putb(entryptr->entry_type)
puts(" $"); puth(entryptr=>entry_aux)
entryptr->entry_EOFH.1 = 0
i32tos(entryptr+entry_EOFL, @eofstr)
for pad = eofstr to 9
putc(' ')
next
puts(@eofstr)
putln
end
//
@ -41,51 +88,83 @@ end
arg = argNext(argFirst)
if ^arg
strcpy(@path, arg)
strupper(@path)
else
fileio:getpfx(@path)
fin
refnum = fileio:open(@path)
if refnum
page = 0
filecnt = 0
firstblk = 1
dirbuf = heapallocalign(512, 8, 0)
repeat
if fileio:read(refnum, dirbuf, 512) == 512
//
// Skip block pointers
//
entry = dirbuf + 4
if firstblk
//
// Pull out revelant details from the first block
//
entrylen = dirbuf->$23
entriesblk = dirbuf->$24
filecnt = dirbuf=>$25
entry = entry + entrylen
fin
for i = firstblk to entriesblk
//
// Print directory entry details
//
if ^entry
printentry()
filecnt--
//
// Pause display every screenfull
//
page++
if page == 23
getc
page = 0
fin
fin
entry = entry + entrylen
next
firstblk = 0
//
// Check if file exists
//
if fileio:getfileinfo(@path, @fileinfo) == FILE_ERR_OK
puts("=NAME==========TYPE===AUX====LENGTH=\n")
//
// Check if cataloging a directory
//
if fileinfo.file_type == $0F
fileio:iobufalloc(2) // Reserve two I/O buffers
if path[path] <> '/' // Make sure path ends with a '/'
path++
path[path] = '/'
fin
until filecnt == 0
page = 21
filecnt = 0
firstblk = 1
dirbuf = heapallocalign(512, 8, 0)
refnum = fileio:open(@path)
repeat
if fileio:read(refnum, dirbuf, 512) == 512
//
// Skip block pointers
//
entry = dirbuf + 4
if firstblk
//
// Pull out revelant details from the first block
//
entrylen = dirbuf->$23
entriesblk = dirbuf->$24
filecnt = dirbuf=>$25
entry = entry + entrylen
fin
for i = firstblk to entriesblk
//
// Print directory entry details
//
^entry = ^entry & $0F
if ^entry
printentry(entry)
filecnt--
//
// Pause display every screenfull
//
if not page
getc
page = 22
else
page--
fin
fin
entry = entry + entrylen
next
firstblk = 0
fin
until filecnt == 0
else
//
// Create file entry from file info
//
filefrompath(@fileentry, @path)
fileentry.entry_access = fileinfo.file_access
fileentry.entry_type = fileinfo.file_type
fileentry:entry_create:0 = fileinfo:create_date
fileentry:entry_create:2 = fileinfo:create_time
fileentry:entry_aux = fileinfo:aux_type
fileentry:entry_mod:0 = fileinfo:mod_date
fileentry:entry_mod:2 = fileinfo:mod_time
refnum = fileio:open(@path)
fileentry:entry_EOFL, fileentry.entry_EOFH = fileio:geteof(refnum)#2
printentry(@fileentry)
fin
fileio:close(0)
else
puts("Unable to open: "); puts(@path); putln

View File

@ -1192,10 +1192,8 @@ def catalog(path)#0
entry = entry + entrylen
fin
for i = firstblk to entriesblk
type = ^entry
if type
len = type & $0F
^entry = len
if ^entry
^entry = ^entry & $0F
prstr(entry)
type = ' '
when entry->$10
@ -1209,7 +1207,7 @@ def catalog(path)#0
type = '+'
wend
cout(type)
for len = 18 - len downto 0
for len = ^entry to 18
cout(' ')
next
filecnt--

View File

@ -1257,10 +1257,8 @@ def catalog(path)#0
entry = entry + entrylen
fin
for i = firstblk to entriesblk
type = ^entry
if type
len = type & $0F
^entry = len
if ^entry
^entry = ^entry & $0F
prstr(entry)
type = ' '
when entry->$10
@ -1274,7 +1272,7 @@ def catalog(path)#0
type = '+'
wend
cout(type)
for len = 18 - len downto 0
for len = ^entry to 18
cout(' ')
next
filecnt--

View File

@ -176,10 +176,8 @@ def catalog(path)#0
entry = entry + entrylen
fin
for i = firstblk to entriesblk
type = ^entry
if type
len = type & $0F
^entry = len
if ^entry
^entry = ^entry & $0F
puts(entry)
type = ' '
when entry->$10
@ -193,7 +191,7 @@ def catalog(path)#0
type = '+'
wend
putc(type)
for len = 18 - len downto 0
for len = ^entry to 18
putc(' ')
next
filecnt--