MARS MIPS simulator’s built-in assembler aligns more than requested?

TL:DR: MARS tooltips are misleading; you need to disable auto-alignment for the rest of the section using .align 0. You can’t just under-align the next word. .align 1 does align by 2, that’s not the problem. e.g. try it between .byte or .ascii pseudo-instructions. e.g. this source produces 0x00110062 as the first word of the … Read more

Error “gnu/stubs-32.h: No such file or directory” while compiling Nachos source code

You’re missing the 32 bit libc dev package: On Ubuntu it’s called libc6-dev-i386 – do sudo apt-get install libc6-dev-i386. See below for extra instructions for Ubuntu 12.04. On Red Hat distros, the package name is glibc-devel.i686 (Thanks to David Gardner’s comment). On CentOS 5.8, the package name is glibc-devel.i386 (Thanks to JimKleck’s comment). On CentOS … Read more

MIPS program that implements the same algorithm in C

(thanks for posting it). You appear to be using this definition of system calls (https://www.assemblylanguagetuts.com/mips-syscall-services-table/) Just after the beq instruction in the while: loop, you increment $s1. I recall that MIPS cpus had a timing bug where it always executed the instruction following a branch. Here, that would mean that $s1 would be one more … Read more

Can someone translate these C codes into mips assembly code

You could use this http://reliant.colab.duke.edu/c2mips/ trans of c to Mips assembly. And the following should be work. .file 1 “” .section .mdebug.abi32 .previous .gnu_attribute 4, 1 .abicalls .rdata .align 2 $LC0: .ascii “Input the string: \000” .align 2 $LC1: .ascii “%s\000” .align 2 $LC2: .ascii “*%s*\012\000” .text .align 2 .globl main $LFB0 = . .set … Read more