home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
UNIFLEX
/
UNIFLEX
/
UniFLEX_Std.Utils1.tar.Z
/
UniFLEX_Std.Utils1.tar
/
utils1
/
dump
< prev
next >
Wrap
Text File
|
1982-01-28
|
4KB
|
238 lines
opt pag,nol
ttl File Dump
pag
lib sysdef
opt lis
pag
* program starts here
org 0
dump ldd 0,s get arg count
cmpd #2 is it 1?
beq dump0 yes - continue
cmpd #3 is it 2?
bne dump6
ldy #pos get starting position
ldx 6,s point at argument
jsr gethex
dump0 ldx #line point to text line
lda #$20 setup space
ldb #76 set counter
dump1 sta 0,x+ space out line
decb dec the count
bne dump1
ldd 4,s get name pointer
std iopn2 set in call
sys ind,iopn
bes dump6 errors?
pshs d save file desc
ldd pos position file
std start
ldd pos+2
std start+2
ldd 0,s get file desc
sys ind,iseek
bes dump9
dump2 lbsr zerbuf zero out buffer
ldd 0,s get file desc
sys read,buffer,16 read in file
bes dump4
cmpd #0 eof?
beq dump4
std count
lbsr fillin fill in text line
ldd #1 set file desc
sys write,line,77 output line
ldd pos+2 get pos count
addd #16 bump by 16
std pos+2
bcc dump2 if no carry
ldd pos propagate carry
addd #1
std pos
bra dump2 repeat
dump4 puls d get file desc
sys close close the file
dump6 sys term exit!
*
dump9 pshs d
ldd #0 write out error
sys write,err0,err0sz
puls d
sys term
*
* gethex - parse hex number from command line
*
gethex ldd #0 set value
std 0,y
std 2,y
ldb ,x+ get character
cmpb #'+ ignore +
bne geth0
ldb ,x+
beq geth9
geth0 cmpb #'0 legal value
blt geth9 no - error
cmpb #'9
ble geth1
cmpb #'a is it a hex digit?
blt geth9 no - abort
cmpb #'f
bgt geth9
subb #'a-10
bra geth2
geth1 subb #'0
geth2 clra
pshs d
ldd 2,y get value
aslb shift left 4
rola
rol 1,y
rol 0,y
aslb
rola
rol 1,y
rol 0,y
aslb
rola
rol 1,y
rol 0,y
aslb
rola
rol 1,y
rol 0,y
addd 0,s++ compute new value
std 2,y save result
ldb ,x+ get next character
bne geth0 continue scan
rts exit
*
geth9 ldd #0 error - bad hex input
sys write,err1,err1sz
ldd #0
sys term
* zerbuf
zerbuf ldb #16 set count
ldx #buffer set pointer
zerbu2 clr 0,x+
decb
bne zerbu2
rts return
* fillin
fillin ldx #line point to line
lda #$20 blank line
ldb #76
fill0 sta ,x+
decb
bgt fill0
ldx #line
ldy #buffer point to file data
lda pos get pos count
bsr pthex out hex
lda pos+1
bsr pthex
lda pos+2
bsr pthex
lda pos+3
bsr pthex
leax 1,x
ldb count+1 get length
cmpb #8
ble fill1
ldb #8
fill1 bsr group
leax 1,x leave space
ldb count+1
subb #8
bge fill2
ldb #0
fill2 bsr group
leax 2,x leave 2 spaces
bra ascii
group pshs b save input count
tstb anything here?
beq group3 no - exit
group2 lda 0,y+ get byte
leax 1,x leave space
bsr pthex output hex
decb dec count
bne group2
group3 ldb #8
subb 0,s+
beq group9
leax b,x
leax b,x
leax b,x
group9 rts return
* pthex
pthex pshs a save char
lsra get hi part
lsra
lsra
lsra
bsr chex do char
sta 0,x+ save result
puls a get byte
bsr chex do char conv
sta 0,x+ save result
rts return
* chex
chex anda #$f mask lo bits
ora #$30 make ascii
cmpa #$39 is it digit
bls chex2
adda #7 make letter
chex2 rts return
* ascii
ascii ldy #buffer point to buffer
ldb count+1
ascii1 lda 0,y+ get byte
anda #$7f mask parity
cmpa #$7f printable?
beq ascii3 no - print '.'
cmpa #$20 is it control?
bhs ascii2
ascii3 lda #'. if so, make period
ascii2 sta 0,x+ save in line
decb end of buffer?
bne ascii1
rts return
* buffers
pos fdb 0,0
iopn fcb open
iopn2 fdb 0
fdb 0
iseek fcb seek
start fdb 0,0
fdb 0
buffer rmb 16
line rmb 76
fcb $d c.r.
count fdb 0
cr equ $0d
err0 fcc 'I/O error on file',cr
err0sz equ *-err0
err1 fcc 'Illegal hex input - abort',cr
err1sz equ *-err1
end dump