線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1508
推到 Plurk!
推到 Facebook!

【ASM】請問16進制轉2進制並且分組的問題

尚未結案
Darkest
一般會員


發表:1
回覆:1
積分:0
註冊:2003-07-22

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-07-23 00:00:13 IP:218.163.xxx.xxx 未訂閱
老師丟了一張紙,叫我們去做,內容如下: Write twice a main program that calls a procedure, firstin a single module, then in separate modules.    The main program will contain the definition of an ASCII character string of hexadecimal symbols. The corresponding numbers will be given in an ascending sequence. For example, the numbers may be given as     MINTERM  DB  '013678ABC$'    The character $ is used as an ending delimiter.    The subprogram will first convert each ASCII code in the string into a binary number, then put the number into a certain separate group according to the number of 1's it contains. Numbers with the same number of 1's should be kept in an ascending sequence. For example, the given string should be sorted into         Group_0  0,FFh         Group_1  1,8,FFh         Group_2  3,6,A,C,FFh         Group_3  7,B,FFh         Group_4  FFh    Note that a particular group may be empty. You can try to initialize each group in such a way so that your programming effort can be reduced.    意思大概是..寫兩個程式,一個主程式,一個副程式(ProgA,ProgB) ProgA將16進制的一串數值轉為ASCII ProgB將這些數值ㄉASCII轉為2進制,並且將這些數值分組(以2進制的1的數目分組,如0有0個1所以在Group_0,1h,8h有1個1所以分到Group_1..以此類推)    老師說這個不但佔暑修期末考50%  期末考也要考這個   要是有好心大大可以幫上忙  希望在較難理解的地方加簡單的註解 因為要讀.. 希望好心的大大能為我解決這個問題..~_~" 發表人 -
Darkest
一般會員


發表:1
回覆:1
積分:0
註冊:2003-07-22

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-07-23 00:57:53 IP:218.163.xxx.xxx 未訂閱
Prog_A已經解決 請大大們幫我看看 ;程式目的:將16進位轉為ASCII碼    INCLUDE UTILITY.H DX2AL        MACRO                ;這個巨集唯一的作用是用來把dx的4個高bit         LOCAL        lop        ;依次移入al的低bits         mov        al,0         mov        cx,4 lop:        sal        dx,1         rcl        al,1         loop        lop         ENDM         .MODEL         .DATA         EXTRN        result1:WORD,ascii_result1:BYTE ascii_table        DB        '0123456789ABCDEF'        ;ASCII碼轉換表 count                DB        ?         .CODE         PUBLIC        hex_to_ascii hex_to_ascii        PROC         mov        si,0         mov        di,0         lea        bx,ascii_table        ;ds:bx指向ascii_table next1:        mov        dx,result[si] next2:        DX2AL        ;移dx的高4bits至al的低4bits                 xlatb        ;轉換成ASCII碼         mov        ascii_result1[di],al         inc        di        ;指向ascii_result1[]陣列下一元素         test        di,11b        ;在3與7時         jnz        next2        ;會被測出(ZF=0)         inc        si         inc        si        ;si=0,2時才執行         cmp        si,2        ;所以一共執行兩次         jbe        next1         ret hex_to_ascii        ENDP         END            不過現在問題變成..如何將Prog_B的ASCII變成binary然後分組.. 而且要如何將這兩個程式組合.. 好苦惱啊..大大們幫幫我吧
系統時間:2024-05-11 5:38:47
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!