0

So i wrote this MARIE code and every time I try to run it it prompts me to enter an input when I never put Input anywhere in the code. The code is supposed to call 2 subroutines PUSH and POP where push pushes the elements 4,6,8 into the stack and POP, removes them

Here is the code:

ORG 000
PTR, HEX 0002
STACK, HEX 1111
 HEX 2222
 HEX 3333
 HEX 4444
 HEX 5555
 HEX 6666
 HEX 7777
A, HEX 0004
B, HEX 0006
C, HEX 0008
ONE, HEX 0001
PBUFF,HEX 1234
Load A
Store PBUFF
JnS PUSH
Load B
Store PBUFF
JnS PUSH
Load C
Store PBUFF
JnS PUSH
Halt
PUSH, HEX 000
 Load PBUFF
 StoreI PTR
 Output
 Load PTR
 Add ONE
 Store PTR
 JUMP PUSH // Use a regular JUMP instead of JUMP I (0)
POP, HEX 000
Load PTR // Load the current value of PTR
Subt ONE // Decrement PTR
Store PTR // Store the updated value back in PTR
LoadI PTR // Load the value from the stack at the updated address
Output / Output the value
Halt

I've been working with a tutor for 2 days know and neither of us know whats wrong with the code and why its doing that.

Daniel A. White
192k49 gold badges389 silver badges474 bronze badges
asked Nov 17, 2023 at 0:46
3
  • 2
    MARIE code starts executing from address 0 - but you don't have code at address 0, you have various pieces of initialized data. Each of those values is going to do SOMETHING when executed, and apparently one of those values is actually an Input opcode. You need to move all your data to someplace after the main code - it could either be before or after your subroutines. Commented Nov 17, 2023 at 1:00
  • Try single stepping to see what's happening. The problem is that you're missing a the concept of an entry point, which could be as simple as jumping forward past your data. And you'll see this immediately if you attempt to single step. Commented Nov 17, 2023 at 15:39
  • You asked a question before about MARIE, and didn't give any feedback to the answer that was given. That's not very motivating. Commented Jul 24, 2024 at 14:40

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.