计划未按计划运作

时间:2015-10-26 20:58:22

标签: assembly masm irvine32

在我的代码中,我在屏幕上成功打印了名称,但现在我只需要打印我的姓氏。虽然它仍然提示整个名称,但屏幕上只显示姓氏。我一直在努力,但我无法弄清楚。

我的代码:

include irvine32.inc

title Read5

.data

outmsg DB " Will Smith: ",0    ;promts here will smith but on screen only smith

len    DW 0

.code

main proc

mov ecx, 5

mov edx, offset outmsg

call writestring

call crlf

sub eax,eax

ShowChar:

sub eax,eax

mov al, [ebx]

call writechar

sub ebx, 1

loop showChar

Exit 

main endp

end main

1 个答案:

答案 0 :(得分:0)

您忘记在EBX中设置指针。

 mov  ebx, offset outmsg + 6  ; +6 to skip " Will "
 mov  ecx, 5
ShowChar:
 sub  eax, eax
 mov  al, [ebx]
 call writechar
 add  ebx, 1                  ; don't subtract here
 loop ShowChar

当然,您也可以使用与完整名称相同的方式打印姓氏。

 mov  edx, offset outmsg + 6  ; +6 to skip " Will "
 call writestring
 call crlf