tools/as7: added syscalls chmod and chown, added auto-increment
locations, fixed a bug in character input, added several EAE instructions. We now have cp.s, chmod.s and chown.s working.
This commit is contained in:
+58
-52
@@ -1,77 +1,83 @@
|
||||
" chmode
|
||||
" chmod: chmod mode file [file file ...]
|
||||
"
|
||||
" mode is an octal number
|
||||
|
||||
lac 017777 i
|
||||
lac 017777 i " Have we got any arguments?
|
||||
sad d4
|
||||
jmp error
|
||||
|
||||
jmp error " No, give an error
|
||||
lac 017777
|
||||
tad d4
|
||||
dac 8
|
||||
tad d1
|
||||
dac name
|
||||
dzm octal
|
||||
dzm nchar
|
||||
-8
|
||||
dac c1
|
||||
tad d4 " Skip past argc
|
||||
dac 8 " and save the ptr to the octal value at location 8
|
||||
tad d1 " Why only 1 here?
|
||||
dac name " Save the filename pointer
|
||||
dzm octal " Zero the octal value and
|
||||
dzm nchar " the number of characters
|
||||
-8 " Set c1 to -8 so we can increment up to zero
|
||||
dac c1 " and thus count the number of chars in the argument
|
||||
|
||||
1:
|
||||
lac nchar
|
||||
dzm nchar
|
||||
sza
|
||||
jmp 2f
|
||||
lac 8 i
|
||||
lmq
|
||||
and o177
|
||||
dac nchar
|
||||
lacq
|
||||
lrss 9
|
||||
lac nchar " Get any left-over character from the last loop
|
||||
dzm nchar " and set nchar to empty now
|
||||
sza " It was already empty, so get a new word
|
||||
jmp 2f " Not empty, it has the second ASCII value, goto 2f
|
||||
lac 8 i " Read the next word with two chars in it
|
||||
lmq " Copy it to MQ
|
||||
and o177 " Trim off all but the second ASCII value
|
||||
dac nchar " Save it into nchar
|
||||
lacq " Bring it back from MQ
|
||||
lrss 9 " and shift down the first ASCII value
|
||||
|
||||
2:
|
||||
sad o40
|
||||
jmp 3f
|
||||
tad om60
|
||||
lmq
|
||||
lac octal
|
||||
cll; als 3
|
||||
omq
|
||||
dac octal
|
||||
sad o40 " If the character is a space
|
||||
jmp 3f " don't try to make it part of the octal value
|
||||
tad om60 " Not a space, subtract 060 i.e. '0'
|
||||
lmq " Move it into MQ
|
||||
lac octal " Load the octal value up to here
|
||||
cll; als 3 " Shift it left 3 bits
|
||||
omq " OR in the digit from MQ
|
||||
dac octal " and save back in the octal value
|
||||
|
||||
3:
|
||||
isz c1
|
||||
jmp 1b
|
||||
isz c1 " Is that the last character?
|
||||
jmp 1b " No, go back and get another one
|
||||
|
||||
loop:
|
||||
lac 017777 i
|
||||
lac 017777 i " How many arguments left?
|
||||
sad d8
|
||||
sys exit
|
||||
tad dm4
|
||||
dac 017777 i
|
||||
lac name
|
||||
sys exit " None, exit
|
||||
tad dm4 " Subtract 4 to indicate one less argument
|
||||
dac 017777 i " and save for next time
|
||||
lac name " Also move to the next filename
|
||||
tad d4
|
||||
dac name
|
||||
lac octal
|
||||
sys chmode; name:0
|
||||
lac octal " Set AC to have the new file mode
|
||||
sys chmod; name:0 " and change the file's mode
|
||||
sma
|
||||
jmp loop
|
||||
lac name
|
||||
dac 1f
|
||||
lac d1
|
||||
sys write; 1:0; 4
|
||||
jmp loop " Loop if no error
|
||||
lac name " We got back -1, error
|
||||
dac 1f " Write out the filename on stdout
|
||||
lac d1 " followed by the " ?\n" string
|
||||
sys write; 1:0; 4 " and loop back
|
||||
lac d1
|
||||
sys write; 1f; 2
|
||||
jmp loop
|
||||
|
||||
1:
|
||||
040;077012
|
||||
040;077012 " String literal " ?\n"
|
||||
|
||||
error:
|
||||
lac d1
|
||||
lac d1 " Write " "\n" to stdout and exit
|
||||
sys write; 1b+1; 1
|
||||
sys exit
|
||||
|
||||
om60: -060
|
||||
o40: 040
|
||||
d1: 1
|
||||
d1: 1 " Numeric constants
|
||||
d4: 4
|
||||
d8: 8
|
||||
dm4: -4
|
||||
d4: 4
|
||||
o40: 040
|
||||
o177: 0177
|
||||
om60: -060
|
||||
|
||||
nchar: .=.+1
|
||||
nchar: .=.+1 " Number of characters in the value entered
|
||||
c1: .=.+1
|
||||
octal: .=.+1
|
||||
octal: .=.+1 " The resulting octal value
|
||||
|
||||
Reference in New Issue
Block a user