.data
fnf: .ascii "The file was not found: "
###important: UPDATE THIS PATH TO WHERE YOU SAVED THE TEXT FILE
#asciiz directive creates null-terminated string
file: .asciiz "C:/Users/mmono/OneDrive/Documents/input.txt"
pstring:.asciiz " characters.\nFile contents:"
buffer: .space 1024
.text
# These lines opens and reads the file containing text to be modified
main:
li $v0, 13 # System call to open file, $v0 set to file descriptor
# $v0 negative if failed to open file
la $a0, file # Load file to read, $a0 set to address of string
# containing file name
li $a1, 0 # Set read-only flag
li $a2, 0 # Set mode
syscall
add $s0, $v0, $zero # Save file descriptor in $v0 to new register $s0
# because $v0 will be used in other system calls
blt $v0, 0, err # Go to handler if failed to open file
# These lines read text from file
read:
li $v0, 14 # System call to read file
add $a0, $s0, $zero # Load file descriptor to $a0
la $a1, buffer # Set $a1 to address of input buffer where
# text will be loaded to
li $a2, 1024 # Set $a2 to number of characters to read
syscall
#after read, $v0 will have number of bytes read
#set last byte to null
la $a0, buffer
add $a0, $a0, $v0 #address of byte after file data
sb $zero, 0($a0)
#initialize some registers
init:
li $t0, 0 # $t0 will be message character iterator i
# initialize i=0
add $s1, $a1, $zero # save address start of buffer
#loop to count characters, exclude white spaces and
loop:
add $s2, $s1, $t0 # $s2 <= A + i, address of current character
# A: address start of buffer
lb $s3, 0($s2) # load char in message[i] to $s3
beq $s3, $zero, print #null, reached end of buffer
addi $t0, $t0, 1 #i++
j loop #continue counting
# Print Data to console
print:
li $v0, 1 # System call to print integer
add $a0, $t0, $zero # Load to $a0 integer to print
syscall
#print "File contents:"
li $v0, 4 # System call to print string
la $a0, pstring # Load to $a0 string to print
syscall
#print actual file contents
li $v0, 4 # System call to print string
la $a0, buffer # Load to $a0 string to print
syscall
# Close File
close:
li $v0, 16 # Close File Syscall
add $a0, $s0, $zero # Load File Descriptor
syscall
j done # Goto done
# Error
err:
li $v0, 4 # System call to print string
la $a0, fnf # Load Error String
syscall
# Done
done:
li $v0, 10 # Exit Syscall
syscall
Dies ist die Datei, dass dieses Programm liest. Es heißt input.txt.QtSpim Mit einer TXT-Datei zu lesen und bearbeiten richtige Aktivierung in Assembler-Code haben
das ist sehr informativ, aber ich wünschte es gäbe mehr Bilder WOW !!!!!!!!!!! WIE SO COOL! Ich denke, dass Sie einen Folgeartikel schreiben sollten, der das Problem weiter ausdehnt. Wir brauchen eine aufschlussreichere Meinung wie Ihre. GREAT! SCHREIBE EINE ANDERE!
Das Programm benötigt die TXT-Datei zu bearbeiten, so dass der erste Buchstabe nach einer gewissen Zeit, ein Zeilenvorschub (Newline), Ausrufezeichen oder Fragezeichen aktiviert ist, und alles unerwünschten Aktivierung loszuwerden.
Ich weiß, ich nehme ASCII-Codes und xoder die Bits, um das ASCII-Zeichen zu ändern und dann in einen Buchstaben zu konvertieren. Dies liegt daran, dass die Bitfolge "00100000" 32 in Dezimal mit dem logischen Operator "XOR" zur Änderung der Großschreibung verwendet werden kann.
Die 8-Bit-ASCII-Darstellung für der Großbuchstabe "A" ist 01000001. Wenn Sie XOR mit 0010000, erhalten Sie 01100001, den ASCII-Code für Kleinbuchstaben "a".
Aber ich kann diese Operation nur an den Buchstaben durchführen, alle Sonderzeichen bleiben gleich.
Also ich denke, ich brauche etwas Code wie folgt zu verwenden: xori $ s3, $ s3,32
nicht sicher, wie dies obwohl in meinem Programm zu implementieren. Danke für die Hilfe.