汇编语言在循环中存储字符

时间:2015-11-03 03:17:13

标签: assembly

后面的代码编译,只会在循环中的putString中生成我名字的第一个字母。它需要生成我姓名的所有字母,以便存储

jmp  firstline

openMsg db "Program by John Piper", 13, 10  
lenOpenMsg = $ - openMsg

myName  db  "John Piper"   
myNameLen = $ - myName  
myName1 db  ?  
myNameLen1 = $ - myName1  
myName2 db  ?  
myNameLen2 = $ - myName2  

firstline:

    mov  SI, offset openMsg 
    mov  CX, lenOpenMsg 
    call putStrng   
    call crlf


    mov  si, offset myName
    mov  cx, myNameLen
    call putStrng
    call crlf
    call crlf


    mov  si, 0
    mov  cx, myNameLen
LoopTop1:  
    mov  dl, myName(si)  
    xor  dl, 0AB  
    mov  myName1(si), dl  
    inc  si  
    loop LoopTop1  


    mov  si, offset myName1
    mov  cx, myNameLen1
    call putStrng
    call crlf
    call crlf



    mov  ah, 04c
    int  021

include ioProcs.inc

1 个答案:

答案 0 :(得分:0)

index只为myName1 db ?保留一个字节。因此,myName1将为1,myNameLen1将写入一个字节。此外,您将覆盖putStrng后面的内存。保留myName1myName1的地点与myName2消耗的数量相同:

myName