.global main # makes label "main" globally known
.text # Instructions follow
.align 2 # Align instructions to 4-byte words
main: movi r16,0x47 # Load the hexadecimal value 41
# to register r16
loop: mov r4,r16 # Copy to r4 from r16
nop # (later changed to call hexasc)
nop # (later changed to mov r4,r2)
movia r8,putchar # copy subroutine address to a register
callr r8 # call subroutine via register
addi r16, r16,1 # Add 1 to register r16
andi r16, r16, 0x7f # mask with 7 bits
ori r16, r16, 0x20 # set a bit to avoid control chars
br loop # Branch to loop
.end # The assembler will stop reading here
foo bar bletch # comes after .end - ignored
I can understand everything, I think, except how the two instructions andi and ori work in this case. ori appears to make so that the ASCII 20 positions forward is printed but why and how?
andi and ori are both bitwise operators:
To see the difference, concider”
versus
http://www.cs.umd.edu/class/sum2003/cmsc311/Notes/Mips/bitwise.html