heey I need ur help..
how to convert a string (text content) to base 64 ??what are the steps for writing this program

thx..

heey I need ur help..
how to convert a string (text content) to base 64 ??what are the steps for writing this program

  1. base64 encodes sequences of bytes, so first you need to convert your string to bytes. How you do this depends on the language/platform you're using... if you're doing this in assembly, your text might already use a single-byte encoding.
  2. RFC 4648 describes how to encode a sequence of bytes as base64. This should be all you need to create your own implementation.

Have a go at writing it yourself, and if you have any trouble, please post your code and questions.

.data
buffer:  .space 91
prompt:   .asciiz    "\n   Please Input a value \n" 
bye:     .asciiz    "\n  ********"

  .globl main 
  .text 
main:  
 li  $v0, 4     # system call code for Print String 
 la   $a0, prompt      # load address of prompt into $a0 
 syscall      # print the prompt message 
 
 li  $v0, 8     # system call code for read string 
 la   $a0, buffer      # load address of buffer into $a0 
 li $a1, 91   #string is 91 bytes long
 syscall      # print the prompt message 
 la $a2,($a0)
 la $t0,($a2)
 move $t7,$zero
 j loop
loop: beq $t4,90,end
 
 
 lb $t1,($t0)
 beq $t1,10,end
 sll $t1,$t1,16
 addi $t0,$t0,1
 lb $t2,($t0)
 beq $t2,10,case1
 sll $t2,$t2,8
 addi $t0,$t0,1
 lb $t3,($t0)
 beq $t3,10,case2
 or $t1,$t1,$t2
 or $t1,$t1,$t3
 addi $t0,$t0,1
 srl $t3,$t1,18
 addi $t3,$t3,65
 sgt $t5,$t3,90
 beq $t5,1,ascii
 
 li $v0,11
 la $a0,($t3)
 syscall
 
 srl $t3,$t1,12
 andi $t3,$t3,63
 addi $t3,$t3,65
 sgt $t5,$t3,90
 beq $t5,1,ascii
 
 li $v0,11
 la $a0,($t3)
 syscall

srl $t3,$t1,6
 andi $t3,$t3,63
 addi $t3,$t3,65
 sgt $t5,$t3,90
 beq $t5,1,ascii
 
 li $v0,11
 la $a0,($t3)
 syscall
 andi $t3,$t1,63
 addi $t3,$t3,65
 sgt $t5,$t3,90
 beq $t5,1,ascii
 
 li $v0,11
 la $a0,($t3)
 syscall
 addi $t4,$t4,1
 beq $t7,1,end
 j loop

I Have this error
[00400058] 102c0000 beq $1, $12, 0 [end-0x00400054]

I'm not that familiar with MIPS... add comments explaining what you're doing, and I can tell you if you're on the right track.

This article has been dead for over six months. Start a new discussion instead.