0

What I am attempting is to compare 2 numbers in assembly language and display the largest of the two numbers, as shown in the pseudo code below.

I am using this website here to do this http://www.peterhigginson.co.uk/RISC/

Here is what I am came up with: INP R0,2 INP R1,2 CMP R0,R1 BGT OUT R0,4 BLT OUT R1,4 However I am getting the error 'bad parameter at line 3 BGT'. I am not sure why I am getting this however I suspect it may be something to do either with indentations or not including a loop or something.

Any help on how to solve this would be much appreciated. Here is the instruction set if anyone is interested. http://www.peterhigginson.co.uk/RISC/instruction_set.pdf

fuz
  • 88,405
  • 25
  • 200
  • 352
  • Branches require a label as target (in your simulator you might only be allowed to use numerical addresses though). – Jester Feb 28 '17 at 22:37
  • @old_timer the instruction set is based on the ARM processor, new and thought some people over there could help me – Lewis Watkins Feb 28 '17 at 22:41
  • @LewisWatkins Please only tag [arm] when your question is about ARM assembly. Something that is merely inspired by ARM should not be tagged as ARM as that is misleading. – fuz Feb 28 '17 at 22:42
  • inspired by arm perhaps but not arm. – old_timer Feb 28 '17 at 22:42
  • sounds like you simply have a syntax error, look at other examples or the documentation to find the syntax for conditional branches. from links you sent us you have extra stuff on the line. – old_timer Feb 28 '17 at 22:44
  • alright cheers mate – Lewis Watkins Feb 28 '17 at 22:45

2 Answers2

0

here's my approach:

        INP R0,2
        INP R1,2
        CMP R0,R1
        BGT g1
        OUT R1,4
        HLT
g1:     OUT R0,4
Tommylee2k
  • 2,683
  • 1
  • 9
  • 22
-1

try this:

        INP R0,2
        INP R1,2
    l1:     CMP R0,R1
        BGT g1
        BLT g2
        BEQ g2
    g1: OUT R0,4
    g2: OUT R1,4
Ria
  • 10,237
  • 3
  • 33
  • 60
  • in the end, you'll always have out'ed R1. Add some "HLT" after OUTing. Also 2 of the branches aren't really needed, if you order the OUTs right – Tommylee2k Mar 01 '17 at 15:06