        title       Macro Demo Program
        include     irvine32.inc
        include     my-macs.inc
        
show    macro       where                   ; Simple macro to do output
        mov         edx, offset where
        call        writestring
        endm

        .data
temp    byte        ?
trange  byte        -40, -20, 0, 16, 32, 50, 70, 80, 95, 120
rating  byte        "Polar     ", 0, "Frigid    ", 0, "Icy       ", 0, "Very Cold ", 0
        byte        "Cold      ", 0, "Cool      ", 0
        byte        "Mild      ", 0, "Warm      ", 0, "Hot       ", 0, "Oppressive", 0
hrday   word        ?
cat     byte        "Kid      ", 0, "Teen     ", 0, "Wreckless", 0, "Rational ", 0
        byte        "Steady   ", 0, "Mature   ", 0, "Foggie   ", 0
arange  word        12, 19, 26, 35, 45, 60, 120
age     dword       ?
p1      byte        0dh, 0ah, "What is today's high temperature? ", 0
p2      byte        "How old are you (in hours)? ", 0
p3      byte        "How many hours did you work this year? ", 0
years   word        ?
r1      byte        "Today is ", 0
r2      byte        " with a temperature of ",0
r3      byte        0dh,0ah, "Meanwhile, you are at the ", 0
r3b     byte        " age, about ", 0
r4      byte        " years old ", 0dh, 0ah, "and worked about", 0
r5      byte        " days this year.", 0dh, 0ah, 0
        .code
main    proc
top:
        show    p1              ; Ask about and get the temperature
        innum   temp
        cmp     temp, 120       ; Terminate on temp > 120 (and < 128)
        jg      done
        show    p2              ; Ask about and get age in hours
        innum   age
        show    p3              ; Ask about and get hours worked
        innum   hrday
        mov     ebx, 365*24     ; Calculate age in years (approx)
        mov     eax, age
        cdq
        div     ebx
        mov     years, ax
        sar		hrday, 3		; Calculate days worked
        find    arange, years   ; Search age ranges for category
        mov     ebx, 10
        mul     ebx
        mov     esi, eax        ; Set up index for category display
        add     esi, offset cat
        find    trange, temp    ; Search temp ranges for weather
        mov     ebx, 11
        mul     ebx
        mov     edi, eax
        add     edi, offset rating  ; Set up index for weather display
        show    r1                  ; Output results
        mov     edx, edi
        call    writestring         ; Insert weather
        show    r2
        outnum  temp
        show    r3
        mov     edx, esi
        call    writestring         ; Insert category
        show    r3b
        outnum  years
        show    r4
        outnum  hrday
        show    r5
        jmp     top                 ; Do it all again
done:
        exit
main    endp

end     main
