Using an HC12 with Cygwin and TerraTerm, I am designing a fixed point calculator. Being a little late to start I am seeking some solid help. 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:
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:
Rich (BB 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