Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
cse3666-2024spring/lab0/01-hello.s
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
23 lines (19 sloc)
873 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# RISC-V Example in RARS | |
# Comments. Anything after # is comments. | |
# .data starts data segments | |
.data | |
# msg is a label in data segment | |
# .asciz specifies an ASCII string ends with a NUL character | |
# we can also use ".string", instead of ".asciz" | |
msg: .asciz "Hello, welcome to CSE 3666.\n" | |
# .text starts code segments | |
.text | |
.globl main # declare main to be global. Note it is ".globl" | |
# define a label, in code segment | |
main: | |
la a0, msg # load the address of the string | |
addi a7, zero, 4 # set the system call number. 4 for printing a string | |
ecall # system call | |
# system call 10: exit with code 0 | |
addi a7, zero, 10 # set the system call number | |
ecall # system call |