Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Fixed PT. Calculator

Using an HC12 with Cygwin and TerraTerm, I am designing a fixed point calculator. The lab wants the format (-)x.x for entry and the result to be (-)xx.x

This is an example for addition entry that will be of this format (in my terraterm window)

c> 1.0
c> 9.1
c> +
10.1
c>

The (-) is an optional negative sign. The calculator will add/subtract multiply/divide and also have the input R/r to generate a random number between 0.0 and 9.9

If anything is entered, an error message occurs.

I have a random num generator I have previously made before, it is commented out for the time being. I am working on the display. I guess I really need help on putting this together, and would like to start on add/subtract first. Here is what I have so far:

[code];*****************************************************
; Lab 6 - Calculator
;*****************************************************
; EQUATES
;*****************************************************
OUTCRLF equ $0FC8 ; Output Carriage Return / line feed
GETCHAR equ $0FB3 ; Retrieve a character
PUTSTRNG equ $0FB9 ; Outputs a string
OUTDECW equ $0FBF ; Outputs dec val of 16-bit word

;*****************************************************
; Main Program
;*****************************************************
org $2000


main ldd #Prompt ;Enter Input (c>)
jsr PUTSTRNG
jsr GETCHAR ;char input => B
cmpb #$0D ;'enter'
beq checkz
beq quit
checkz jsr Display
bra main
quit swi

;*******************************************************
; Display
;*******************************************************


disp
std ChkResult
ldd #Answer ;answer
jsr PUTSTRNG
ldd #ChkResult ;Address => D
jsr OUTDECW
jsr OUTCRLF
rts


;**********************
; Rand Num Gen
;**********************
;rnd
; pshb ;push b onto stack
; andb #MASK4 ;set number to use
; lsrb
; lsrb
; lsrb
; lsrb
; eorb crnt ;xor current number
; stab crnt ;store current number
; ldab 0,sp
; andb #MASK3
; lsrb
; lsrb
; lsrb
; eorb crnt
; stab crnt
; ldab 0,sp
; andb #MASK2
; lsrb
; lsrb
; eorb crnt
; stab crnt
; ldab 0,sp
; andb #MASK0
; eorb crnt
; stab crnt
; ldaa crnt
; ldab 0,sp
; lsrd
; stab 0,sp
; pulb ;pul b to balance stack
; rts

;*******************************************************
; Constants
;*******************************************************
Prompt dc.b 'c>',$0d,$0a,$00
Answer dc.b '',$00
;*******************************************************
; Variables
;*******************************************************
ChkResult ds.w 1[/code]
Sign In or Register to comment.