Advertisement
Guest User

Untitled

a guest
Nov 30th, 2017
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SPARK 1.99 KB | None | 0 0
  1. .global Decode
  2. .global EmuPush
  3. .global EmuWrite
  4. .global EmuPop
  5. .global EmuRead
  6. .global EmuAdd
  7. .global EmuSub
  8. .global EmuMul
  9. .global EmuDiv
  10. .global EmuBz
  11. .global EmuBn
  12. .global EmuJmp
  13.  
  14. .section ".text"
  15.  
  16. !i0 est l instruction
  17. !i1 la machine
  18. Decode:
  19.     save    %sp,-208,%sp   
  20.     lduw    [%i1],%l1       !Obtention du compteur ordinal
  21.     ldx     [%i1+16],%l0    !Obtention du pointeur sur la memoire de la machine virtuelle
  22.     ldub    [%l0+%l1],%l0   !Lecture du premier octet de l'instruction courante
  23.  
  24.  
  25.     cmp     %l0,0x40        !Est-ce l'instruction PUSH? (0x00)
  26.     be      decode10        !Decode un PUSH
  27.     nop
  28.  
  29.  
  30.  
  31.     cmp     %l0,0           !Est-ce l'instruction HALT? (0x00)
  32.     bnz     decodeError     !sinon, le reste n'est pas encore supporte: Erreur.
  33.     nop                     !...
  34.        
  35.  
  36.  
  37.     stw     %g0,[%i0]       !type d'instruction: systeme (0)
  38.     stw     %g0,[%i0+4]     !numero d'operation: 0 (HALT)
  39.     ba      decodeEnd
  40.     nop
  41.  
  42. decode10:                   !PUSH
  43.     mov     1,%l2          
  44.     stw     %l2,[%i0]       !mode 01
  45.  
  46.     mov     0,%l2          
  47.     stw     %l2,[%i0+4]     !operation: 0 (PUSH)
  48.  
  49.                             !CC est toujours 0
  50.                             !fl est a 0 aussi
  51.  
  52.  
  53.  
  54.     mov     3,%l2          
  55.     stw     %l2,[%i0+20]    !Size: 3
  56.  
  57.  
  58.  
  59.  
  60. decodeEnd:         
  61.     mov     0,%i0           !code d'erreur 0: decodage reussi
  62.     ret    
  63.     restore
  64.    
  65.    
  66.    
  67. decodeError:
  68.  
  69.     mov 1,%i0       !code d'erreur 1: instruction illegale.
  70.     ret
  71.     restore
  72.  
  73.  
  74.    
  75.  
  76.  
  77.  
  78.  
  79.  
  80. EmuPush:
  81.     save    %sp,-208,%sp
  82.    
  83.    
  84.     mov 1,%i0
  85.     ret
  86.     restore
  87.    
  88. EmuWrite:
  89.     save    %sp,-208,%sp
  90.    
  91.    
  92.     mov 1,%i0
  93.     ret
  94.     restore
  95.    
  96. EmuPop:
  97.     save    %sp,-208,%sp
  98.    
  99.    
  100.     mov 1,%i0
  101.     ret
  102.     restore
  103.    
  104. EmuRead:
  105.     save    %sp,-208,%sp
  106.    
  107.    
  108.     mov 1,%i0
  109.     ret
  110.     restore
  111.    
  112.    
  113.    
  114. EmuAdd:
  115.     save    %sp,-208,%sp
  116.    
  117.    
  118.     mov 1,%i0
  119.     ret
  120.     restore
  121.    
  122. EmuSub:
  123.     save    %sp,-208,%sp
  124.    
  125.    
  126.     mov 1,%i0
  127.     ret
  128.     restore
  129.    
  130. EmuMul:
  131.     save    %sp,-208,%sp
  132.    
  133.    
  134.     mov 1,%i0
  135.     ret
  136.     restore
  137.    
  138. EmuDiv:
  139.     save    %sp,-208,%sp
  140.    
  141.    
  142.     mov 1,%i0
  143.     ret
  144.     restore
  145.    
  146.    
  147. EmuBz:
  148.     save    %sp,-208,%sp
  149.    
  150.    
  151.     mov 1,%i0
  152.     ret
  153.     restore
  154.    
  155. EmuBn:
  156.     save    %sp,-208,%sp
  157.    
  158.    
  159.     mov 1,%i0
  160.     ret
  161.     restore
  162.  
  163. EmuJmp:
  164.     save    %sp,-208,%sp
  165.    
  166.    
  167.     mov 1,%i0
  168.     ret
  169.     restore
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement