2025-01-27 19:19:11 +00:00
|
|
|
record source_filename = "Sum.im"
|
|
|
|
|
|
|
|
|
|
record package_scope = "net.doorstuck.test"
|
|
|
|
|
|
|
|
|
|
data @.str.0 = str "Finds the sum of a set of numbers."
|
|
|
|
|
data @.str.1 = str "Number (blank to finish): "
|
|
|
|
|
|
2025-04-03 10:47:24 +01:00
|
|
|
define void _() static {
|
2025-01-27 19:19:11 +00:00
|
|
|
; cout put:'Finds the sum of a set of numbers.'
|
|
|
|
|
%1 = alloca id
|
|
|
|
|
store id @.str.0, ptr %1
|
|
|
|
|
|
|
|
|
|
%2 = load ptr %1
|
|
|
|
|
%3 = load id @cout
|
|
|
|
|
|
|
|
|
|
call @_M03putE(id %3, id %2)
|
|
|
|
|
|
|
|
|
|
L0001.cond:
|
|
|
|
|
br label @L0001.body
|
|
|
|
|
|
|
|
|
|
L0001.body:
|
|
|
|
|
; cout
|
|
|
|
|
%4 = load id @cout
|
|
|
|
|
|
|
|
|
|
; 'Number (blank to finish): '
|
|
|
|
|
%5 = alloca id
|
|
|
|
|
store str @.str.1, ptr %5
|
|
|
|
|
|
|
|
|
|
;; cout print:'Number (blank to finish): '
|
|
|
|
|
call @_M05printE(id %4, id %5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; cout
|
|
|
|
|
%6 = load id @cout
|
|
|
|
|
|
|
|
|
|
;; cout flush
|
|
|
|
|
call @_M5flushE(id %6)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; v
|
|
|
|
|
%7 = alloca i32
|
|
|
|
|
|
|
|
|
|
; 0
|
|
|
|
|
%8 = i32 #0
|
|
|
|
|
|
|
|
|
|
;; v = 0
|
|
|
|
|
store i32 %8, ptr %7
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; input
|
|
|
|
|
%9 = alloca id
|
|
|
|
|
|
|
|
|
|
; cin
|
|
|
|
|
%10 = load id @cin
|
|
|
|
|
|
|
|
|
|
; cin readLine
|
|
|
|
|
%11 = call @_M8readLineE(id %10)
|
|
|
|
|
|
|
|
|
|
;; input = cin readLine
|
|
|
|
|
store id %11, ptr %9
|
|
|
|
|
|
|
|
|
|
L0002.if:
|
|
|
|
|
; ''
|
|
|
|
|
%12 = load ptr @String
|
|
|
|
|
%13 = call @_M3newE(id %12)
|
|
|
|
|
|
|
|
|
|
; input
|
|
|
|
|
%14 = load ptr %9
|
|
|
|
|
|
|
|
|
|
; input == ''
|
|
|
|
|
%15 = cmp eq id %14, %13
|
|
|
|
|
|
|
|
|
|
;; if input == ''
|
|
|
|
|
br i1 %15, label @L0002.then, label @L0002.else
|
|
|
|
|
|
|
|
|
|
L0002.then:
|
|
|
|
|
;; then
|
|
|
|
|
|
|
|
|
|
; break
|
|
|
|
|
br label @L0001.end
|
|
|
|
|
|
|
|
|
|
br label @L0002.end
|
|
|
|
|
|
|
|
|
|
L0002.else:
|
|
|
|
|
;; else
|
|
|
|
|
br label @L0002.end
|
|
|
|
|
|
|
|
|
|
L0002.end:
|
|
|
|
|
;; end
|
|
|
|
|
|
|
|
|
|
; Int
|
|
|
|
|
%17 = load id @Int
|
|
|
|
|
|
|
|
|
|
; input
|
|
|
|
|
%18 = load ptr %9
|
|
|
|
|
|
|
|
|
|
; Int parse:input
|
|
|
|
|
%19 = call @_M5parseE(id %17, id %18)
|
|
|
|
|
|
|
|
|
|
;; v = Int parse:input
|
|
|
|
|
store id %19, ptr %7
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
L0001.end:
|
|
|
|
|
}
|