Simply Assembly Program Questions

Discussion in 'OT Technology' started by n9e9o9, Feb 12, 2004.

  1. n9e9o9

    n9e9o9 lol OT Supporter

    Joined:
    Aug 26, 2003
    Messages:
    5,083
    Likes Received:
    0
    Location:
    ATX
    Hi! :)

    I could use some help with making this basic Assembly program for my intro comp class (Ive had little exp wit programming). These are the instructions:

    "Assume that memory locations 79 and 80 are preset with the values 0 and 1 respectively (this will help you). Write in *Little Man Language a program that will read in two numbers and will output a 0 if they are equal and a 1 if they are not."

    *Note: the Little Man Computer is Java applet from this website... http://www.cs.yorku.ca/~peterc/simulator/simulator.html

    Some of the functions I can only use:
    STOP
    LOAD
    STORE
    ADD
    SUBTRACT
    READ
    PRINT
    BRANCH
    BRANCHZ
    BRANCHP

    So far this is what I have:

    00 READ
    01 STORE 13
    02 PRINT
    03 READ
    04 STORE 14
    05 PRINT
    06 LOAD 13

    I'm not sure where to go with this.......how do equate two numbers when you can only store one number in the register?

    Thanks for any help. :bigthumb:
     
  2. Astro

    Astro Code Monkey

    Joined:
    Mar 18, 2000
    Messages:
    2,047
    Likes Received:
    0
    Location:
    Cleveland Ohio
  3. EkriirkE

    EkriirkE Zika Xenu OT Supporter

    Joined:
    Jan 11, 2004
    Messages:
    14,799
    Likes Received:
    0
    Location:
    Dublin & San Francisco, CA
    Child's play.
    Assuming BranchZ X means "goto X if the last math instruction resulted in 0"
    Use subtranction to compare the numbers A & B

    I'm guessing this pseudo machine LOADs X into an "internal register", then the math routines use that number in conjunction with the second number for that instruction

    like to display the addition of what is in location 13 and 14 would work like
    LOAD 13
    ADD 14
    PRINT

    if A-B is 0 then they are equal, branchz to a spot where you can Print 0
    otherwise print 1 and terminate
     
    Last edited: Feb 12, 2004
  4. n9e9o9

    n9e9o9 lol OT Supporter

    Joined:
    Aug 26, 2003
    Messages:
    5,083
    Likes Received:
    0
    Location:
    ATX
    ok how do u print a 1? i got the BRANCHZ part down but not sure how to display the one.....
     
  5. EkriirkE

    EkriirkE Zika Xenu OT Supporter

    Joined:
    Jan 11, 2004
    Messages:
    14,799
    Likes Received:
    0
    Location:
    Dublin & San Francisco, CA
    Java is broken here ATM so I can't try for myself. You probably need to set aside a byte in memory set to 1, then LOAD that location and PRINT since it looks like you can't programatically set the register to a value
     

Share This Page