Communicate with arduino using 8086 assembly language.

I need to use 8086 assembly language to connect with arduino in my assignment. The thing i want to do is when I run the assembly program, the buzzer will sound. I run the assembly program using DOSBox.

int buzzer = 11;
int val;

void setup() {
  pinMode(buzzer, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  val = Serial.read();
  if(-1 != val) {
    if('H' == val) {
      unsigned char i;
      for(i = 0; i < 80; i++) {
        digitalWrite(buzzer, HIGH);
        delay(1);
        digitalWrite(buzzer, LOW);
        delay(1);
      }
      for(i = 0; i < 100; i++) {
        digitalWrite(buzzer, HIGH);
        delay(2);
        digitalWrite(buzzer, LOW);
        delay(2);
      }
    }
  }
}

Above is my arduino program code. When the com1 receive ‘H’, the buzzer will sound.

.MODEL SMALL
.STACK 64
.DATA
.CODE
MAIN PROC
        MOV AX,@DATA
        MOV DS,AX
        MOV AH,00
        MOV AL,11101011b
        MOV DX,00
        MOV AH,1
        MOV AL,'H'
        MOV DX,00
        INT 14H
        MOV AX,4C00H
        INT 21H
MAIN ENDP
END MAIN

Above is my assembly program code. When I run the assembly code, it supposed to send ‘H’ to com1, and the buzzer will sound. However, there is nothing happen when I run the assembly program. What is the problem?

How have you verified that your PC program does send an 'H'?

LianChyn: However, there is nothing happen when I run the assembly program.

To test the assembly program I would test by sending an 'H' continuously and look at the com1 output using an oscilloscope or logic analyzer.

I am not sure whether the assembly program has sent an 'H'. Can I test without an oscilloscope or logic analyzer? If the assembly program does not send an 'H', what will be the reason?

LianChyn: Above is my arduino program code. When the com1 receive 'H', the buzzer will sound.

Wouldn't it make a lot more sense to start with an Arduino program that just prints to the Serial Monitor the value of any byte that it receives.

It will be time enough to make the Arduino program more complex when you can see that your PC program is sending the correct stuff.

...R

Have you verified that COM1 is actually the Arduino? Usually it isn't.

Does your Arduino side of things work using e.g. the serial monitor?

When I use the code print the val, it shows -1. Why...

LianChyn:
I need to use 8086 assembly language to connect with arduino in my assignment. The thing i want to do is when I run the assembly program, the buzzer will sound. I run the assembly program using DOSBox.

int buzzer = 11;

int val;

void setup() {
 pinMode(buzzer, OUTPUT);
 Serial.begin(9600);
}

void loop() {
 val = Serial.read();
 if(-1 != val) {
   if(‘H’ == val) {
     unsigned char i;
     for(i = 0; i < 80; i++) {
       digitalWrite(buzzer, HIGH);
       delay(1);
       digitalWrite(buzzer, LOW);
       delay(1);
     }
     for(i = 0; i < 100; i++) {
       digitalWrite(buzzer, HIGH);
       delay(2);
       digitalWrite(buzzer, LOW);
       delay(2);
     }
   }
 }
}




Above is my arduino program code. When the com1 receive 'H', the buzzer will sound.



.MODEL SMALL
.STACK 64
.DATA
.CODE
MAIN PROC
       MOV AX,@DATA
       MOV DS,AX
       MOV AH,00
       MOV AL,11101011b
       MOV DX,00
       MOV AH,1
       MOV AL,‘H’
       MOV DX,00
       INT 14H
       MOV AX,4C00H
       INT 21H
MAIN ENDP
END MAIN




Above is my assembly program code. When I run the assembly code, it supposed to send 'H' to com1, and the buzzer will sound. However, there is nothing happen when I run the assembly program. What is the problem?

Before we get too far debugging your programs, please explain how you have the Arduino connected to the PC. Are you using the USB port on the PC to connect to the Arduino. OR are you using a serial RS232 port on the PC? If the latter, do you have a RS232 to TTL adapter making the connection?

Paul

I am using USB port, the device manager show COM1 is arduino, the problem is the assembly program do not send an ‘H’

LianChyn: I am using USB port, the device manager show COM1 is arduino, the problem is the assembly program do not send an 'H'

Sorry, can't help. I used "C" on PCs running DOS from 1990. Much easier, well, not that much easier.

Paul

Thank you for your answer

the problem is the assembly program do not send an 'H'

Then this is not an Arduino problem.

LianChyn: the problem is the assembly program do not send an 'H'

I assume you don't expect people here to help you with 8088 assembler code.

You have posted a piece of assembler code in your Original Post. Are you really suggesting that that is all that is needed to open the serial port, set the baud rate and send a character? Seems very unlikely to me.

...R

const byte buzzer = 11;

void setup() 
{
  pinMode(buzzer, OUTPUT);
  Serial.begin(9600);
}

void loop() 
{
  int val = Serial.read();
  if('H' == val) {
    for(int i = 0; i < 80; i++) {
      digitalWrite(buzzer, HIGH);
      delay(1);
      digitalWrite(buzzer, LOW);
      delay(1);
    }
    for(int i = 0; i < 100; i++) {
      digitalWrite(buzzer, HIGH);
      delay(2);
      digitalWrite(buzzer, LOW);
      delay(2);
    }
  }
}

Beyond this, your question is outside the scope of this forum.