Script started on Mon 17 Feb 2025 02:23:50 PM EST [mweeks@gsuad.gsu.edu@snowball ~]$ cat example1b.s # example1b.s # # java -jar /home/mweeks/rars1_6.jar example1b.s # # This is different from example1.s because it uses "addi" # instead of putting each value into registers. # # -MCW, 2025 .text main: # 1. get these values into registers # load the value 37 into x1 li x1, 37 # load the value 24 into x2 # load the value 17 into x3 #li x2, 24 #li x3, 17 # 2. add x1 to x2 #add x4, x1, x2 # 2. add x1 to 24 addi x1, x1, 24 # 3. sub x3 from (x1 + x2) #sub x4, x4, x3 # 3. add -17 to sum addi x1, x1, -17 # print x1 mv a0, x1 li a7, 1 ecall # print NL li a7, 11 li a0, 10 ecall # Exit the program with a return code li a7, 93 li a0, 0 # 0 for everything is OK ecall .data helloworld: .string "Hello World\n" [mweeks@gsuad.gsu.edu@snowball ~]$ java -jar /home/mweeks/rars1_6.jar example1b.s RARS 1.6 Copyright 2003-2019 Pete Sanderson and Kenneth Vollmar 44 [mweeks@gsuad.gsu.edu@snowball ~]$ cat example1c.s # example1c.s # # java -jar /home/mweeks/rars1_6.jar example1c.s # # This is different from example1.s because it gets all 3 values # from the data section. # # -MCW, 2025 .text main: # 1. get these values into registers # load the value 37 into x1 la x2, myvalues lb x1, 0(x2) # load the value 24 into x2 # load the value 17 into x3 #li x2, 24 #li x3, 17 # 2. add x1 to x2 #add x4, x1, x2 # 2. add x1 to 24 #addi x1, x1, 24 addi x2, x2, 1 lb x3, 0(x2) add x1, x1, x3 # 3. sub x3 from (x1 + x2) #sub x4, x4, x3 # 3. add -17 to sum #addi x1, x1, -17 addi x2, x2, 1 lb x3, 0(x2) add x1, x1, x3 # print x1 mv a0, x1 li a7, 1 ecall # print NL li a7, 11 li a0, 10 ecall # Exit the program with a return code li a7, 93 li a0, 0 # 0 for everything is OK ecall .data helloworld: .string "Hello World\n" myvalues: .byte 37, 24, -17 [mweeks@gsuad.gsu.edu@snowball ~]$ java -jar /home/mweeks/rars1_6.jar example1c.s RARS 1.6 Copyright 2003-2019 Pete Sanderson and Kenneth Vollmar 44 [mweeks@gsuad.gsu.edu@snowball ~]$ cat example1_Venus.S # example1_Venus.s # # Use VSCode/Venus for this # # -MCW, 2025 .text main: # 1. get these values into registers # load the value 37 into x1 # load the value 24 into x2 # load the value 17 into x3 li x1, 37 li x2, 24 li x3, 17 # 2. add x1 to x2 add x4, x1, x2 # 3. sub x3 from (x1 + x2) sub x4, x4, x3 # print x4 mv a1, x4 li a0, 1 ecall # print NL li a0, 11 li a1, 10 ecall # Exit the program with a return code li a0, 17 li a1, 0 # 0 for everything is OK ecall .data helloworld: .string "Hello World\n" [mweeks@gsuad.gsu.edu@snowball ~]$ cat example2.s # example2.s # # java -jar /home/mweeks/rars1_6.jar example2.s # # This movie 2001 A Space Odyssey features a computer called "HAL". # What do you get when you add 1 to each character code? This program # does that. # # -MCW, 2025 .text main: # Use s0 since it is "saved" # load the first char value into x1 la s0, mychars lb x1, 0(s0) # add 1 to it addi x1, x1, 1 # print it out as a char mv a0, x1 li a7, 11 ecall # print space li a7, 11 li a0, 32 ecall ############################## # REPEAT with small change ############################## # load the next char value into x1 lb x1, 1(s0) # add 1 to it addi x1, x1, 1 # print it out as a char mv a0, x1 li a7, 11 ecall # print space li a7, 11 li a0, 32 ecall ############################## # REPEAT with small changes ############################## # load the next char value into x1 lb x1, 2(s0) # add 1 to it addi x1, x1, 1 # print it out as a char mv a0, x1 li a7, 11 ecall # print NL li a7, 11 li a0, 10 ecall # Exit the program with a return code li a7, 93 li a0, 0 # 0 for everything is OK ecall .data mychars: .string "HAL" [mweeks@gsuad.gsu.edu@snowball ~]$ java -jar /home/mweeks/rars1_6.jar example2.s RARS 1.6 Copyright 2003-2019 Pete Sanderson and Kenneth Vollmar I B M [mweeks@gsuad.gsu.edu@snowball ~]$ exit exit Script done on Mon 17 Feb 2025 02:48:52 PM EST