SHARE
TWEET

Untitled

a guest Jul 10th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. declare i32 @putchar(i32)
  2.  
  3. define void @putstr(i8* %a) {
  4.     %first = load i8, i8* %a
  5.     %cond = icmp eq i8 %first, 0
  6.     br i1 %cond, label %IfZero, label  %IfNotZero
  7.     IfNotZero:
  8.     %char = zext i8 %first to i32
  9.     call i32 @putchar(i32 %char)
  10.     %next = getelementptr i8, i8* %a, i8 1
  11.     call void @putstr(i8* %next)
  12.     ret void
  13.     IfZero:
  14.     ret void
  15. }
  16.  
  17. define void @main() {
  18.     %array = alloca [7 x i8]
  19.     store [7 x i8] c"hello\0A\00", [7 x i8]* %array
  20.     %arr = bitcast [7 x i8]* %array to i8*
  21.     call void @putstr(i8* %arr)
  22.     ret void
  23. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top