
;  --------------------------------------------------------------
;                EMBEDDED MICROCONTROLLER PROGRAMMING
;                       HOMEWORK #2 - PROBLEM 1
;
;                      Written by S.C.T.  1-9-99
;		    Modified by ALM: April 2, 2001
;  --------------------------------------------------------------

; This program demonstrates the use of binary addition, subtraction,
; multiplication, and division using 8 bit numbers.

; This program should be assembled into an Intel hex file and loaded
; into your SDK.  Print out a copy of your list file and use it to
; single step through the program.  For each operation, examine the
; contents of the applicable registers and determine whether the
; results are valid or not and explain why.  After stepping through
; the instructions and answering the questions, modify this file with
; comments which contain the answers to each question.  Send in the
; commented file as problem 1 of your homework.  Make sure to include
; YOUR NAME in the commented file.

; NOTE: For all the questions below which ask for numbers or results,
; use decimal values for all numbers and list which registers contain
; the results and what flags are used to evaluate whether the results
; are correct or not.

  $MOD52

  ORG   4000h                   ; Start Program execution at
                                ; Address 4000 hex

; 0) Do the addition below assuming that we are working with
; UNSIGNED numbers. What are the two numbers we are adding (decimal) ?
; What is the result ? Is the result valid or not ?  Why or Why not ?

  MOV   A, #65h
  ADD   A, #2Bh

; 1) Do the addition below assuming that we are working with
; UNSIGNED numbers. What are the two numbers we are adding (decimal) ?
; What is the result ? Is the result valid or not ?  Why or Why not ?

  MOV   A, #0C5h
  ADD   A, #4Bh

; 2)  Now do the addition below assuming that we are working with
; SIGNED numbers. What are the two numbers we are adding (decimal) ?
; What is the result ? Is the result valid or not ?  Why or Why not ?

  MOV   A, #0C5h
  ADD   A, #4Bh

; 3)  Do the addition below assuming that we are working with
; SIGNED numbers. What are the two numbers we are adding (decimal) ?
; What is the result ? Is the result valid or not ?  Why or Why not ?

  MOV   A, #80h
  ADDC  A, #7Fh

; 4) Do the subtraction below assuming that we are working with
; UNSIGNED numbers. What are the two numbers we are adding (decimal) ?
; What is the result ? Is the result valid or not ?  Why or Why not ?

  MOV   A, #93h
  CLR   C
  SUBB  A, #0A1h

; 5) Now do the subtraction below assuming that we are working with
; SIGNED numbers. What are the two numbers we are adding (decimal) ?
; What is the result ? Is the result valid or not ?  Why or Why not ?

  MOV   A, #80h
  CLR   C
  SUBB  A, #01h

; 6) Do the subtraction below assuming that we are working with
; SIGNED numbers. What are the two numbers we are adding (decimal) ?
; What is the result ? Is the result valid or not ?  Why or Why not ?

  MOV   A, #93h
  CLR   C
  SUBB  A, #0A1h

  END
