Skip to content

Instantly share code, notes, and snippets.

@austin362667
Created July 5, 2022 07:35
Show Gist options
  • Select an option

  • Save austin362667/3d51997ddf561edd4bf387d9cc3dd086 to your computer and use it in GitHub Desktop.

Select an option

Save austin362667/3d51997ddf561edd4bf387d9cc3dd086 to your computer and use it in GitHub Desktop.
; source file: prog/hello.s1
; External declaration of the puts function
declare void @puts(i8* nocapture) nounwind
; Declare the string constant as a global constant.
@name = internal constant [8 x i8] c"script1\00"
; Definition of main function
define void @main(i32 %argc, i8** %argv) {
; Convert [13 x i8]* to i8 *... in local
; [FYR:getelementptr](https://llvm.org/docs/GetElementPtr.html)
%name_cast = getelementptr [8 x i8], [8 x i8]* @name, i64 0, i64 0
; Call puts function to write out the string to stdout.
call void @puts(i8* %name_cast);
ret void
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment