汇编程序初学问题

来源:百度知道 编辑:UC知道 时间:2024/07/14 14:46:21
题目是这样的:将AX中的双字节数据拆成四部分(每部分4位)顺序存入内存中,例如:AX=1234H,拆后放入内存中为:01H,02H,03H,04H,请问怎么实现阿,最好能把完整程序贴上去,谢了

程序如下,供LZ参考:
data segment
W db 0,0,0,0
data ends

code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov ax,1234H
mov bx,ax

mov cl,4
shr ah,cl
mov W,ah ;写入01H
and bh,0fh
mov W+1,bh ;写入02H
mov cl,4
shr al,cl
mov W+2,al ;写入03H
and bl,0fh
mov W+3,bl ;写入04H

mov ax,4c00h
int 21h
code ends
end start