Docsity

BCDINC Subroutine Homework - Prof. Jerry Tucker, Assignments of Electrical and Electronics Engineering

Toggle sidebar
bg1
Homework 148
due Monday 11/14/08
These will count as take home problems for the next quiz; therefore, do not consult with
others and sign the pledge below:
On my honor I have neither given nor received aid on this homework.
______________________________________ Name: _______________________
1. The subroutine BCDINC is shown below. Does it work correctly? If not fix it.
;***************************************************************
; FUNCTION: BCDINC - INCREMENTS TWO DIGIT BCD NUMBER IN ACC
; IF A = 09H WHEN CALLED BCDINC RETURNS 10H
; IF A = 99H WHEN CALLED BCEINC RETURNS 00H
; INPUTS: ACC
; OUTPUTS: ACC
; CALLS: NONE
; DESTROYS: ACC, DFLAG
;***************************************************************
BCDINC:
INC A ;INCREMENT BCD NUMBER
ADD A,#1 ;INCREMENT BCD NUMBER
DA A ;CORRECT INCREMENTED BCD
RET ;AND RETURN
END
You may use the supplied BCDINC.ASM file to test the subroutine.
INSTRUCTIONS THAT AFFECT FLAGS
(incomplete)
Instruction CY OV AC Z N Instruction CY OV AC Z N
ADD X X X X X CLR bit 0 - - - -
ADDC X X X X X CPL bit X - -
ANL C,bit X - - X X
SUBB X X X X X ANL/ C,bit X - - X X
MUL X X - X X ORL C,bit X - - X X
DIV 0 X - X X ORL/ C,bit X - - X X
DA X - - X X MOV C,bit X - - - -
XRL - - - X X CJNE X - - X X
CPL A - - - X X
SETB C 1 - - - - DEC - - - X X
SWAP A - - - X X DJNZ - - - X X
RR, RL - - - X X INC - - - X X
RRC, RLC X - - X X SLL,SRL,SRA X - - X X
ADD A,#1 ;This affects the carry flags.

Partial preview of the text

Download BCDINC Subroutine Homework - Prof. Jerry Tucker and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

Homework 148 due Monday 11/14/ These will count as take home problems for the next quiz; therefore, do not consult with others and sign the pledge below: On my honor I have neither given nor received aid on this homework. ______________________________________ Name: _______________________

  1. The subroutine BCDINC is shown below. Does it work correctly? If not fix it. ;*************************************************************** ; FUNCTION: BCDINC - INCREMENTS TWO DIGIT BCD NUMBER IN ACC ; IF A = 09H WHEN CALLED BCDINC RETURNS 10H ; IF A = 99H WHEN CALLED BCEINC RETURNS 00H ; INPUTS: ACC ; OUTPUTS: ACC ; CALLS: NONE ; DESTROYS: ACC, DFLAG ;*************************************************************** BCDINC: INC A ;INCREMENT BCD NUMBER ADD A,#1 ;INCREMENT BCD NUMBER DA A ;CORRECT INCREMENTED BCD RET ;AND RETURN END You may use the supplied BCDINC.ASM file to test the subroutine.

INSTRUCTIONS THAT AFFECT FLAGS

(incomplete)

Instruction CY OV AC Z N Instruction CY OV AC Z N ADD X X^ X X X^ CLR bit 0 -^ - - - ADDC X X^ X X X^ CPL bit X -^ - ANL C,bit X - -^ X X SUBB X X^ X X X^ ANL/ C,bit X - -^ X X MUL X X -^ X X^ ORL C,bit X - -^ X X DIV 0 X^ - X X^ ORL/ C,bit X - -^ X X DA X - -^ X X^ MOV C,bit X - -^ - - XRL - - -^ X X^ CJNE X - -^ X X CPL A - -^ - X X SETB C 1 - -^ - -^ DEC - -^ - X X SWAP A - - -^ X X^ DJNZ - -^ - X X RR, RL - - -^ X X^ INC - -^ - X X RRC, RLC X - -^ X X^ SLL,SRL,SRA X - -^ X X ADD A,#1 ;This affects the carry flags.