Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub flg_signzeroparity8(ByVal Value As UByte)
  2.     If Value = 0 Then zf = 1 Else zf = 0
  3.     If (Value And &h80) Then sf = 1 Else sf = 0
  4.     pf = parity(Value)
  5. End Sub
  6.  
  7. Sub flg_signzeroparity16(ByVal Value As UShort)
  8.     If Value = 0 Then zf = 1 Else zf = 0
  9.     If (Value And &h8000) Then sf = 1 Else sf = 0
  10.     pf = parity(Value And &hFF)
  11. End Sub
  12.  
  13. Sub flg_logical8(ByVal Value As UByte)
  14.     flg_signzeroparity8 Value
  15.     cf = 0
  16.     of = 0
  17. End Sub
  18.  
  19. Sub flg_logical16(ByVal Value As UShort)
  20.     flg_signzeroparity16 Value
  21.     cf = 0
  22.     of = 0
  23. End Sub
  24.  
  25. Sub flg_adc8(ByVal v1 As UByte, ByVal v2 As UByte, ByVal v3 As UByte) 'v3 is carry flag
  26.     Dim dst As UShort
  27.     dst = v1+v2+v3
  28.     flg_signzeroparity8 dst
  29.     If (dst And &hFF00) Then cf = 1 Else cf = 0
  30.     If (((dst Xor v1) And (dst Xor v2)) And &h80) Then of = 1 Else of = 0
  31.     If ((v1 Xor v2 Xor dst) And &h10) Then af = 1 Else af = 0
  32. End Sub
  33.  
  34. Sub flg_adc16(ByVal v1 As UShort, ByVal v2 As UShort, ByVal v3 As UShort) 'v3 is carry flag
  35.     Dim dst As UInteger
  36.     dst = v1+v2+v3
  37.     flg_signzeroparity16 dst
  38.     If (dst And &hFFFF0000) Then cf = 1 Else cf = 0
  39.     If (((dst Xor v1) And (dst Xor v2)) And &h8000) Then of = 1 Else of = 0
  40.     If ((v1 Xor v2 Xor dst) And &h10) Then af = 1 Else af = 0
  41. End Sub
  42.  
  43. Sub flg_add8(ByVal v1 As UByte, ByVal v2 As UByte)
  44.     Dim dst As UShort
  45.     dst = v1+v2
  46.     flg_signzeroparity8 dst
  47.     If (dst And &hFF00) Then cf = 1 Else cf = 0
  48.     If (((dst Xor v1) And (dst Xor v2)) And &h80) Then of = 1 Else of = 0
  49.     If ((v1 Xor v2 Xor dst) And &h10) Then af = 1 Else af = 0
  50. End Sub
  51.  
  52. Sub flg_add16(ByVal v1 As UShort, ByVal v2 As UShort)
  53.     Dim dst As UInteger
  54.     dst = v1+v2
  55.     flg_signzeroparity16 dst
  56.     If (dst And &hFFFF0000) Then cf = 1 Else cf = 0
  57.     If ((dst Xor v1) And (dst Xor v2) And &h8000) Then of = 1 Else of = 0
  58.     If ((v1 Xor v2 Xor dst) And &h10) Then af = 1 Else af = 0
  59. End Sub
  60.  
  61. Sub flg_sub8(ByVal v1 As UByte, ByVal v2 As UByte)
  62.     Dim dst As UShort
  63.     dst = v1-v2
  64.     flg_signzeroparity8 dst
  65.     If (dst And &hFF00) Then cf = 1 Else cf = 0
  66.     If ((dst Xor v1) And (v1 Xor v2) And &h80) Then of = 1 Else of = 0
  67.     If ((v1 Xor v2 Xor dst) And &h10) Then af = 1 Else af = 0
  68. End Sub
  69.  
  70. Sub flg_sub16(ByVal v1 As UShort, ByVal v2 As UShort)
  71.     Dim dst As UInteger
  72.     dst = v1-v2
  73.     flg_signzeroparity16 dst
  74.     If (dst And &hFFFF0000) Then cf = 1 Else cf = 0
  75.     If ((dst Xor v1) And (v1 Xor v2) And &h8000) Then of = 1 Else of = 0
  76.     If ((v1 Xor v2 Xor dst) And &h10) Then af = 1 Else af = 0
  77. End Sub
  78.  
  79. Sub flg_sbb8(ByVal v1 As UByte, ByVal v2 As UByte, ByVal v3 As UByte) 'v3 is carry flag
  80.     Dim dst As UShort
  81.     dst = v1-v2-v3
  82.     flg_signzeroparity8 dst
  83.     If (dst And &hFF00) Then cf = 1 Else cf = 0
  84.     If ((dst Xor v1) And (v1 Xor v2) And &h80) Then of = 1 Else of = 0
  85.     If ((v1 Xor v2 Xor dst) And &h10) Then af = 1 Else af = 0
  86. End Sub
  87.  
  88. Sub flg_sbb16(ByVal v1 As UShort, ByVal v2 As UShort, ByVal v3 As UShort) 'v3 is carry flag
  89.     Dim dst As UInteger
  90.     dst = v1-v2-v3
  91.     flg_signzeroparity16 dst
  92.     If (dst And &hFFFF0000) Then cf = 1 Else cf = 0
  93.     If ((dst Xor v1) And (v1 Xor v2) And &h8000) Then of = 1 Else of = 0
  94.     If ((v1 Xor v2 Xor dst) And &h10) Then af = 1 Else af = 0
  95. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement