EASy68K
http://www.easy68k.com/EASy68Kforum/

how to print integer in multi-digit hexadecimal
http://www.easy68k.com/EASy68Kforum/viewtopic.php?f=6&t=1020
Page 1 of 1

Author:  pinkberry [ Sat May 21, 2011 3:18 am ]
Post subject:  how to print integer in multi-digit hexadecimal

hello everyone!i am new to 68k assembly language. :oops:

i have a lab work that required us to print integer in multi-digit hexadecimal by passing parameters on the stack.and i have totally no idea how to do. :(

hope that someone can teach me thanks a lot C:

Author:  clive [ Sat May 21, 2011 6:25 am ]
Post subject: 

Code:
CR      EQU     $0D
LF      EQU     $0A

        ORG     $1000
START:
        MOVE.L  #$CAFECAFE,-(A7)
        BSR     OUTHEX8
        ADDA.L  #4,A7

        MOVE.L  #$12345678,-(A7)
        BSR     OUTHEX8
        ADDA.L  #4,A7

        MOVE.L  #$9ABCDEF0,-(A7)
        BSR     OUTHEX8
        ADDA.L  #4,A7

        MOVE.W  #CR,-(A7)
        BSR     OUTCHAR
        ADDA.L  #2,A7

        MOVE.W  #LF,-(A7)
        BSR     OUTCHAR
        ADDA.L  #2,A7

        MOVE.B  #9,D0
        TRAP    #15

OUTHEX8 LINK    A6,#0
        MOVEM.L D0-D2,-(A7)
        MOVE.L  8(A6),D0
        MOVE.W  #8-1,D1
NXTDIG  ROL.L   #4,D0
        MOVE.L  D0,D2
        AND.L   #$0F,D2
        CMP.B   #10,D2
        BCS     UNDER10
        ADD.W   #$07,D2
UNDER10 ADD.W   #$30,D2
        MOVE.W  D2,-(A7)
        BSR     OUTCHAR
        ADDA.L  #2,A7
        DBRA    D1,NXTDIG
        MOVEM.L (A7)+,D0-D2
        UNLK    A6
        RTS

OUTCHAR LINK    A6,#0
        MOVEM.L D0-D1,-(A7)
        MOVE.W  8(A6),D1
        MOVE.B  #6,D0
        TRAP    #15
        MOVEM.L (A7)+,D0-D1
        UNLK    A6
        RTS

        END     START

Author:  pinkberry [ Sat May 21, 2011 1:33 pm ]
Post subject: 

thanks clive :D

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/