home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 1 / ARM_CLUB_CD.iso / contents / apps / languages / progs / bcplib / wimps < prev    next >
Encoding:
Text File  |  1994-01-21  |  18.2 KB  |  578 lines

  1. ;Compiled code conventions ;
  2. ;Registers:
  3. ;
  4. ;RB         8    Called address     ;can be used without saving
  5. ;RL         12   Caller's static
  6. ;RTS        11   Top of stack (empty word above)
  7. ;RP         10   Frame pointer
  8. ;RG         9    Global base
  9. ;RGB        7    Special global base
  10. ;
  11. ;There is an upwards-growing stack, addressed by two registers.  R(F)P is the
  12. ;frame pointer, RTS the top of stack+1 free word pointer.
  13. ;RG points at the base of the global vector; RGB addresses a set of subroutines
  14. ;within the library.
  15. ;
  16. ;On procedure entry, RB holds the address of the called procedure.  It need not
  17. ;be preserved.  RL holds the address of the caller's static data, and must be
  18. ;preserved.  R14 holds the link: this must be written to both PC and PSR on
  19. ;return.  R1 to R4 hold the first four arguments, with others on the stack
  20. ;above RTS in the usual way. Thus, a general procedure would look like:
  21. ;        STMEA   rts!, {rb, rp, rl, r14} ; save linkage
  22. ;        SUB     rp, rts, #16            ; new frame pointer
  23. ;        STMEA   rts!, {a1, ...}         ; arguments
  24. ;           ...
  25. ;        MOV     rts, rp                 ; unwind our frame
  26. ;        LDMIB   rp, {rp, rl, pc}^       ; no need to restore RB
  27. ;
  28. ;R0 to R6 and RB(8) may be used without saving their values; so may R13 and
  29. ;moreover it is accessible from BCPL through the name NIL (assignment to NIL
  30. ;from BCPL has the side-effect of updating R6).  R6 and R13 are guaranteed
  31. ;untouched by the library, and by BCPL code which does not update NIL.
  32. ;
  33. ;On return, a1 holds value received.
  34.  
  35.  
  36.           .include  "regnames"
  37.           .include  "swinames"
  38.           Result2 = 52
  39.           Wb      = 150
  40.  
  41.           .AREA     Code
  42. Start:    .ascii     "BCPL"
  43.           .LONG     Globinits-Start
  44.           .ascii    "WimpSWIs"
  45.           .ASCII    "25 Dec 89 00-00-00  "
  46.           .LONG     0
  47.           .LONG     -1
  48.           .ascic    "WimInit"
  49. WimpInitialise:
  50.           mov       r0, a1              ; Wimp Version Required
  51.           ldr       a1, Task            ;
  52. ;         mov       a2, a2              ; BcToC0( WimpTaskName )
  53.           mov       a3, a3, lsl #2      ; Message Vec (0 all)
  54. Wswi:     swi       Wimp_Initialise     ;
  55.           str       r0, [rg, #Result2]  ; Current Wimp Version
  56.           mov       pc, lr              ; Resultis Task Handle
  57. Task:     .ascii    "TASK"
  58.  
  59. ;          mov       a2, #1
  60. ;          add       a2, a2, a1, lsl #2 ; bug if string not zero-terminated.
  61. ;          ldr       a1, Task
  62. ;          ldr       r0, RiscNo
  63. ;Wswi:     swi       Wimp_Initialise
  64. ;          str       r0, [rg, #Result2]
  65. ;          mov       r0, #0xc0
  66. ;          mov       a4, a1
  67. ;          ldr       a1, fl
  68. ;          swi       OS_Find
  69. ;          str       r0, fl
  70. ;          mov       a1, a4
  71. ;          mov       pc, lr
  72. ;Task:     .ascii    "TASK"
  73. ;RiscNo:   .long     200
  74. ;
  75.           .long     -1
  76.           .ascic    "WCreWin"
  77. WimpCreateWindow:
  78.           mov       r5, #Wimp_CreateWindow-Wimp_Initialise
  79. Wswic:    ldr       rb, [pc, #Wswi-$-8]
  80.           add       r5, r5, rb
  81.           str       r5, [pc, #Wswid-$-8]
  82.           mov       a2, a2              ;allow for pipelining
  83.           mov       a1, a1, lsl #2
  84. Wswid:    .blkl     1
  85.           mov       a1, r0
  86. ;          mov       a4, a1
  87. ;          ldr       r0, [a1]
  88. ;          ldr       a1, tmp
  89. ;          mov       a2, #12
  90. ;          swi       OS_ConvertInteger4
  91. ;          mov       a1, r0
  92. ;          mov       r0, #2
  93. ;          ldr       a2, tmp
  94. ;          mov       r3, #12
  95. ;          swi       OS_GBPB
  96. ;
  97. ;          mov       a1, a4
  98.           mov       pc,lr
  99. ;
  100.           .long     -1
  101.           .ascic    "WCrIcon"
  102. WimpCreateIcon:
  103.           mov       r5, #Wimp_CreateIcon-Wimp_Initialise
  104.           b         Wswic
  105.           .long     -1
  106.           .ascic    "WDelWin"
  107. WimpDeleteWindow:
  108.           mov       r5, #Wimp_DeleteWindow-Wimp_Initialise
  109.           b         Wswic
  110.           .long     -1
  111.           .ascic    "WDeIcon"
  112. WimpDeleteIcon:
  113.           mov       r5, #Wimp_DeleteIcon-Wimp_Initialise
  114.           b         Wswic
  115.           .long     -1
  116.           .ascic    "WiOpenW"
  117. WimpOpenWindow:
  118.           mov       r5, #Wimp_OpenWindow-Wimp_Initialise
  119.           b         Wswic
  120.           .long     -1
  121.           .ascic    "WCloseW"
  122. WimpCloseWindow:
  123.           mov       r5, #Wimp_CloseWindow-Wimp_Initialise
  124.           b         Wswic
  125. ;
  126.           .long     -1
  127.           .ascic    "WimPoll"
  128. WimpPoll: mov       r0, a1
  129.           mov       a1, a2, lsl #2
  130.           swi       Wimp_Poll
  131.           mov       a1, r0
  132.           mov       pc, lr
  133. ;
  134.           .long     -1
  135.           .ascic    "WRedraw"
  136. WimpRedrawWindow:
  137.           mov       r5, #Wimp_RedrawWindow-Wimp_Initialise
  138.           b         Wswic
  139.           .long     -1
  140.           .ascic    "WUpdate"
  141. WimpUpdateWindow:
  142.           mov       r5, #Wimp_UpdateWindow-Wimp_Initialise
  143.           b         Wswic
  144.           .long     -1
  145.           .ascic    "WGtRect"
  146. WimpGetRectangle:
  147.           mov       r5, #Wimp_GetRectangle-Wimp_Initialise
  148.           b         Wswic
  149.           .long     -1
  150.           .ascic    "WGtWsta"
  151. WimpGetWindowState:
  152.           mov       r5, #Wimp_GetWindowState-Wimp_Initialise
  153.           b         Wswic
  154.           .long     -1
  155.           .ascic    "WgtWinf"
  156. WimpGetWindowInfo:
  157.           mov       r5, #Wimp_GetWindowInfo-Wimp_Initialise
  158.           b         Wswic
  159.           .long     -1
  160.           .ascic    "WSIconS"
  161. WimpSetIconState:
  162.           mov       r5, #Wimp_SetIconState-Wimp_Initialise
  163.           b         Wswic
  164.           .long     -1
  165.           .ascic    "WGIconS"
  166. WimpGetIconState:
  167.           mov       r5, #Wimp_GetIconState-Wimp_Initialise
  168.           b         Wswic
  169.           .long     -1
  170.           .ascic    "WGtPtIn"
  171. WimpGetPointerInfo:
  172.           mov       r5, #Wimp_GetPointerInfo-Wimp_Initialise
  173.           b         Wswic
  174.           .long     -1
  175.           .ascic    "WDragBx"
  176. WimpDragBox:
  177.           mov       r5, #Wimp_DragBox-Wimp_Initialise
  178.           b         Wswic
  179. ;
  180.           .long     -1
  181.           .ascic    "WFRedra"
  182. WimpForceRedraw:
  183.           mov       r0, a1
  184.           mov       rb, a2, lsl #2
  185.           ldmia     rb, {a1-a4}
  186.           swi       Wimp_ForceRedraw
  187.           mov       pc, lr
  188.           .long     -1
  189.           .ascic    "WSCaret"
  190. WimpSetCaretPosition:
  191.           mov       r0, a1
  192.           mov       a1, a2
  193.           mov       rb, a3, lsl #2
  194.           ldmia     rb, {a2-r5}
  195.           swi       Wimp_SetCaretPosition
  196.           mov       pc, lr
  197. ;
  198.           .long     -1
  199.           .ascic    "CreMenu"
  200. WimpCreateMenu:
  201.           cmn       a1, #1
  202.           movne     a1, a1, lsl #2
  203.           swi       Wimp_CreateMenu
  204.           mov       pc, lr
  205. ;
  206.           .long     -1
  207.           .ascic    "MenuDec"
  208. WimpDecodeMenu:
  209.           mov       a1, a1, lsl #2
  210.           mov       a2, a2, lsl #2
  211.           mov       a3, a3, lsl #2
  212.           swi       Wimp_DecodeMenu
  213.           mov       pc, lr
  214. ;
  215.           .long     -1
  216.           .ascic    "WiWIcon"
  217. WimpWhichIcon:
  218.           mov       r0, a1
  219.           mov       a1, a2, lsl #2
  220.           mov       a2, a3
  221.           mov       a3, a4
  222.           swi       Wimp_WhichIcon
  223.           mov       pc, lr
  224. ;
  225.           .long     -1
  226.           .ascic    "WSetExt"
  227. WimpSetExtent:
  228.           mov       r0, a1
  229.           mov       a1, a2, lsl #2
  230.           swi       Wimp_SetExtent
  231.           mov       pc, lr
  232. ;
  233.           .long     -1
  234.           .ascic    "OpTempl"
  235. WimpOpenTemplate:
  236.           swi       Wimp_OpenTemplate
  237.           mov       pc, lr
  238.           .long     -1
  239.           .ascic    "ClTempl"
  240. WimpCloseTemplate:
  241.           swi       Wimp_CloseTemplate
  242.           mov       pc, lr
  243.           .long     -1
  244.           .ascic    "LdTempl"
  245. WimpLoadTemplate:
  246.           mov       a1, a1, lsl #2
  247.           mov       rb, a2, lsl #2
  248.           ldmia     rb, {a2-v3}
  249.           swi       Wimp_LoadTemplate
  250.           stmea     rb, {a2-v3}
  251.           str       v3, [rg, #Result2]
  252. ;          mov       a2, rb, lsr #2
  253.           mov       a1, a1, lsr #2
  254.           mov       pc, lr
  255. ;
  256.           .long     -1
  257.           .ascic    "WProKey"
  258. WimpProcessKey:
  259.           mov       r0, a1
  260.           swi       Wimp_ProcessKey
  261.           mov       pc, lr
  262.           .long     -1
  263.           .ascic    "WGCaret"
  264. WimpGetCaretPosition:
  265.           mov       r5, #Wimp_GetCaretPosition-Wimp_Initialise
  266.           b         Wswic
  267. ;
  268.           .long     -1
  269.           .ascic    "WCloseD"
  270. WimpCloseDown:
  271. ;          mov       r0, a1
  272. ;          ldr       a1, Task
  273.           swi       Wimp_CloseDown
  274.           mov       pc, lr
  275.           .long     -1
  276.           .ascic    "WStTask"
  277. WimpStartTask:
  278.           mov       r0, a1
  279.           swi       Wimp_StartTask
  280.           mov       a1, r0
  281.           Mov       pc, lr
  282. ;
  283.           .long     -1
  284.           .ascic    "WRepErr"
  285. WimpReportError:
  286.           cmp       a1, #0
  287.           movgt     r0, a1, lsl #2
  288.           movle     r0, a1
  289.           mov       a1, a2
  290.           mov       a2, a3
  291.           swi       Wimp_ReportError
  292.           mov       pc, lr
  293. ;
  294.           .long     -1
  295.           .ascic    "Windout"
  296. WimpGetWindowOutline:
  297.           mov       r5, #Wimp_GetWindowOutline-Wimp_Initialise
  298.           b         Wswic
  299. ;
  300.           .long     -1
  301.           .ascic    "WPollid"
  302. WimpPollIdle:
  303.           mov       r0, a1
  304.           mov       a1, a2, lsl #2
  305.           mov       a2, a3
  306.           swi       Wimp_PollIdle
  307.           mov       a1, r0
  308.           mov       pc, lr
  309. ;
  310.           .long     -1
  311.           .ascic    "WPlIcon"
  312. WimpPlotIcon:
  313.           mov       r5, #Wimp_PlotIcon-Wimp_Initialise
  314.           b         Wswic
  315. ;
  316.           .long     -1
  317.           .ascic    "SetMode"
  318. WimpSetMode:
  319.           mov       r0, a1
  320.           swi       Wimp_SetMode
  321.           mov       pc, lr
  322. ;
  323.           .long     -1
  324.           .ascic    "SetPalt"
  325. WimpSetPalette:
  326.           mov       r5, #Wimp_SetPalette-Wimp_Initialise
  327.           b         Wswic
  328.           .long     -1
  329.           .ascic    "ReadPal"
  330. WimpReadPalette:
  331.           mov       r5, #Wimp_ReadPalette-Wimp_Initialise
  332.           b         Wswic
  333.           .long     -1
  334.           .ascic    "WSetCol"
  335. WimpSetColour:
  336.           mov       r0, a1
  337.           swi       Wimp_SetColour
  338.           mov       pc, lr
  339. ;
  340.           .long     -1
  341.           .ascic    "SendMes"
  342. WimpSendMessage:
  343.           mov       r0, a1
  344.           mov       a1, a2, lsl #2
  345.           mov       a2, a3
  346.           mov       a3, a4
  347.           swi       Wimp_SendMessage
  348.           mov       a1, a2
  349.           mov       pc, lr
  350. ;
  351.           .long     -1
  352.           .ascic    "CrSuMen"
  353. WimpCreateSubMenu:
  354.           mov       a1, a1, lsl #2
  355.           swi       Wimp_CreateSubMenu
  356.           mov       pc, lr
  357. ;
  358.           .long     -1
  359.           .ascic    "WSpriOp"
  360. WimpSpriteOp:
  361.           mov       r0, a1
  362.           mov       a1, rgb
  363.           mov       a2, a2, lsl #2
  364.           add       a2, a2, #1
  365.           mov       rb, a3, lsl #2
  366.           ldmia     rb, {a3-rgb}
  367.           swi       Wimp_SpriteOp
  368.           stmea     rb, {a3-rgb}
  369.           mov       rgb, a1
  370.           mov       a1, a2
  371.           mov       pc, lr
  372. ;
  373.           .long     -1
  374.           .ascic    "WSlotSz"
  375. WimpSlotSize:
  376.           mov       r0, a1
  377.           mov       a1, a2
  378.           mov       rb, a3, lsl #2
  379.           swi       Wimp_SlotSize
  380.           str       a2, [rb]
  381.           str       a1, [rg, #Result2]
  382.           mov       a1, r0
  383.           mov       pc, lr
  384. ;
  385.           .long     -1
  386.           .ascic    "WClFMem"
  387. WimpClaimFreeMemory:
  388.           mov       r0, a1
  389.           mov       a1, a2
  390.           swi       Wimp_ClaimFreeMemory
  391.           str       a2, [rg, #Result2]
  392.           mov       pc, lr
  393. ;
  394.           .long     -1
  395.           .ascic    "WCommdW"
  396. WimpCommandWindow:
  397.           cmp       a1, #1
  398.           movgt     r0, #1
  399.           addgt     r0, r0, a1, lsl #2
  400.           mvnle     r0, a1
  401.           swi       Wimp_CommandWindow
  402.           mov       pc, lr
  403.           .long     -1
  404.           .ascic    "WTextCl"
  405. WimpTextColour:
  406.           mov       r0, a1
  407.           swi       Wimp_TextColour
  408.           mov       pc, lr
  409.           .long     -1
  410.           .ascic    "WSysInf"
  411. WimpReadSysInfo:
  412.           mov       r0, a1
  413.           swi       Wimp_ReadSysInfo
  414.           mov       a1, r0
  415.           mov       pc, lr
  416.           .long     -1
  417.           .ascic    "WGtMenS"
  418. WimpGetMenuState:
  419.           mov       r0, a1
  420.           mov       a1, a2, lsl #2
  421.           mov       a2, a3
  422.           mov       a3, a4
  423.           swi       Wimp_GetMenuState
  424.           mov       pc, lr
  425. Globinits:
  426.           .long     Wb+0
  427.           .long     WimpInitialise - Start
  428.           .long     Wb+1
  429.           .long     WimpCreateWindow - Start
  430.           .long     Wb+2
  431.           .long     WimpCreateIcon -Start
  432.           .long     Wb+3
  433.           .long     WimpDeleteWindow -Start
  434.           .long     Wb+4
  435.           .long     WimpDeleteIcon - Start
  436.           .long     Wb+5
  437.           .long     WimpOpenWindow - Start
  438.           .long     Wb+6
  439.           .long     WimpCloseWindow - Start
  440.           .long     Wb+7
  441.           .long     WimpPoll - Start
  442.           .long     Wb+8
  443.           .long     WimpRedrawWindow - Start
  444.           .long     Wb+9
  445.           .long     WimpUpdateWindow - Start
  446.           .long     Wb+10
  447.           .long     WimpGetRectangle - Start
  448.           .long     Wb+11
  449.           .long     WimpGetWindowState - Start
  450.           .long     Wb+12
  451.           .long     WimpGetWindowInfo - Start
  452.           .long     Wb+13
  453.           .long     WimpSetIconState - Start
  454.           .long     Wb+14
  455.           .long     WimpGetIconState - Start
  456.           .long     Wb+15
  457.           .long     WimpGetPointerInfo  - Start
  458.           .long     Wb+16
  459.           .long     WimpDragBox - Start
  460.           .long     Wb+17
  461.           .long     WimpForceRedraw - Start
  462.           .long     Wb+18
  463.           .long     WimpSetCaretPosition - Start
  464.           .long     Wb+19
  465.           .long     WimpGetCaretPosition - Start
  466.           .long     Wb+20
  467.           .long     WimpCreateMenu - Start
  468.           .long     Wb+21
  469.           .long     WimpDecodeMenu - Start
  470.           .long     Wb+22
  471.           .long     WimpWhichIcon - Start
  472.           .long     Wb+23
  473.           .long     WimpSetExtent - Start
  474.           .long     Wb+25
  475.           .long     WimpOpenTemplate - Start
  476.           .long     Wb+26
  477.           .long     WimpCloseTemplate - Start
  478.           .long     Wb+27
  479.           .long     WimpLoadTemplate - Start
  480.           .long     Wb+28
  481.           .long     WimpProcessKey - Start
  482.           .long     Wb+29
  483.           .long     WimpCloseDown - Start
  484.           .long     Wb+30
  485.           .long     WimpStartTask - Start
  486.           .long     Wb+31
  487.           .long     WimpReportError - Start
  488.           .long     Wb+32
  489.           .long     WimpGetWindowOutline -Start
  490.           .long     Wb+33
  491.           .long     WimpPollIdle -Start
  492.           .long     Wb+34
  493.           .long     WimpPlotIcon -Start
  494.           .long     Wb+35
  495.           .long     WimpSetMode - Start
  496.           .long     Wb+36
  497.           .long     WimpSetPalette - Start
  498.           .long     Wb+37
  499.           .long     WimpReadPalette - Start
  500.           .long     Wb+38
  501.           .long     WimpSetColour - Start
  502.           .long     Wb+39
  503.           .long     WimpSendMessage - Start
  504.           .long     Wb+40
  505.           .long     WimpCreateSubMenu - Start
  506.           .long     Wb+41
  507.           .long     WimpSpriteOp - Start
  508.           .long     Wb+44
  509.           .long     WimpSlotSize - Start
  510.           .long     Wb+46
  511.           .long     WimpClaimFreeMemory - Start
  512.           .long     Wb+47
  513.           .long     WimpCommandWindow - Start
  514.           .long     Wb+48
  515.           .long     WimpTextColour - Start
  516.           .long     Wb+50
  517.           .long     WimpReadSysInfo - Start
  518.           .long     Wb+70                    ; rearrange
  519.           .long     WimpGetMenuState - Start
  520.           .long     Wb+52
  521.           .long     0
  522. ;cs;dc;tb;i/.long/;tb;e/_//;nw;dc;i/ - Start/;s;i/.long/;tb;tu;2n
  523.           .LONG  0x12345678
  524.           .LONG  Globinits + 4 - Start
  525.           .LONG  Globinits + 12 - Start
  526.           .LONG  Globinits + 20 - Start
  527.           .LONG  Globinits + 28 - Start
  528.           .LONG  Globinits + 36 - Start
  529.           .LONG  Globinits + 44 - Start
  530.           .LONG  Globinits + 52 - Start
  531.           .LONG  Globinits + 60 - Start
  532.           .LONG  Globinits + 68 - Start
  533.           .LONG  Globinits + 76 - Start
  534.           .LONG  Globinits + 84 - Start
  535.           .LONG  Globinits + 92 - Start
  536.           .LONG  Globinits + 100 - Start
  537.           .LONG  Globinits + 108 - Start
  538.           .LONG  Globinits + 116 - Start
  539.           .LONG  Globinits + 124 - Start
  540.           .LONG  Globinits + 132 - Start
  541.           .LONG  Globinits + 140 - Start
  542.           .LONG  Globinits + 148 - Start
  543.           .LONG  Globinits + 156 - Start
  544.           .LONG  Globinits + 164 - Start
  545.           .LONG  Globinits + 172 - Start
  546.           .LONG  Globinits + 180 - Start
  547.           .LONG  Globinits + 188 - Start
  548.           .LONG  Globinits + 196 - Start
  549.           .LONG  Globinits + 204 - Start
  550.           .LONG  Globinits + 212 - Start
  551.           .LONG  Globinits + 220 - Start
  552.           .LONG  Globinits + 228 - Start
  553.           .LONG  Globinits + 236 - Start
  554.           .LONG  Globinits + 244 - Start
  555.           .LONG  Globinits + 252 - Start
  556.           .LONG  Globinits + 260 - Start
  557.           .LONG  Globinits + 268 - Start
  558.           .LONG  Globinits + 276 - Start
  559.           .LONG  Globinits + 284 - Start
  560.           .LONG  Globinits + 292 - Start
  561.           .LONG  Globinits + 300 - Start
  562.           .LONG  Globinits + 308 - Start
  563.           .LONG  Globinits + 316 - Start
  564.           .LONG  Globinits + 324 - Start
  565.           .LONG  Globinits + 332 - Start
  566.           .LONG  Globinits + 340 - Start
  567.           .LONG  Globinits + 348 - Start
  568.           .LONG  Globinits + 356 - Start
  569.           .LONG  Globinits + 364 - Start
  570.           .LONG  Globinits + 372 - Start
  571.           .LONG  0x87654321
  572. ;Wimp_SetPointerShape : Wb + 24
  573. ;Wimp_BaseOfSprites :   Wb + 42
  574. ;Wimp_BlockCopy :       Wb + 43
  575. ;Wimp_ReadPixTrans :    Wb + 45
  576. ;Wimp_TransferBlock :   Wb + 49
  577. ;Wimp_SetFontColours :  Wb + 51
  578.