Howdy, Stranger!

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

Categories

translate

sodasoda Member Posts: 2
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

  • AsmGuru62AsmGuru62 Member Posts: 6,519
    : 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]
  • Shawn CarterShawn Carter Member Posts: 0

    _____ ( http://forcoder.org ) free ebooks and video tutorials about | C, Ruby, JavaScript, Assembly, Java, Perl, PHP, R, PL/SQL, Swift, Visual Basic .NET, C#, C++, Scratch, MATLAB, Visual Basic, Python, Delphi, Objective-C, Go Fortran, Prolog, D, ABAP, Clojure, Awk, ML, Alice, Scala, Scheme, Dart, FoxPro, Ada, Bash, Rust, SAS, Apex, Crystal, LabVIEW, VBScript, Kotlin, Lisp, Transact-SQL, Logo, Julia, Erlang, Lua, COBOL, F#, Hack | ________

Sign In or Register to comment.