133k views
5 votes
For HCS12 Dragon board, in code warrior software.

Write an assembly program which inputs two numbers (from 0 to 9) from user and stores them in var1 and var2. You can use getchar subroutine to get an input. The program adds var1 and var2 and displays result on screen.

User Lokesh Sah
by
6.7k points

1 Answer

6 votes

Final answer:

To write an assembly program for the HCS12 Dragon board in CodeWarrior software, define variables to store the input numbers, use the getchar subroutine to get input, add the values, and display the result.

Step-by-step explanation:

Solution:

To write an assembly program for the HCS12 Dragon board in CodeWarrior software, you can follow these steps:

  1. Define two variables, var1 and var2, to store the input numbers.
  2. Use the getchar subroutine to get input from the user and store it in var1 and var2.
  3. Add the values of var1 and var2 and store the result in a separate variable, sum.
  4. Display the result on the screen.

Here's an example code snippet:

section .data
var1 db 0
var2 db 0
sum db 0

section .text

global _start

_start:
mov ah, 0
int 16h ; get input for var1
mov [var1], al

mov ah, 0
int 16h ; get input for var2
mov [var2], al

mov al, [var1]
add al, [var2]
mov [sum], al

mov ah, 0eh ; display result
mov al, [sum]
add al, 30h ; convert to ASCII
int 10h

done:
mov ah, 0
int 16h ; wait for key press
int 20h ; exit

User Josh Kelley
by
6.9k points