translate

how do i translate this into assembly code using only move, sub, add, beq, and bne?

if x>12 then x:=2*x+4 else x:=x+y

Comments

  • : how do i translate this into assembly code using only move, sub, add, beq, and bne?
    :
    : if x>12 then x:=2*x+4 else x:=x+y
    :
    [blue]
    mov ax, x
    mov dx, y

    cmp ax, 12
    ja X_ABOVE_12

    add ax, dx ; X=X+Y
    jmp AFTER_IF

    X_ABOVE_12:
    shl ax, 1 ; X=2*X
    add ax, 4 ; +4

    AFTER_IF:
    ; --- Use AX here as X
    [/blue]
Sign In or Register to comment.

Howdy, Stranger!

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

Categories

In this Discussion