Jump to content
  • Revista PROGRAMAR: Já está disponível a edição #60 da revista programar. Faz já o download aqui!

Razvancb

Codificação de uma mensagem

Recommended Posts

Razvancb

Boas pessoal.
Sou completamente novo nesta linguagem, ando a aprender na fac, mas não me ando a dar muito bem com ela.

 

Preciso de criar um programa de codificação de mensagens, onde o utilizar mete a mensagem, e sempre que aparecer uma vogal, adiciona a consoante próxima à vogal.

Por exemplo:
A > B
E > F
I > J
O > P
U > V

 

Então, se a minha mensagem fosse: "Hello World", depois da encriptação seria:  "Hefllop Woprld".

Já tenho o código do input da mensagem aqui:
 

.data #let processor know we will be submitting data to program now

insert:
    .word 4 #make a 4 byte (32 bit) space in memory for a word with address insert_into

input:
    .asciiz "\Please Enter a String to Print\n" #in unused memory store this string with address Ask_Input

output:
    .asciiz "\You typed in: " #in unused memory store this string with address Tell_Output

.text #enables text input / output, kind of like String.h in C++
    

main: #main function is always called in any mips program, so the program will start here with actual assembly code

    la $a0, input #load address input from memory and store it into arguement register 0
    li $v0, 4 #loads the value 4 into register $v0 which is the op code for print string
    syscall #reads register $v0 for op code, sees 4 and prints the string located in $a0

    la $a0, insert #sets $a0 to point to the space allocated for writing a word
    la $a1, insert #gets the length of the space in $a1 so we can't go over the memory limit
    li $v0, 8 #load op code for getting a string from the user into register $v0
    syscall #reads register $v0 for op code, sees 8 and asks user to input a string, places string in reference to $a0

    la $a0, output #load address output from memory and store it into arguement register 0
    li $v0, 4 #loads the value 4 into register $v0 which is the op code for print string
    syscall #reads register $v0 for op code, sees 4 and prints the string located in $a0

    la $a0, insert #load address insert_into from memory and store it into arguement register 0
    li $v0, 4 #loads the value 4 into register $v0 which is the op code for print string
    syscall #reads register $v0 for op code, sees 4 and prints the string located in $a0

    li $v0, 10 #loads op code into $v0 to exit program
    syscall #reads $v0 and exits program

Porém, já não sei como/o que fazer a partir daqui.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.