hddblue 发表于 2010-10-19 16:41:51

顯示string會出現亂碼

各位前輩好,以下的程式為在 big_real_mode 讀取記憶體的值

例如: C:\memory.exe(程式檔名) 01000100(Address)

則會顯示01000100位置的值

但是我另外還有要顯示出字串,但是顯示出來都是亂碼

麻煩前輩給我一些指導,謝謝


.model small
.386p
;------------------------------------------------------------------------------------------------
DSEG SEGMENT USE16'data'

DESC STRUC
LimitL DW 0
BaseL DW 0
BaseM DB 0
Attributes DB 0
LimitH DB 0
BaseH DB 0
DESC ENDS

PDesc STRUC
Limit DW 0
Base DD 0
PDesc ENDS

GDT_def Label Fword
Null_Desc DESC < 0h, 0h, 00h, 00h, 000h, 0>
Data_Desc DESC < 0FFFFh, 0h, 00h, 92h, 0CFh, 0>
GDT_Addr PDesc <$-GDT_def-1, >

msg1 BYTE 'The Input Address is:$'
msg2 BYTE 'The Data is:','$'

DSEG ENDS


;------------------------------------------------------------------------------------------------

ASSUME CS:CSEG,DS:DSEG

CSEG SEGMENT USE16'code'

push ds
push es
push fs
push gs

call big_real_mode

   
mov edx,OFFSET msg1;
mov ah,09h;   
int 21h;
mov edx,OFFSET msg2;
mov ah,09h;
int 21h;
   
call PSP   
   
call crlf   
   
mov esi,ebx
mov eax,fs:
out 80h,eax
mov ebx,eax
call _8bits
   
call real_mode
   
pop gs
pop fs
pop es
pop ds
   
.exit
;------------------------------------------------------------------------------------------------
big_real_mode proc near
in al, 92h
or al, 002
out 092h, al
out 0edh, al
cli
mov eax,DSEG
shl eax, 4
xor ebx, ebx
mov ebx, offset GDT_def
add eax, ebx
mov dword ptr GDT_Addr.Base, eax
lgdt fword ptr GDT_Addr
mov bx, 8
mov eax, cr0
or al, 1
mov cr0, eax
jmp PMod
PMod:
mov fs, bx
mov gs, bx
mov eax,cr0
and al, 0FEh
mov cr0, eax
jmp RMod
RMod:
xor ax, ax
mov fs, ax
mov gs, ax
   
sti
   
ret
big_real_mode ENDP
;------------------------------------------------------------------------------------------------
real_mode proc near
in al, 92h
and al, 02
out 92h, al   
ret
real_mode ENDP
;------------------------------------------------------------------------------------------------
Get_Commandtail PROC near
push es
pusha
mov ah,62h
int 21h
mov es,bx
popa
pop es
ret
Get_Commandtail ENDP
;------------------------------------------------------------------------------------------------
PSP proc near
mov ah,62h
int 21h
mov es,bx   
xor ebx,ebx
mov si,82h
mov al,es:
call Change
mov cl,4
shl ebx,cl
add ebx,eax
mov al,es:
call Change
mov cl,4
shl ebx,cl
add ebx,eax
mov al,es:
call Change
mov cl,4
shl ebx,cl
add ebx,eax
mov al,es:
call Change
mov cl,4
shl ebx,cl
add ebx,eax
mov al,es:
call Change
mov cl,4
shl ebx,cl
add ebx,eax
mov al,es:
call Change
mov cl,4
shl ebx,cl
add ebx,eax
mov al,es:
call Change
mov cl,4
shl ebx,cl
add ebx,eax
mov al,es:
call Change
mov cl,4
shl ebx,cl
add ebx,eax
ret
PSP endp
;------------------------------------------------------------------------------------------------
Change proc near
A:   
movzx eax,al
mov edx,eax
cmp eax,'0'   
jb A
cmp eax,'9'   
ja B
sub eax,'0'
jmp short E
B:
and eax,0dfh   
mov edx,eax
sub eax,37h   
cmp eax,0ah
jb A   
cmp eax,0fh
ja A   
E:
push eax   
call PRT   
pop eax
CExit:
ret
Change endp
;------------------------------------------------------------------------------------------------
PRT proc near
mov ah,02h
int 21h
ret
PRT endp
;------------------------------------------------------------------------------------------------
crlf proc near
mov ah,02h
mov dl,0dh
int 21h
mov ah,02h
mov dl,0ah
int 21h
ret
crlf endp
;------------------------------------------------------------------------------------------------
_32bits proc near
pushad
mov cl,4
rol ebx,cl
call print_4_bits
rol ebx,cl
call print_4_bits
rol ebx,cl
call print_4_bits
rol ebx,cl
call print_4_bits
rol ebx,cl
call print_4_bits
rol ebx,cl
call print_4_bits
rol ebx,cl
call print_4_bits
rol ebx,cl
call print_4_bits
rol ebx,cl
popad
ret
_32bits endp
;------------------------------------------------------------------------------------------------
_16bits proc near
pusha   
rol bx,cl
call print_4_bits
rol bx,cl
call print_4_bits
rol bx,cl
call print_4_bits
rol bx,cl
call print_4_bits
popa
ret
_16bits endp
;------------------------------------------------------------------------------------------------
_8bits proc near
pusha   
rol bx,cl
call print_4_bits
rol bx,cl
call print_4_bits
popa
ret
_8bits endp
;------------------------------------------------------------------------------------------------
print_4_bits proc near
mov dx,bx
and dl,0fh
add dl,30h
cmp dl,3ah
jb print
add dl,7
print:   
mov ah,2
int 21h
ret
print_4_bits endp   
;------------------------------------------------------------------------------------------------
CSEG ends
END
页: [1]
查看完整版本: 顯示string會出現亂碼