![]() |
| ||
| MIPS: Print array in columns (SPIM) I have written a code that prints array in 6 columns: # ----- I can't get the elements aligned however. We can asume that the longest length of the integer is 8, and must be right justified. Could you please guide me on how to do this? Thanks. |
| ||
| Re: MIPS: Print array in columns (SPIM) - format integer as a string in some memory buffer - measure it's length - output 8-len spaces - output buffer |
| ||
| Re: MIPS: Print array in columns (SPIM) Use a static buffer 256 or so bytes in size. Plenty of room! You can subtract the current add new character position from the buffer base to get your index. Do a modulus operation and advance that many slots by inserting spaces. OR you can have a moving partition. NEXT = THIS + 12 space. print column entry, If THIS < NEXT SKIP = NEX - THIS print skip spaces. OR prefill entire buffer with spaces (0x20). Then merely skip, no fill needed since its prefilled. But don't forget your ASCIIz terminator after the last column! |
| ||
| Re: MIPS: Print array in columns (SPIM) You can also print character by character but your column position logic remains the same. Instead of inserting spaces, write spaces. |
| ||
| Re: MIPS: Print array in columns (SPIM) Thanks all! Working on that part of my program now. |
| All times are GMT -4. The time now is 1:12 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC