sorry for long post name.
anywyas, i'm converting an emulator a friend of mine made into VB form C. i came into some problems at the end where return is casuing an error. here is the code:
'The following #define macro was replaced in-line:
'ORIGINAL LINE: #define ROPCODE(offs) ((oprom[offs] << 8) Or oprom[(offs) + 1])
#Const ROPCODE = True
Private convert_zero() As Byte = {32, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}
Private condition() As String = {"", "nz,", "z,", "???,", "nc,", "nc nz,", "nc z,", "???,", "c,", "c nz,", "c z,", "???,", "???,", "???,", "???,", "???,", "???,", "???,", "???,", "???,", "nn,", "nn nz,", "nn z,", "???,", "n,", "n nz,", "n z,", "???,", "???,", "???,", "???,", "never,"}
Private Function signed_16bit(ByVal val As Short) As String
Dim temp As New String(New Char(9) {})
If val < 0 Then
temp = String.Format("-${0:x}", -val)
Else
temp = String.Format("${0:x}", val)
End If
Return temp
End Function
Private Shared Function dasmjag(ByVal [variant] As Integer, ByVal buffer As String, ByVal pc As UInteger, ByVal oprom As String) As UInteger
Dim flags As UInteger = 0
Dim op As Integer = ROPCODE(0)
Dim reg1 As Integer = (op >> 5) And 31
Dim reg2 As Integer = op And 31
Dim size As Integer = 2
pc += 2
Select Case op >> 10
Case 0
buffer = String.Format("add r{0:D},r{1:D}", reg1, reg2)
Case 1
buffer = String.Format("addc r{0:D},r{1:D}", reg1, reg2)
Case 2
buffer = String.Format("addq ${0:x},r{1:D}", convert_zero(reg1), reg2)
Case 3
buffer = String.Format("addqt ${0:x},r{1:D}", convert_zero(reg1), reg2)
Case 4
buffer = String.Format("sub r{0:D},r{1:D}", reg1, reg2)
Case 5
buffer = String.Format("subc r{0:D},r{1:D}", reg1, reg2)
Case 6
buffer = String.Format("subq ${0:x},r{1:D}", convert_zero(reg1), reg2)
Case 7
buffer = String.Format("subqt ${0:x},r{1:D}", convert_zero(reg1), reg2)
Case 8
buffer = String.Format("neg r{0:D}", reg2)
Case 9
buffer = String.Format("and r{0:D},r{1:D}", reg1, reg2)
Case 10
buffer = String.Format("or r{0:D},r{1:D}", reg1, reg2)
Case 11
buffer = String.Format("xor r{0:D},r{1:D}", reg1, reg2)
Case 12
buffer = String.Format("not r{0:D}", reg2)
Case 13
buffer = String.Format("btst ${0:D},r{1:D}", reg1, reg2)
Case 14
buffer = String.Format("bset ${0:D},r{1:D}", reg1, reg2)
Case 15
buffer = String.Format("bclr ${0:D},r{1:D}", reg1, reg2)
Case 16
buffer = String.Format("mult r{0:D},r{1:D}", reg1, reg2)
Case 17
buffer = String.Format("imult r{0:D},r{1:D}", reg1, reg2)
Case 18
buffer = String.Format("imultn r{0:D},r{1:D}", reg1, reg2)
Case 19
buffer = String.Format("resmac r{0:D}", reg2)
Case 20
buffer = String.Format("imacn r{0:D},r{1:D}", reg1, reg2)
Case 21
buffer = String.Format("div r{0:D},r{1:D}", reg1, reg2)
Case 22
buffer = String.Format("abs r{0:D]", reg2)
Case 23
buffer = String.Format("sh r{0:D},r{1:D}", reg1, reg2)
Case 24
buffer = String.Format("shlq ${0:D},r{1:D}", 32 - convert_zero(reg1), reg2)
Case 25
buffer = String.Format("shrq ${0:D},r{1:D}", convert_zero(reg1), reg2)
Case 26
buffer = String.Format("sha r{0:D},r{1:D}", reg1, reg2)
Case 27
buffer = String.Format("sharq ${0:D},r{1:D}", convert_zero(reg1), reg2)
Case 28
buffer = String.Format("ror r{0:D},r{1:D}", reg1, reg2)
Case 29
buffer = String.Format("rorq ${0:D},r{1:D}", convert_zero(reg1), reg2)
Case 30
buffer = String.Format("cmp r{0:D},r{1:D}", reg1, reg2)
Case 31
buffer = String.Format("cmpq ${0:D},r{1:D}", convert_zero(reg1), reg2)
Case 32
If GetObject() = JAGUAR_VARIANT_GPU Then
buffer = String.Format("sat8 r{0:D}", reg2)
Else
buffer = String.Format("subqmod ${0:x},r{1:D}", convert_zero(reg1), reg2)
End If
Case 33
If GetObject() = JAGUAR_VARIANT_GPU Then
buffer = String.Format("sat16 r{0:D}", reg2)
Else
buffer = String.Format("sat16s r{0:D}", reg2)
End If
Case 34
buffer = String.Format("move r{0:D},r{1:D}", reg1, reg2)
Case 35
buffer = String.Format("moveq {0:D},r{1:D}", reg1, reg2)
Case 36
buffer = String.Format("moveta r{0:D},r{1:D}", reg1, reg2)
Case 37
buffer = String.Format("movefa r{0:D},r{1:D}", reg1, reg2)
Case 38
buffer = String.Format("movei ${0:x},r{1:D}", ROPCODE(2) Or (ROPCODE(4) << 16), reg2)
size = 6
Case 39
buffer = String.Format("loadb r{0:D},r{1:D}", reg1, reg2)
Case 40
buffer = String.Format("loadw r{0:D},r{1:D}", reg1, reg2)
Case 41
buffer = String.Format("load r{0:D},r{1:D}", reg1, reg2)
Case 42
If GetObject() = JAGUAR_VARIANT_GPU Then
buffer = String.Format("loadp (r{0:D}),r{1:D}", reg1, reg2)
Else
buffer = String.Format("sat32s r{0:D}", reg2)
End If
Case 43
buffer = String.Format("load (r14+${0:x}),r{1:D}", convert_zero(reg1) * 4, reg2)
Case 44
buffer = String.Format("load (r15+${0:x}),r{1:D}", convert_zero(reg1) * 4, reg2)
Case 45
buffer = String.Format("storeb r{0:D},r{1:D}", reg1, reg2)
Case 46
buffer = String.Format("storew r{0:D},r{1:D}", reg1, reg2)
Case 47
buffer = String.Format("store r{0:D},r{1:D}", reg1, reg2)
Case 48
If Object = JAGUAR_VARIANT_GPU Then
buffer = String.Format("storep r{0:D},(r{1:D})", reg2, reg1)
Else
buffer = String.Format("mirror r{0:D}", reg2)
End If
break()
Case 49
buffer = String.Format("store (r14+${0:x}),r{1:D}", convert_zero(reg1) * 4)
Case 50
buffer = String.Format("store (r15+${0:x}),r{1:D}", convert_zero(reg1) * 4)
Case 51
buffer = String.Format("move pc,r{0:D}", reg2)
Case 52
buffer = String.Format("jump {0}(r{1:D})", condition(reg2), reg1)
Case 53
buffer = String.Format("jr {0}{1:X8}", condition(reg2), pc + (CSByte(reg1 << 3) >> 2))
Case 54
buffer = String.Format("mmult r{0:D},r{1:D}", reg1, reg2)
Case 55
buffer = String.Format("mtoi r{0:D},r{1:D}", reg1, reg2)
Case 56
buffer = String.Format("normi r{0:D},r{1:D}", reg1, reg2)
Case 57
buffer = "nop"
Case 58
buffer = String.Format("load (r14+r{0:D}),r{1:D}", reg1, reg2)
Case 59
buffer = String.Format("load (r15+r{0:D}),r{1:D}", reg1, reg2)
Case 60
buffer = String.Format("store r{0:D},(r14+r{1:D})", reg2, reg1)
Case 61
buffer = String.Format("store r{0:D},(r15+r{1:D})", reg2, reg1)
Case 62
If Object = JAGUAR_VARIANT_GPU Then
buffer = String.Format("sat24 r{0:D}", reg2)
Else
buffer = "illegal"
End If
Case 63
If Object = JAGUAR_VARIANT_GPU Then
buffer = String.Format(buffer, If(reg1, "unpack r%d", "pack r%d"), reg2)
Else
buffer = String.Format("addqmod ${0:x},r{1:D}", convert_zero(reg1), reg2)
End If
End Select
Return size Or flags Or DASMFLAG_SUPPORTED
End Function
'The following constructor is declared outside of its associated class:
'ORIGINAL LINE: CPU_DISASSEMBLE(jaguargpu)
Private CPU_DISASSEMBLE(ByVal UnnamedParameter1 As jaguargpu)
Return dasmjag(JAGUAR_VARIANT_GPU, buffer, pc, oprom)
End Sub
'The following constructor is declared outside of its associated class:
'ORIGINAL LINE: CPU_DISASSEMBLE(jaguardsp)
Private CPU_DISASSEMBLE(ByVal UnnamedParameter1 As jaguardsp)
Return dasmjag(JAGUAR_VARIANT_DSP, buffer, pc, oprom)
End sub
there probably are other errors. such as other variables that will be added in another module.
anyways, return gives the same error as the post name. does anybody know an alternative, or how to fix it? thanks.