GIDForums  

Go Back   GIDForums > Computer Programming Forums > Assembly Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 27-Apr-2009, 15:41
theduff theduff is offline
New Member
 
Join Date: Apr 2009
Posts: 2
theduff is on a distinguished road

Reverse bit order in MIPS/SPIM


Here is what I have so far.

The program receives and echos characters without syscalls.

I am trying to add 2 procedures(rev7 and putint)

Rev7: Reverses the least significant 7 bits and outputs $s2

Putint: Prints the decimal value of $s2.

When i run it, it echos the character then prints a "P". I have no idea where that comes from.

Everything seems correct to me but I do not understand why it does not print the decimal digits

Code:
.data hello: .asciiz "Enjoy This Program\nExit with !\n" bye: .asciiz "\nThanks for using this program\n\nGood-Bye\n" space: .asciiz " " endl: .byte 10 carr: .byte 13 stack: .space 99 .text .globl main main: la $a0, hello #print hello jal putc puts: jal getc beq $v0, 33, end #BRANCH ON ! to exit message beq $v0, 10, newline #branch on newline to print carriage return and linefeed la $a0, space sb $v0, ($a0) jal putc jal rev7 #NEW for project 4 j puts getc: lw $v0, 0xffff0000 andi $v0, $v0, 0x01 beq $v0, $zero, getc #check if device is ready and read, else branch back to getc lw $v0, 0xffff0004 j $ra putc: li $a1, 0xffff0000 lw $v0, 8($a1) andi $v0, $v0, 0x01 beq $v0, $zero, putc #check if device is ready and print, else branch back to putc sw $t0, 12($a1) lbu $t0, ($a0) addi $a0, $a0, 1 bne $t0, $zero, putc j $ra newline: la $a0, endl #print \n linefeed and \r carriage return jal putc la $a0, carr jal putc b puts rev7: li $s0, 7 add $s1, $0, $v0 add $s2, $0, $0 shift: andi $t0, $s1, 1 # beq $t0, $0, skip ori $s2, $s1, 1 skip: srl $s1, $s1, 1 sll $s2, $s2, 1 sub $s0, $s0, 1 bgez $s0, shift putint: add $t2, $0, $s2 la $t0, stack loop_putint: rem $t3, $t2, 10 add $t0, $t0, 1 div $t2, $t2, 10 bgtz $t2, loop_putint la $t1, stack print_putint: add $t0, $t0, -1 lb $v0, 0($t0) jal putc bgt $t0, $t1, print_putint b puts end: la $a0, bye # print bye message and exit jal putc li $v0,10 syscall
  #2  
Old 02-May-2009, 11:20
Howard_L Howard_L is offline
Regular Member
 
Join Date: Apr 2007
Location: Maryland/PA, USA
Posts: 803
Howard_L is a jewel in the roughHoward_L is a jewel in the roughHoward_L is a jewel in the rough

Re: Reverse bit order in MIPS/SPIM


I see the 'P' you're talking about.
Have you solved this yet or do you still need some help?
If so I can look into it more later today.
  #3  
Old 02-May-2009, 15:09
theduff theduff is offline
New Member
 
Join Date: Apr 2009
Posts: 2
theduff is on a distinguished road

Re: Reverse bit order in MIPS/SPIM


Ya I did get it figured out. Thanks though
 
 

Recent GIDBlogProgramming ebook direct download available by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
CPanel Hosting, Teamspeak 2 Hosting, SHOUTcast Hosting, As Low As $2.00 per Month Kalypsoweb Web Hosting Advertisements & Offers 0 30-Jul-2006 17:00
Reverse DNS entries admin Web Hosting Forum 1 21-Apr-2006 11:39
Reverse functions and Reverse checking functions jenmaz C Programming Language 4 24-Nov-2004 09:48
Two virtual hosts, cgi script behaves differently on each blimbo Apache Web Server Forum 0 04-Aug-2004 10:35
Can't view pages from another machine on the Intranet aevans Apache Web Server Forum 9 14-May-2004 03:26

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 01:08.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.