Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # largo 40
- # origen 36
- # destino 32
- # SF_SIZE 32
- ##STACKFRAME
- ##SRA
- # PADDING 28
- # RA 24
- # FP 20
- # GP 16
- ## LTA
- # PADDING 12
- # ITERADOR 8
- # HI 4
- # LO 0
- .data
- hex_array: .asciiz "0123456789abcdef"
- .text
- .align 2
- .global hex_dump
- .ent hex_dump
- hex_dump:
- .frame $fp,$fp,SF_SIZE
- .set noreorder
- cpload t9
- .set reorder
- subu sp,sp, SF_SIZE
- .cprestore GP
- sw $fp,FP(sp)
- sw ra,RA(sp)
- move $fp, sp
- ## FIN RECETA
- sw a0,destino($fp)
- sw a1,origen($fp)
- sw a2,largo($fp)
- li t0,0
- sw t0,ITERADOR($fp)
- ## condicion de corte del loop
- LOOP:
- lw t0,ITERADOR($fp)
- lw t1,largo($fp)
- beq t0,t1,FIN_LOOP
- ## logica del loop
- ## me traigo el contenido del origen evaluado en el iterador (lo tengo en t0 el iterador, mala practica)
- lw t1,origen($fp)
- addu t2,t0,t1 ## direccion de src[k]
- lb t0,0(t2) ## me traigo el char
- srl t1,t0,4 ## src[k] >> 4
- sb t1,HI($fp)
- andi t3,t0,15 ## src[k] & 0xf
- sb t3,LO($fp)
- la t0,hex_array
- addu t1,t0,t3 ## t1 es la direccion de hex_array[lo]
- sb t2,0(t1) ## contenido de hex_array[lo]
- lw t0,destino($fp) ## traigo el puntero del destino
- sb t2,0(t0) ## *dest= hex_array[lo]
- ## direccion destino ++
- addiu t0,1
- sw t0,destino($fp)
- lw t3,HI($fp)
- la t0,hex_array
- addu t1,t0,t3 ## t1 es la direccion de hex_array[hi]
- sb t2,0(t1) ## contenid o de hex_array[hi]
- lw t0,destino($fp) ## traigo el puntero del destino
- sb t2,0(t0) ## *dest= hex_array[hi]
- ## direccion destino ++
- addiu t0,1
- sw t0,destino($fp)
- ## fin logica
- ## iterador++
- lw t0,ITERADOR($fp)
- addiu t0,1
- lw t0,ITERADOR($fp)
- b LOOP
- FIN_LOOP:
- lw t0,destino($fp)
- move v0,t0
- .ent hex_dump
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement