$crystal = 12000000
$regfile = "89c51cc.dat"
Dim A As Byte
Dim D As Byte
Dim C As Byte
P1 = 255
P3 = 0
P2 = 0
Main:
Control:
If P1 = &B11111110 Then
Waitms 100
P2 = &B01111001
A = &B00000001
D = P3
C = A Xor D
P3 = C
Wait 1
Goto Control
Else
If P1 = &B11111101 Then
Waitms 100
P2 = &B00010010
A = &B00000010
D = P3
C = A Xor D
P3 = C
Wait 1
Goto Control
Else
If P1 = &B11111100 Then
Waitms 100
P2 = &B00000110
A = &B00000100
D = P3
C = A Xor D
P3 = C
Wait 1
Goto Control
Else
If P1 = &B11111011 Then
Waitms 100
P2 = &B01001100
A = &B00001000
D = P3
C = A Xor D
P3 = C
Wait 1
Goto Control
Else
If P1 = &B11111010 Then
Waitms 100
P2 = &B00100100
A = &B00010000
D = P3
C = A Xor D
P3 = C
Wait 1
Goto Control
Else
If P1 = &B11111001 Then
Waitms 100
P2 = &B00100000
A = &B00100000
D = P3
C = A Xor D
P3 = C
Wait 1
Goto Control
Else
If P1 = &B11111000 Then
Waitms 100
P2 = &B00001111
A = &B01000000
D = P3
C = A Xor D
P3 = C
Wait 1
Goto Control
Else
If P1 = &B11110111 Then
Waitms 100
P2 = &B00000000
A = &B10000000
D = P3
C = A Xor D
P3 = C
wait 1
Goto Control
Else
Goto Control
End If
End If
End If
End If
End If
End If
End If
End If
End
Asked
Active
Viewed 155 times
-7

Roh
- 4,598
- 6
- 41
- 86
-
1At least explain what it's supposed to do, and add 4 spaces at the start of each line of code so that it is interpreted by the site as a block of code. – jms Feb 10 '16 at 16:53
-
1actually i have to program a microcontroller(PIC16F877) through this vb.net program. and it is given to me by my professor so please help me out – Harshit Rana Feb 10 '16 at 16:58
-
1There are several problems with this question. First this site is for Electrical Engineering. Your question appears to be about software, so it may be better on stackoverflow. Second, we expect some evidence of effort or research. This shows commitment to the question and answer, and indicates you are not just a troll wasting our time. One way to demonstrate some effort is explain what the program is intended to do. Please read the [help] to learn how to ask good questions. Then edit your question before it gets closed. – gbulmer Feb 10 '16 at 17:03
-
@gbulmer SO would reject this, as they expect microcontroller programming to be handled here. – Passerby Feb 10 '16 at 17:04
-
1I didn't realise people still used gotos in code ??? – Neil_UK Feb 10 '16 at 17:06
-
Indenting would be good, and use elseif, it avoids multiple nested if statements. – user1582568 Feb 10 '16 at 17:07
-
3@Neil_UK I didn't think I would ever see "vb.net" and "microcontroller" in the same sentence... OP, why vb.net? – uint128_t Feb 10 '16 at 17:07
-
@Passerby, I'm pretty sure this is meant to be code to control the programming process, not code to be programmed into the uC. But I don't see anywhere that this code actually outputs anything or controls anything, so it looks like a pure code issue to me, nothing specific to controlling a device programmer. – The Photon Feb 10 '16 at 17:12
-
@uint128_t, I'm pretty sure this is meant to be code to control the programming process, not code to be programmed into the uC. – The Photon Feb 10 '16 at 17:12
-
@Passerby - *this* program is VB. I'd imagine there are likely many more VB programmers hanging out at stackoverflow than here. But hey, who knows? And this will likely get closed if the OP doesn't address the fundamental lack of information. I rarely vote to close in the first hour, so they have plenty of time to fix it. – gbulmer Feb 10 '16 at 17:13
-
@ThePhoton I think so too, but I'm still a bit puzzled by the choice of language. There are many languages that I would think are far more appropriate. – uint128_t Feb 10 '16 at 17:16
-
Never used VB, yet the code is very simple to understand. But I have to ask: couldn't you use a "switch case" equivalent? Or at least a while loop? These GOTOs almost gave me a heart attack. – Vicente Cunha Feb 10 '16 at 17:25
-
3Kinda looks like a bad intro to assembly. Maybe some abstraction for jumps and conditional branches with the poor GOTOs and checks. I totally disagree with this teaching method. – mcmiln Feb 10 '16 at 17:35
-
1@Neil_UK A goto has very limited correct use, primarily, moving *forward* out of nested loops. For C, at least, there isn't a better way to perform exception like calls. – Samuel Feb 10 '16 at 18:45
-
@uint128_t [aside] NetDuino can be programmed in VB.NET, as far as I understand. – Nick Alexeev Feb 10 '16 at 19:43
-
I think the code can be summarize as: `control: goto control`. (check P1 set at the start and the if statements). – jippie Feb 10 '16 at 19:49
1 Answers
2
It checks P1, and depending on what P1 is, it changes P2 and P3. Then it repeats. That's it.

Passerby
- 72,580
- 7
- 90
- 202