幫忙將下面16bit匯編改成32bit匯編。測試成功後再加200分酬謝,絕不食言。謝謝

lypp 2003-08-26 09:35:20
PAGE 66,132

OPTION segment:use16 ; This directive should be placed before .386P so that the default segment size will be 16 bits
OPTION OFFSET:GROUP ; Default
OPTION CASEMAP:NONE
.386P
.MODEL LARGE, C

DGROUP GROUP _DATA,CONST,STACK

PAGE
;+===========================================================================+
;| Structure |
;+===========================================================================+
IMAGE STRUCT
wWidth WORD ?
wHeight WORD ?
wColorBit WORD ?
wWidthPixel WORD ?
wHeightPixel WORD ?
acMap BYTE 0 DUP(?)
IMAGE ENDS

PAGE
;+===========================================================================+
;| Macro |
;+===========================================================================+

PAGE
;+===========================================================================+
;| Constant |
;+===========================================================================+
;***********
;
;***********
BPT TEXTEQU <BYTE PTR>
WPT TEXTEQU <WORD PTR>
DPT TEXTEQU <DWORD PTR>

FALSE EQU 1 eq 0
TRUE EQU 1 eq 1
NO EQU FALSE
YES EQU TRUE

;***********
;
;***********
CONST SEGMENT PUBLIC 'CONST'

g_adwColor LABEL DWORD
DWORD 000000000h
DWORD 000000001h
DWORD 000000100h
DWORD 000000101h
DWORD 000010000h
DWORD 000010001h
DWORD 000010100h
DWORD 000010101h
DWORD 001000000h
DWORD 001000001h
DWORD 001000100h
DWORD 001000101h
DWORD 001010000h
DWORD 001010001h
DWORD 001010100h
DWORD 001010101h

CONST ENDS

PAGE
;+===========================================================================+
;| Global variable |
;+===========================================================================+
_DATA SEGMENT PUBLIC 'DATA'

;uffer DWORD 0CC88CC88h

_DATA ENDS

PAGE
;+===========================================================================+
;| Stack |
;+===========================================================================+
STACK SEGMENT STACK 'STACK'

; BYTE 100h DUP(0)

STACK ENDS

PAGE
;+===========================================================================+
;| Program |
;+===========================================================================+
_TEXT SEGMENT PUBLIC 'CODE'
ASSUME cs:_TEXT
ASSUME ds:DGROUP

Begin:
ConvertColorPlane \
PROC USES eax bx ecx dx si di ds es, \
lpsDst:DWORD, \
lpsSrc:DWORD, \
wWidth:WORD
LOCAL adwColor[16]:DWORD, \
wIndex:WORD, \
wLoopOfLine:WORD, \
wLoopOf8Bit:WORD

;***********
; Move color table to stack for easy process
;***********
mov ax,DGROUP ; Prepare segment register
mov ds,ax

sub si,si
mov cx,16
@@:
mov eax,g_adwColor[si] ; Must use si as index register
mov adwColor[si],eax ; If use bx, it will be "Error A2029: multiple base registers not allowed"
add si,4
loop @B
;***********
;
;***********
lds bx,lpsSrc ; Source bit map
les di,lpsDst ; Destination bit map
mov ax,wWidth ; wIndex = wWidth * 2 / 8
shr ax,2 ; 2 Pixels in 1 byte in original bit map
mov wIndex,ax ; 8 Pixels in 1 byte in converted bit map - Each byte represent a color plane

mov wLoopOfLine,ax ; Loop n of 8-bit per scan line
_CCP_010:
mov wLoopOf8Bit,4 ; Loop 8-bit (4 bytes) in a scan line
sub eax,eax
_CCP_020:
sub dx,dx
mov dl,[bx] ; Fetch 1 byte of bit map

mov si,dx
and si,000F0h ; Fetch 1st pixel in the high 4-bit
shr si,2 ; Adjust for DWORD
mov ecx,adwColor[si]
shl eax,1
or eax,ecx

mov si,dx
and si,0000Fh ; Fetch 2nd pixel in the low 4-bit
shl si,2 ; Adjust for DWORD
mov ecx,adwColor[si]
shl eax,1
or eax,ecx

inc bx ; Point to the next byte of source bit map
dec wLoopOf8Bit
jnz _CCP_020

push bx
mov es:[di],al ; Store color plane 0 to destination bit map
mov bx,wIndex
mov es:[di][bx],ah ; Store color plane 1 to destination bit map
shr eax,16
add bx,wIndex
mov es:[di][bx],al ; Store color plane 2 to destination bit map
add bx,wIndex
mov es:[di][bx],ah ; Store color plane 3 to destination bit map
pop bx

inc di ; Point to the next byte of destination bit map
dec wLoopOfLine
jnz _CCP_010

ret

ConvertColorPlane \
ENDP

END ;egin
...全文
114 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
wylpro 2003-08-28
  • 打赏
  • 举报
回复
就照我那样写,没错。
你把它声明成16位模式,当然不行了。
还有,入口,出口,变成32位就行了,内部是不是32位没关系。
如果在保护模式下运行,保证内部不改变段寄存器,其他遵照delphi入口约定保存寄存器。
蚊子王 2003-08-27
  • 打赏
  • 举报
回复
这个不是纯粹替换一下就可以的,要修改很多地方的。
lypp 2003-08-27
  • 打赏
  • 举报
回复
Purpleendurer(Purplenendurer):
能否幫改寫成32bit匯編。現在程序是16bit和32bit混用了。
我用delphi7調用它(obj),編譯就報遭遇16bit的錯誤。麻煩了,謝謝!!
紫郢剑侠 2003-08-27
  • 打赏
  • 举报
回复
程序风格不错哟!
wecomputer 2003-08-26
  • 打赏
  • 举报
回复
up
Tiangua 2003-08-26
  • 打赏
  • 举报
回复
gz
wylpro 2003-08-26
  • 打赏
  • 举报
回复
这么沃绰的提问方式 不会是作业吧
wylpro 2003-08-26
  • 打赏
  • 举报
回复
PAGE 66,132

OPTION segment:use16 ; This directive should be placed before

改成:
PAGE 66,132

OPTION segment:use32 ; This directive should be placed before
W32API 2003-08-26
  • 打赏
  • 举报
回复
没弄明白你想说什么。。。
你的代码已经是在用 32-bit mode 了的啊。。。
不然你在使用 eax 时就是 error。

21,459

社区成员

发帖
与我相关
我的任务
社区描述
汇编语言(Assembly Language)是任何一种用于电子计算机、微处理器、微控制器或其他可编程器件的低级语言,亦称为符号语言。
社区管理员
  • 汇编语言
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧