You are on page 1of 3

ASCII Code Table

HEX 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F DEC 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 CHR NUL SOH STX ETX EOT ENQ ACK BEL BS HT LF VT FF CR SO SI DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US Ctrl ^@ ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z HEX DEC 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 CHR SP ! # $ % & ( ) * + , . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? HEX DEC 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 CHR @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ HEX DEC 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F 96 97 98 99 100 101 102 103 104 105 106 107 108 109 100 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 CHR ` a b c d e f g h I j k l m n o p q r s t u v w x y z { | } ~ DEL

EECC250 - Shaaban
#1 lec #13 Winter99 1-17-2000

ASCII-Encoded Decimal To Binary Conversion


Subroutine DECBIN, assumes A0 to point at the highest character of a valid five character ASCII-encoded decimal number with a maximum value 65535 The decimal number is converted to a one word binary value stored in the low word of D0
ORG CLR.L MOVEQ CLR.L MOVE.B SUBI.B MULU ADD.W SUBI.B BNE RTS $1000 D0 #5,D6 D1 (A0)+,D1 #$30,D1 #10,D0 D1,D0 #1,D6 NEXTD

DECBIN NEXTD

Initialize loop counter to get five digits Clear new digit holding register Get one ASCII digit from memory Subtract ASCII bias $30 Multiply D0 by 10 Add new digit to binary value in D0 Decrement counter If not done get next digit

EECC250 - Shaaban
#2 lec #13 Winter99 1-17-2000

Binary To ASCII-Coded Decimal Conversion


Subroutine BINDEC, converts binary value in the lower word of register D0 into an ASCIIcoded decimal string. Address where resulting ASCII string should be stored is given in A0 This routine does not eliminate leading zeroes when the value is less than 10000 ORG MOVE.W MOVE.W BSR MOVE.W BSR MOVE.W BSR MOVE.W BSR MOVE.B ADDI.B MOVE.B RTS ANDI.L DIVU MOVE.B ADDI.B MOVE.B SWAP RTS $1000 D0,D6 #10000,D5 DIGIT #1000,D5 DIGIT #100,D5 DIGIT #10,D5 DIGIT D6,D1 #$30,D1 D1,(A0)+ #$0FFFF,D6 D5,D6 D6,D1 #$30,D1 D1,(A0)+ D6 Make a copy of input number Get 10000s digit Get 1000s digit Get 100s digit Get 10s digit Get 1s digit Add ASCII bias Store 1s ASCII digit in memory Clear upper word of D6 Divide D6 by D5 Load result digit in D1 Add ASCII bias Store ASCII digit in memory Get remainder

BINDEC

DIGIT

EECC250 - Shaaban
#3 lec #13 Winter99 1-17-2000

You might also like