It is currently Sat Apr 04, 2020 8:48 am

 All times are UTC

 Page 1 of 1 [ 3 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: unsigned numberPosted: Mon Oct 25, 2010 9:15 pm

Joined: Sat Oct 16, 2010 9:57 am
Posts: 2
i want to add,subtract,divide,multiply using unsigned number and to display it at output windos..
what the program to do it?

Top

 Post subject: Posted: Tue Oct 26, 2010 11:30 am

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1118
Trap task 15 will display the unsigned number in D1.L converted to number base (2 through 36) contained in D2.B.
For example, to display D1.L in base10 put 10 in D2.B

_________________
Prof. Kelly

Top

 Post subject: tq..but i still cannot do it..Posted: Tue Oct 26, 2010 2:25 pm

Joined: Sat Oct 16, 2010 9:57 am
Posts: 2
prof,my probem is
1.how to do add,subtract,divide,multiply using unsigned number..i cannot solve it..
2.how to running the clock?and how to put AM or PM..
3.i enter 12+12=..then i save the result by pressing 'a',then i clear the result by presing 'c'...my problem is how to recall or enter number for operation after clear the result?..i want to do both function..i just can choose only one..recall or enter number..my program below,i do for enter number after clear result..

hope you can help me..please..tq so much.

prof this is my program..
Code:
*-----------------------------------------------------------
* Program    :simple calculator
* Written by :shaiful
* Date       :
* Description:
*-----------------------------------------------------------

NOON    EQU     12*60*60*100                            ;clock

*-----------------------<CONTROL CHARACTERS>-----------------------------
BS      EQU     \$08   BACKSPACE
HT      EQU     \$09   TAB (HORIZONTAL 5 CHARACTERS)
LF      EQU     \$0A   NEW LINE (LINE FEED)
VT      EQU     \$0B   VERTICAL TAB (4 LINES)
FF      EQU     \$0C   FORM FEED (ALWAYS END PRINTING WITH A FORM FEED.)
CR      EQU     \$0D   CARRIAGE RETURN
*------------------------------------------------------------------------

*--------------------------------------<MAIN PROGRAM>----------------------------------------

START   ORG     \$1000

JSR     WELCOME
JSR     TIMES           ;jum to subroutine
JSR     DELAY           ;delay to display time and greeting

MOVE    #11,D0          ;clear screen
MOVE.W  #\$FF00,D1       ;clear screen
TRAP    #15             ;use for I/O

enter1  JSR     SHOW
move    #14,d0
lea     masuk1,a1
trap    #15

move    #4,d0          ;read from key board
trap    #15

move.l  d1,d7           ;from keybrd to d7
clr.l   d1

*--------------------<SUBROUTINE FOR KEYBOARD>---------------------

KEY_BRD move    #5,d0          ;read from key board
trap    #15

cmp.b   #'s',d1
beq     submem

cmp.b   #'r',d1
beq     recall

cmp.b   #'a',d1

cmp.b   #'b',d1
beq     clrmem

CMP.B   #'c',d1
beq     CLEAR

cmp.b   #'-',d1
beq     sub

cmp.b   #'+',d1

cmp.b   #'/',d1
beq     div

cmp.b   #'=',d1
beq     result

cmp.b   #'*',d1
beq     mul

bra     KEY_BRD

*------------------------------------------------------------

*-----------------<FUNCTION SUBROUTINE>------------------------

lea     masuk2,a1
trap    #15             ;enter second number

move    #4,d0
trap    #15

move.l  d1,d6
clr     d1

move.l  d7,d2           ;move for displ

bra     KEY_BRD

result  move.b  #3,d0           ;display num in d1
move    d2,d1
trap    #15

bra     KEY_BRD

sub     move    #14,d0
lea     masuk2,a1
trap    #15           ;enter second number

move    #4,d0
trap    #15

move.l  d1,d6

sub.l   d6,d7           ;subtrat
move.l  d7,d2        ;move for displ

BRA     KEY_BRD

div     move    #14,d0
lea     masuk2,a1
trap    #15             ;enter second number

move    #4,d0
trap    #15

move.l  d1,d6

divs    d6,d7        ;divide

move.l  d7,d2

BRA     KEY_BRD

mul     move    #14,d0
lea     masuk2,a1
trap    #15             ;msukkan no ke2

move    #4,d0        ;bca dr key board
trap    #15

move.l  d1,d6

muls    d6,d7           ;multiply

move.l  d7,d2           ;

BRA     KEY_BRD

CLEAR   CLR.L   D1              ;reset D1
MOVE    #11,D0          ;reset SCREEN
MOVE.W  #\$FF00,D1       ;reset SCREEN
TRAP    #15
jsr     enter1

clrmem  CLR.L   D0              ;reset DO
CLR.L   D1              ;reset D1
CLR.L   D2              ;reset D2
CLR.L   D3              ;reset D3
CLR.L   D4              ;reset D4
CLR.L   D5              ;reset D5
CLR.L   D6              ;reset D6
CLR.L   D7              ;reset D7
MOVEA   A5,A1           ;reset A1
MOVEA   A5,A2           ;reset A2
MOVEA   A5,A3           ;reset A3
MOVEA   A5,A4           ;reset A4
MOVEA   A5,A6           ;reset A6
MOVE    #11,D0          ;reset SCREEN
MOVE.W  #\$FF00,D1       ;reset SCREEN
TRAP    #15
BRA     enter1

bra     KEY_BRD

recall move    #3,d0
move    d5,d1
trap    #15
bra     KEY_BRD

submem  sub     d5,d2
move    #3,d0
move    d2,d1
trap    #15
move    d2,d7
bra     KEY_BRD

*--------------------------------------------------------------

*------------------------------------<SUBROUTINE FOR TIME>---------------------------------------

TIMES   MOVE    #14,D0          ;display the null terminated string at A1 witout CR,LF
LEA     TIME,A1         *LOAD FROM MESSAGE DEFINITIONS
TRAP    #15             *USED FOR I/O

MOVE    #8,D0           *RETURN TIME IN HUNDREDTHS OF A SECOND SINCE MIDNIGHT IN D1.L
TRAP    #15             *USED FOR I/O

IF.L    D1 <HS> #NOON
SUB.L   #NOON,D1
ENDI

DIVU    #100,D1
ANDI.L  #\$0000FFFF,D1
MOVE.L  D1,D5

DIVU    #60,D1
ANDI.L  #\$0000FFFF,D1
MOVE.L  D1,D6

DIVU    #60,D1
ANDI.L  #\$0000FFFF,D1
MOVE.L  D1,D4
JSR     DISP            *DISPLAY HOURS

MULU    #60,D1
SUB.L   D1,D6
MOVE.L  D6,D1
JSR     DISP            *DISPLAY MINUTES

MULU    #60,D1
SUB.L   D1,D5
MULU    #3600,D4
SUB.L   D4,D5

MOVE    #3,D0
MOVE.L  D5,D1
TRAP    #15             *DISPLAY SECONDS
RTS                     *RETURN FROM SUBROUTINE TIMES

*-------------------------------------------------------------------------------------------

*--------------------------------<SUBROUTINE TO DISPLAY VALUE IN D1>--------------------------

DISP    MOVE    #3,D0           *DISPLAY SIGNED NUMBER IN D1.L IN DECIMAL IN SMALLEST FIELD
TRAP    #15             *USED FOR I/O
MOVE    #14,D0          *DISPLAY THE NULL TERMINATED STRING AT (A1) WITHOUT CR, LF
LEA     SPACE,A1        *LOAD FROM MESSAGE DEFINITIONS
TRAP    #15             *USED FOR I/O
RTS                     *RETURN FROM DISP SUBROUTINE

*-------------------------------------------------------------------------------------------

*---------------------------<SUBROUTINE WELCOME>--------------------------------------------

WELCOME LEA     GRETG,A1         *DISPLAY MSG0 FROM MESSAGE DEFINITIONS
MOVE.W  #14,D0
TRAP    #15
BEQ     DONE

LEA     GRETG1,A1         *DISPLAY MSG1 FROM MESSAGE DEFINITIONS
MOVE.W  #14,D0
TRAP    #15
BEQ     DONE

RTS

*--------------------------------------------------------------------------------------------

*-----------------------------<SUBROUTINE MESSEG>----------------------------------------------------------------------------

masuk1  dc.b    LF,CR,''
masuk2  dc.b    '',0
GRETG   DC.B    VT,VT,VT,CR,HT,HT,HT,HT,HT,HT,'   WELCOME!!!!',0         *SHOW GREETING WELCOME
GRETG1  DC.B    LF,LF,CR,HT,HT,HT,HT,HT,'  THIS IS SIMPLE CALCULATOR',0
TIME    DC.B    LF,LF,CR,HT,HT,HT,HT,HT,'     TIME NOW IS ',0                                                          *SHOW TIME
SPACE   DC.B    ':',0                                                                     *SPACE BETWEEN HOURS,MINUTES AND SECONDS IN TIME
MSG     DC.B    LF,LF,CR,'<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>',0       *DISPLAY SELECTION OF TRANSACTION
MSG0    DC.B    LF,CR,CR,'|  PRESS * TO (multiply)    PRESS + TO (add)          |',0      *DISPLAY SELECTION OF TRANSACTION
MSG1    DC.B    LF,CR,CR,'|  PRESS - TO (subtract)    PRESS = TO (result)       |',0      *DISPLAY SELECTION OF TRANSACTION
MSG2    DC.B    LF,CR,CR,'|  PRESS / TO (divide)      PRESS C TO CLEAR RESULT   |',0      *DISPLAY SELECTION OF TRANSACTION
MSG3    DC.B    LF,CR,CR,'|  PRESS A SAVE RESULT      PRESS B TO CLEAR MEMORY   |',0      *DISPLAY SELECTION OF TRANSACTION
MSG4    DC.B    LF,CR,CR,'|  PRESS S TO SUBTRACT FROM MEMORY                    |',0      *DISPLAY SELECTION OF TRANSACTION
MSG5    DC.B    LF,CR,CR,'|  PRESS R TO RECALL CONTENT OF MEMORY                |',0      *DISPLAY SELECTION OF TRANSACTION
MSG6    DC.B    LF,CR,CR,'<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>',LF,0    *DISPLAY SELECTION OF TRANSACTION

*----------------------------------------------------------------------------------------------------------------------------

*---------------------<SUBROUTINE DELAY>----------------------

DELAY   MOVE.L  #\$AFFFFF,D0     *MOVE VALUE \$6FFFFF TO D0
LOOP    SUB.L   #1,D0           *SUBTRACT VALUE IN D0 BY 1
BNE     LOOP            *LOOP PROGRAM UNTIL D0 ZERO
RTS                     *RETURN FROM DELAY SUBROUTINE

*-------------------------------------------------------------

*-------<PROGRAMMING TO RESET DATA AND ADRESS REGISTRY>--------

RESET   CLR.L   D0              *RESET D0
CLR.L   D1              *RESET D1
CLR.L   D2              *RESET D2
CLR.L   D3              *RESET D3
CLR.L   D4              *RESET D4
CLR.L   D5              *RESET D5
CLR.L   D6              *RESET D6
CLR.L   D7              *RESET D7
MOVEA   A5,A1           *RESET A1
MOVEA   A5,A2           *RESET A2
MOVEA   A5,A3           *RESET A3
MOVEA   A5,A4           *RESET A4
MOVEA   A5,A6           *RESET A6

*-------------------------------------------------------------

* SUBROUTINE TO DISPLAY MESSAGE AFTER ADD ITEMS AND DO SOME CORRECTION
* ====================================================================
*----------------------------------------------------------------------|
SHOW    LEA     MSG,A1          *DISPLAY MSG FROM MESSAGE DEFINITIONS
MOVE.W  #14,D0
TRAP    #15
BEQ     DONE

LEA     MSG0,A1         *DISPLAY MSG0 FROM MESSAGE DEFINITIONS
MOVE.W  #14,D0
TRAP    #15
BEQ     DONE

LEA     MSG1,A1         *DISPLAY MSG1 FROM MESSAGE DEFINITIONS
MOVE.W  #14,D0
TRAP    #15
BEQ     DONE

LEA     MSG2,A1         *DISPLAY MSG2 FROM MESSAGE DEFINITIONS
MOVE.W  #14,D0
TRAP    #15
BEQ     DONE

LEA     MSG3,A1         *DISPLAY MSG6 FROM MESSAGE DEFINITIONS
MOVE.W  #14,D0
TRAP    #15
BEQ     DONE

LEA     MSG4,A1         *DISPLAY MSG4 FROM MESSAGE DEFINITIONS
MOVE.W  #14,D0
TRAP    #15
BEQ     DONE

LEA     MSG5,A1         *DISPLAY MSG4 FROM MESSAGE DEFINITIONS
MOVE.W  #14,D0
TRAP    #15
BEQ     DONE

LEA     MSG6,A1         *DISPLAY MSG4 FROM MESSAGE DEFINITIONS
MOVE.W  #14,D0
TRAP    #15
BEQ     DONE

RTS                     *RETURN FROM SUBROUTINE SHOW
*----------------------------------------------------------------------|

* HALT SIMULATOR
* ==============
*------------------------------------------------------|
DONE    MOVE.B  #9,D0           *TERMINATE THE PROGRAM
TRAP    #15             *USED FOR I/O
*------------------------------------------------------|

END     START

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 3 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: Majestic-12 [Bot] and 2 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ EASy68K Forum    FAQ    Latest Features    EASy68K Questions    68000 Programming Questions    Wish List    Wishes Granted    Undocumented Features    Documented Features    General Discussion    EASy68K Projects