Skip to content

Instantly share code, notes, and snippets.

@danmux
Last active December 17, 2015 22:32
Show Gist options
  • Save danmux/60123934a396f4faf981 to your computer and use it in GitHub Desktop.
Save danmux/60123934a396f4faf981 to your computer and use it in GitHub Desktop.
// single if statement
a := 4 // MOVIR R0, 4 --
// RTOI R1, R0 -- R1 = local integer variable int
if a == 5 {
// SUBI R2,R1,5 -- subtract 5 from R1 and store result in R2
// BNEZ R2,LABEL2 -- if R2 !=0 then a != 5 so jump past next code block
a = 3 // MOVIR R0, 3 --
// RTOI R1, R0 -- convert to int
}
// LABEL2:
// ... code block 2 ...
@danmux
Copy link
Author

danmux commented Dec 17, 2015

//  if else statement

a := 4                    //    MOVIR R0, 4     --  
                          //    RTOI R1, R0     -- R1 = local integer variable int

if a == 5 {               
                          //    SUBI R2,R1,5    -- subtract 5 from R1 and store result in R2
                          //    BNEZ R2,LBLELSE -- if R2 !=0 then a != 5 so jump to the else block

    a = 3                 //    MOVIR R0, 3     --  
                          //    RTOI R1, R0     -- convert to int
                          //    JMP CONTINUE    -- skip the else block - jump to CONTINUE
} else {

                          // LBLELSE:
//  ... code block 2 ...

}
                          // CONTINUE:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment