برنامج بلغة الاسمبلي يطلب من المستخدم ادخال قيمة عددية ومن ثم يقوم بطباعة مربع هذة القيمة .
.data
hello_msg: .asciiz "Program to find square integer !\n";
hello_msg1: .asciiz "Inter Value !\n";
hello_msg3: .asciiz "The Square of value is !\n";
#-------------------------------------------------------------------------------
.text
main:
la $a0, hello_msg
li $v0, 4
syscall
#-------------------------------------------------------------------------------
la $a0, hello_msg1
li $v0, 4
syscall
#-------------------------------------------------------------------------------
li $v0, 5 # Read integer
syscall # $v0 = value read
#-------------------------------------------------------------------------------
move $t0, $v0 # or use mul $st0,$v0,$v0
#-------------------------------------------------------------------------------
la $a0, hello_msg3
li $v0, 4
syscall
#-------------------------------------------------------------------------------
mul $v0,$t0,$t0
move $a0, $v0 # $a0 = value to print
#-------------------------------------------------------------------------------
li $v0, 1 # Print integer
syscall
#-------------------------------------------------------------------------------
li $v0, 10 # Exit program
syscall