?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1. ; variation on more complex internal states of sjasmplus (reading multi-line from macro definition/etc)
  2.  
  3.     OUTPUT "multi_line_init2.bin"
  4.  
  5.     DB  "1) single-line classic initializers test:\n"
  6.  
  7.     STRUCT S_sub1
  8. b1      byte    $11
  9. t1      text    5, { "txt", '_' }
  10. w1      word    $3322
  11.     ENDS
  12.  
  13.     STRUCT S_main
  14. b2      byte    $44
  15. s1      S_sub1
  16.     ENDS
  17.  
  18.     ; 2x S_main instance by using dot-repeater -> no label assigned to these
  19. dotRep  .2  S_main { 'a', { 'b', { "cdefg" }, "\nh" } }
  20.  
  21.     ; 2x S_main instance by using DUP+EDUP
  22. dupRep:
  23.         DUP 2
  24.             S_main { 'i', { 'j', { "klmno" }, "\np" } }
  25.         EDUP
  26.  
  27.     ; emit structure inside macro
  28. macDef  MACRO   b1?, t1?
  29. .macSub     S_main { '<', { b1?, { t1? }, "\n>" } }
  30.         ENDM
  31.  
  32.     ; emit 2x structure inside macro with dot repeater (structs have own macro-specific label)
  33.         .2  macDef 'B', < 'C', 'D', "EF" >
  34.  
  35.         DUP 2
  36.             macDef 'b', < 'c', 'd', "ef" >
  37.         EDUP
  38.  
  39.     DB  "\n2) same code, but multi-line variants:\n"
  40.     DB  "(dot-repeater variants are NOT supported)\n"
  41.  
  42.     ; 2x S_main instance by using DUP+EDUP
  43. mlDupRep:
  44.         DUP 2
  45.             S_main {
  46.                 'i',
  47.                 {
  48.                     'j',
  49.                     { "klmno" },
  50.                     "\np"
  51.                 }
  52.             }
  53.         EDUP
  54.  
  55.     ; emit structure inside macro
  56. macDef2  MACRO   b1?, t1?
  57. .macSub     S_main {
  58.     '<',
  59.     {
  60.         b1?,
  61.         { t1? },
  62.         "\n>"
  63.     }
  64. }
  65.         ENDM
  66.  
  67.     ; emit 2x structure inside macro with dot repeater (structs have own macro-specific label)
  68.         .2  macDef2 'B', < 'C', 'D', "EF" >
  69.  
  70.         DUP 2
  71.             macDef2 'b', < 'c', 'd', "ef" >
  72.         EDUP
  73.  
  74.     ; 2x S_main instance by using dot-repeater -> this one is *NOT* supported
  75.     ; it should NOT read more lines outside of the macro scope, and report missing "}"
  76. mlDotRep  .2  S_main {
  77.         ld  b,c : ld a,(bc) ; this should be processed as instructions => 41 0A ("A\n")
  78.  
  79.     ; try dot-repeater inside macro definition as ultimate complexity thing
  80.     ; (ignoring IF type of complexity and recursion, because I want to finish it today)
  81.     ; this is still *NOT* supported and the second instance will miss the "}"
  82. macDef3  MACRO   b1?, t1?
  83.         .2 S_main {
  84.     '{',
  85.     {
  86.         b1?,
  87.         { t1? },
  88.         "\n}"
  89.     }
  90. }
  91.         ENDM
  92.  
  93.     ; this should fail due to dot-repeater used for multi-line initializer
  94.         macDef3 '1', "2345"
  95.         ld  b,d : ld a,(bc) ; this should be processed as instructions => 42 0A ("B\n")
  96.  
  97.     OUTEND
  98.