Author Topic: Calculate your daily water consumption  (Read 605 times)


  • Member
  • *****
  • Posts: 13944
  • Assembly is fun ;-)
    • MasmBasic
Calculate your daily water consumption
« on: May 30, 2022, 06:39:04 AM »
include \masm32\MasmBasic\                        ; download
  MovVal ST(0), Input$("\nConsumption: ", "500")               ; ask e.g. for cubic metres of water
  movaps xmm1, TimeSF(Input$("older date: ", fDate$(-30)))     ; suggest thirty days before today
  psubq TimeSF(Input$("newer date: ", fDate$())), xmm1         ; subtract from today
  FpuPush TimeDiff(d)
  Print Str$("%i days between the two dates\n", ST(0))         ; display difference in days
  Inkey Str$("Consumption per day: %3f units", ST(0)v)         ; calculate consumption per day

The strings "500", fDate$(-30) and fDate$() are suggestions and can be edited by the user with the arrow and backspace keys. The consumption can be any number, e.g. 1.5; the dates must be entered in the correct format - sorry, U.S. format won't work :cool:


Code: [Select]
Consumption: 500
older date: 29.01.2022
newer date: 29.05.2022
120 days between the two dates
Consumption per day: 4.17 units

Macros used: MovVal, Input$(), TimeSF(), fDate$(), TimeDiff(), FpuPush, Str$(), Inkey