Files
compilers/9LAB/bar3.asm
T

43 lines
1.0 KiB
NASM

# PACKAGE foo
.data # Data section starts here, strings first
_NL: .asciiz "\n" # NEWLINE STRING
.align 2 # start all global variable aligned
y: .word 7 # global var initialized
Z: .space 4 # global var uninitialized
A: .space 400 # global var uninitialized
x: .word 1 # global var initialized
.text # start of text segment (code)
.globl main # Force MIPS to start at main label
main: # MAIN METHOD LABEL
subu $t0 $sp 16 #set up $t0 to be the new spot for SP
sw $ra ($t0) #Store the return address in offset 0
sw $sp 4($t0) #Store the old stack pointer in offset 4
move $sp $t0 #set the stack pointer to the new value
#EMIT PRINT INT HERE
li $a0, 5 #expr constant value
li $v0 1 #set up write call
syscall #print a number
li $v0, 4 #print NEWLINE
la $a0, _NL #print NEWLINE string location
syscall #call print a NEWLINE
li $v0 0 #return NULL zero (0)
lw $ra ($sp) #reset return address
lw $ra 4($sp) #reset stack pointer
li $v0, 10 #Main function ends
syscall #MAIN FUNCTION EXIT