1 / 5

Calculator

Calculator. 9S12DP256 Lab 2. Convert counted string at addr1 to double number ud2 ud1 normally zero to begin with addr2 points to first invalid character : >NUMBER ( ud1 addr1 -- ud2 addr2 ). ptr. kbuf. Calculator (add) LOAD lcd256.whp LOAD keypad12.whp

sabine
Télécharger la présentation

Calculator

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Calculator 9S12DP256 Lab 2

  2. \ Convert counted string at addr1 to double number ud2 \ ud1 normally zero to begin with \ addr2 points to first invalid character : >NUMBER ( ud1 addr1 -- ud2 addr2 ) ptr kbuf \ Calculator (add) LOAD lcd256.whp LOAD keypad12.whp VARIABLE ptr VARIABLE first VARIABLE kbuf 20 ALLOT : init ( -- ) kbuf ptr ! SPI.INIT init.key lcd.init TRUE first ! ;

  3. \ Convert counted string at addr1 to double number ud2 \ ud1 normally zero to begin with \ addr2 points to first invalid character : >NUMBER ( ud1 addr1 -- ud2 addr2 ) kbuf 31 32 33 Enter decimal number 123 ptr : display ( n -- ) first @ \ if first digit IF init \ clear display FALSE first ! THEN hex2asc DUP >data8 \ display digit 1 ptr +! \ update ptr ptr @ C! ;

  4. \ Convert counted string at addr1 to double number ud2 \ ud1 normally zero to begin with \ addr2 points to first invalid character : >NUMBER ( ud1 addr1 -- ud2 addr2 ) 3 kbuf 31 32 33 Press E ptr 0 : enter ( n -- d ) DROP ptr @ kbuf - \ get no. of chars kbuf C! \ make counted string 1 ptr +! 0 ptr @ C! \ make asciiz string 0 0 kbuf \ convert ascii string >NUMBER DROP \ to double number TRUE first ! ;

  5. : add ( d1 n -- d2 ) clear.lcd enter D+ 2DUP (D.) type.lcd ; : calc ( -- ) init BEGIN wait.for.keyup getkey DUP 14 = \ E key IF enter ELSE DUP 10 = \ A key IF add ELSE DUP 12 = \ C key IF init ELSE display THEN THEN THEN AGAIN ;

More Related