# Last modified on Wed Feb 8 13:41:01 PST 1995 by heydon # # Add two user-supplied numbers # # PROCEDURE r1 := ReadNum() IS <10> # t1 :: Print("Enter a number: ") # ; t1 := Readln() # ; r1 := Atof(t1) # END # # PROCEDURE Main() IS <11> # r1, r2, t1 :: r1 := ReadNum() # ; r2 := ReadNum() # ; t1 := FmtReal(Atof(r1 + r2)) # ; Print("Sum: "); Print(t1); Print("\n") # END # # BEGIN <12> # Main() # END. V0 "Enter a number: " V1 "Invalid arguments to ADD" V2 "Sum: " V3 "\n" V4 1.2 V5 2.3 C11 # INCSP 3 (r1, r2, t1) .INCSP b3 .PUSHG c4 .PUSHG c5 # ADD UNDEF .ADD s3 # JUMP DEF .JUMP s2 # UNDEF: ERROR .ERROR b1 # DEF: POPL t1 .POPL s3 # PUSHG 2 "Sum: " .PUSHG c2 # CALLEXT Print .CALLEXT c0 # INCSP 1 .INCSP b1 # PUSHL t1 .PUSHL s3 # CALLEXT FmtReal .CALLEXT c2 # DECSP 1 .DECSP b1 # CALLEXT Print .CALLEXT c0 # PUSHG 3 "\n" .PUSHG c3 # CALLEXT Print .CALLEXT c0 # RET .RET # Change one of the numbers following the END to a non-number to see # Error Handling END 1.2 2.3