Subversion Repositories NedoOS

Rev

Rev 126 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;; Test case for IFUSED / IFNUSED ;;
  3. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4.  
  5. ;; Compilation:
  6. ;;      sjasmplus.exe ifused_test.asm --lstlab --lst=ifused_test.lst
  7. ;;
  8. ;; After compilation, please check the listing file "ifused_test.lst"
  9.  
  10.  
  11. ;; This must generate syntax errors
  12.  
  13.         IFUSED
  14.         IFNUSED
  15.  
  16. ;; All rest of code must be compiled without errors
  17.  
  18. start
  19.  
  20. ;; Some little user program :)
  21.  
  22. .noused call    EnableInt
  23. .used   call    Wait
  24.         jr      .used
  25.  
  26. ;; Some little direct tests
  27.  
  28.         IFUSED
  29.         db      'ok'
  30.         ELSE
  31.         db      'fail'
  32.         ENDIF
  33.  
  34.         IFNUSED
  35.         db      'fail'
  36.         ELSE
  37.         db      'ok'
  38.         ENDIF
  39.  
  40.         IFUSED  .used
  41.         db      'ok'
  42.         ENDIF
  43.  
  44.         IFUSED  .noused
  45.         db      'fail'
  46.         ENDIF
  47.  
  48.         IFUSED  not_defined_label
  49.         db      'fail'
  50.         ENDIF
  51.  
  52. ;; Some little library :)
  53.  
  54. EnableInt
  55.         IFUSED  EnableInt
  56.         ei
  57.         ret
  58.         ENDIF
  59.  
  60. Wait    IFUSED
  61.         ld      b,#FF
  62. .loop
  63.         IFUSED  EnableInt
  64. .halter halt
  65.         ELSE
  66.         ld      c,#FF           ;; When the "call EnableInt" is commented out,
  67. .cycle  dec     c               ;; this branch after ELSE must be generated.
  68.         jr      nz,.cycle
  69.         ENDIF                   ;; End of IFUSED EnableInt
  70.  
  71.         djnz    .loop
  72.         ret
  73.         ENDIF                   ;; End of IFUSED Wait
  74.  
  75. ;; ADDENDUM: different code path to generate some more syntax errors
  76.         IFUSED  Invalid&Label   ; there's no obvious way how to hit "invalid label"
  77.         IFNUSED Invalid%Label   ; error message, the GetID is too much foolproof.
  78.