home *** CD-ROM | disk | FTP | other *** search
/ ticalc.org / ticalc_org_rev_b.iso / archives / 86 / asm / source / triangle.asm < prev    next >
Encoding:
Assembly Source File  |  2001-07-01  |  2.6 KB  |  120 lines

  1. #include "asm86.h"
  2. #include "ti86asm.inc"
  3. #include "ti86ops.inc"
  4. #include "ti86math.inc"
  5.  
  6. ;Triangle Tester - by Elroy (elroy@usa.net)
  7. ;-----
  8. ;Input Legs and Hypotenuse, and it returns what type of
  9. ;triangle it is.  This is my first asm program, so sorry
  10. ;about any bad techniques!
  11.  
  12. ;----------  Equates  ----------
  13. _asap_ind    .equ    0D623h
  14. _clrWindow    .equ    4A86h
  15. _CPOP1OP2    .equ    41FBh
  16. _exec_pg3    .equ    5714h
  17. _homeUp        .equ    4A95h
  18. _ioprompt    .equ    0C324h
  19. _mov10b        .equ    $427b
  20.  
  21. ;----------  Program  ----------
  22. .org _asm_exec_ram
  23.     nop
  24.     jp Top
  25.     .dw $0000
  26.     .dw Str_Shell_Title
  27. Clear:
  28.     call _clrLCD
  29.     call _clrWindow
  30.     call _homeUp
  31.     ret
  32. Prompt:
  33.     call _mov10b            ;move to prompt buffer, 10 bytes
  34.     ld a,0Dh
  35.     ld (_asap_ind),a
  36.     call _exec_pg3
  37.     ret
  38. Top:
  39.     call Clear
  40.     ld hl,Str_Title
  41.     call _puts
  42.     ld bc,$0003            ;row 3 column 0
  43.     ld (_curRow),bc
  44.     ld de,_ioprompt
  45.     ld hl,Str_Prompt1        ;load prompt string
  46.     call Prompt            ;prompt and move to op1
  47.     call _OP1TOOP4            ;move op1 to op4
  48.     ld de,_ioprompt
  49.     ld hl,Str_Prompt2
  50.     call Prompt
  51.     call _OP1TOOP5
  52.     ld de,_ioprompt
  53.     ld hl,Str_Prompt3
  54.     call Prompt
  55.     call _OP1TOOP6            ;op4 = A, op5 = B, op6 = C
  56.     call _OP4TOOP1            ;op1 = A
  57.     call _OP5TOOP2            ;op2 = B
  58.     call _FPADD            ;op1 = A+B
  59.     call _OP1TOOP2            ;op2 = A+B
  60.     call _OP6TOOP1            ;op1 = C
  61.     call _CPOP1OP2            ;test (A+B)-C
  62.     jp m,Test            ;if negative jump to Test
  63.     ld hl,Str_Fail            ;else load failure string
  64.     jp Exit                ;and jump to Exit
  65. Test:
  66.     call _OP4TOOP1            ;op1 = A
  67.     call _FPSQUARE            ;op1 = A^2
  68.     call _OP1TOOP4            ;op4 = A^2
  69.     call _OP5TOOP1            ;op1 = B
  70.     call _FPSQUARE            ;op1 = B^2
  71.     call _OP1TOOP5            ;op5 = B^2
  72.     call _OP6TOOP1            ;op1 = C
  73.     call _FPSQUARE            ;op1 = C^2
  74.     call _OP1TOOP6            ;op6 = C^2
  75.     call _OP4TOOP1            ;op1 = A^2
  76.     call _OP5TOOP2            ;op2 = B^2
  77.     call _FPADD            ;op1 = A^2+B^2
  78.     call _OP6TOOP2            ;op2 = C^2
  79.     call _CPOP1OP2            ;test (A^2+B^2)-C^2
  80.     jp z,Right            ;if answer is zero jump to Right
  81.     jp m,Obtuse            ;if answer is negative jump to Obtuse
  82.     ld hl,Str_Acute            ;else it's acute
  83.     jp Exit
  84. Right:
  85.     ld hl,Str_Right
  86.     jp Exit
  87. Obtuse:
  88.     ld hl,Str_Obtuse
  89. Exit:
  90.     ld bc,$0107            ;column 1 row 7
  91.     ld (_curRow),bc
  92.     set 3,(iy+05)            ;inverse text
  93.     call _puts            ;display string
  94.     res 3,(iy+05)            ;normal text
  95.     call _getkey
  96.     call Clear
  97.     ret
  98.  
  99. ;---------- Variables ----------
  100. Str_Title:
  101.     .db "Triangle Tester      "
  102.     .db "elroy@usa.net",0
  103. Str_Prompt1:
  104.     .db "Leg 1:",0
  105. Str_Prompt2:
  106.     .db "Leg 2:",0
  107. Str_Prompt3:
  108.     .db "Hyp. :",0
  109. Str_Fail:
  110.     .db "Impossible triangle",0
  111. Str_Acute:
  112.     .db "  Acute triangle   ",0
  113. Str_Right:
  114.     .db "  Right triangle   ",0
  115. Str_Obtuse:
  116.     .db "  Obtuse triangle  ",0
  117. Str_Shell_Title:
  118.     .db "Triangle Tester",0
  119. .end
  120.