Search code examples
assemblymipsmars-simulator

How can I set the program counter before execution in MARS simulator?


I'm trying to make MARS start execution from a specific address (0x004000A0). I tried clicking on the program counter but it won't let me edit the program counter. Is it possible to edit it, or is there any other MIPS simulator with this capability?


Solution

  •     .text 0x004000A0
        .globl main
    main:
        li $v0, 10
        syscall
    

    Settings   →   ✅  Initialize Program Counter to global 'main' if defined


    Otherwise, if you are ok having a j 0x004000A0 at the default start location 0x00400000, then you could use one of several approaches to multiple file compilation on MARS to keep that j out of your primary source code.

    • An exception handler can add code at the default text location
    • If multiple files are open in tabs will assemble them all
    • You can select "assemble all files in directory" option