大会计划

时间:2010-11-10 21:20:44

标签: assembly

我想在Assembly中创建一个程序,它将从键盘读取一个字符串,然后将每个字母转换为另一个表,然后将它存储在[201]的表中。在[200]我有一个字符串的字母计数器。这就是我所做的:

mov [0300h],88h        ;thats the table that I want to convert to.(only 3 digits)

mov [0301h],83h

mov [0302h],0CEh


mov ah,01h                     ;insert string 
int 81h                   


mov di,01h                 

start: 
mov al,[di]  
cmp al,00h          ;not
    sure about that. last char of string
    should be /0.

je end                  
mov [0200h],di    ;char counter.    
inc di

mov bx,0300h      
sub al,041h
    ;convert char 
xlat 
mov [di+01ffh],al
    ;store converted char to 201...

loop start 

end:

**int 81h**
;reads chars until <cr> from keyboard.Starting  address of input data buffer             ES:DI+1

出于某种原因,DI在我的程序结束时取值0900。知道为什么它不起作用,或任何我可以通过任何其他方式做出的想法?非常感谢。

2 个答案:

答案 0 :(得分:0)

mov al,[di]

你不应该在输入缓冲区添加偏移吗?

答案 1 :(得分:0)

它太破了..看看这个例子(它认为int81的fn 1读取一个char。不知道实际的接口):

some_table: db 88h, 83h, CEh
result:     db ??(128) // can't recall the syntax

push ds
pop  es
lea bx, some_table
lea di, result // for stosb to work

start: 
mov ah,01h                     ;//insert string 
int 81h                   
cmp al, 0Ah  // enter in linux (or it's 0Dh?)
je end                  
sub al, 'A' // what do you mean by "convert to char"? it's already a char. and what happens if it's larger than 'C'?
xlat 
stosb 
jmp start 
end: