Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

having some trouble with this simple homework...

so i have to make a program in assembly. RIT assembly to be exact, and i almoast strangled my prof cus it was driving me nuts. the lab goes like this...

In BASIC: A = 19
B = 17
C = 7
MIN = A
If( B < MIN ) then MIN = B
If( C < MIN ) then MIN = C
Print MIN

now i have to make it in RIT Assembly. RIT standing for Rational Interactive Tiny Assembly Lang. so if anyone has any clue how i can get this thing working i would really appreciate it. this is what i have so far and don't have working...

"LOD R1 V9"
"LOD R2 V17"
"LOD R3 V7"
"LOD R0 R1"
"LOD R4 R1"
"LOD R5 R2"
"LOD R6 R3"
"CMP R4"
"CMP R5"
"CMP R6"
"LOD R7 R2"
"LOD R8 R3"
"LOD R7 R4"
"LOD R8 R4"
"JGT R7 2"
"LOD R0 R2"
"JGT R8 2"
"LOD R0 R3"
"DSP R0"
"DSP R0"


Thanks,
Adam

Comments

  • e0richte0richt Member Posts: 4
    here is a possible answer to your problem...
    I don't know RIT but extrapolated from your example...

    a dw 19 ; a = 19 decimal
    b dw 17 ; b = 17 decimal
    c dw 7 ; c = 7
    min dw 0 ; min = 0

    start: ; start of program
    lod r1 a ; r1 <- a
    sto r1 min ; r1 -> min
    lod r2 b ; r2 <- b
    cmp r2 ; flags = r1 - r2
    jlt next ; if (r1 < r2) -> jump
    lod r1 r2 ; r1 <- r2
    sto r1 min ; r1 -> min
    next:
    lod r2 c ; r1 <- c
    cmp r2 ; flags = r1-r2
    jlt done ; if (r1 < r2) -> jump
    lod r1 r2 ; r1 <- r2
    sto r1 min ; r1 -> min
    done:
    dsp r1 ; display min
    ret ; return to caller

    : so i have to make a program in assembly. RIT assembly to be exact, and i almoast strangled my prof cus it was driving me nuts. the lab goes like this...
    :
    : In BASIC: A = 19
    : B = 17
    : C = 7
    : MIN = A
    : If( B < MIN ) then MIN = B
    : If( C < MIN ) then MIN = C
    : Print MIN
    :
    : now i have to make it in RIT Assembly. RIT standing for Rational Interactive Tiny Assembly Lang. so if anyone has any clue how i can get this thing working i would really appreciate it. this is what i have so far and don't have working...
    :
    : "LOD R1 V9"
    : "LOD R2 V17"
    : "LOD R3 V7"
    : "LOD R0 R1"
    : "LOD R4 R1"
    : "LOD R5 R2"
    : "LOD R6 R3"
    : "CMP R4"
    : "CMP R5"
    : "CMP R6"
    : "LOD R7 R2"
    : "LOD R8 R3"
    : "LOD R7 R4"
    : "LOD R8 R4"
    : "JGT R7 2"
    : "LOD R0 R2"
    : "JGT R8 2"
    : "LOD R0 R3"
    : "DSP R0"
    : "DSP R0"
    :
    :
    : Thanks,
    : Adam
    :
    :

  • e0richte0richt Member Posts: 4
    here is a possible answer to your problem...
    I don't know RIT but extrapolated from your example...
    [code]
    a dw 19 ; a = 19 decimal
    b dw 17 ; b = 17 decimal
    c dw 7 ; c = 7
    min dw 0 ; min = 0

    start: ; start of program
    lod r1 a ; r1 <- a
    sto r1 min ; r1 -> min
    lod r2 b ; r2 <- b
    cmp r2 ; flags = r1 - r2
    jlt next ; if (r1 < r2) -> jump
    lod r1 r2 ; r1 <- r2
    sto r1 min ; r1 -> min
    next:
    lod r2 c ; r1 <- c
    cmp r2 ; flags = r1-r2
    jlt done ; if (r1 < r2) -> jump
    lod r1 r2 ; r1 <- r2
    sto r1 min ; r1 -> min
    done:
    dsp r1 ; display min
    ret ; return to caller
    [/code]
    : so i have to make a program in assembly. RIT assembly to be exact, and i almoast strangled my prof cus it was driving me nuts. the lab goes like this...
    :
    : In BASIC: A = 19
    : B = 17
    : C = 7
    : MIN = A
    : If( B < MIN ) then MIN = B
    : If( C < MIN ) then MIN = C
    : Print MIN
    :
    : now i have to make it in RIT Assembly. RIT standing for Rational Interactive Tiny Assembly Lang. so if anyone has any clue how i can get this thing working i would really appreciate it. this is what i have so far and don't have working...
    :
    : "LOD R1 V9"
    : "LOD R2 V17"
    : "LOD R3 V7"
    : "LOD R0 R1"
    : "LOD R4 R1"
    : "LOD R5 R2"
    : "LOD R6 R3"
    : "CMP R4"
    : "CMP R5"
    : "CMP R6"
    : "LOD R7 R2"
    : "LOD R8 R3"
    : "LOD R7 R4"
    : "LOD R8 R4"
    : "JGT R7 2"
    : "LOD R0 R2"
    : "JGT R8 2"
    : "LOD R0 R3"
    : "DSP R0"
    : "DSP R0"
    :
    :
    : Thanks,
    : Adam
    :
    :

Sign In or Register to comment.