2010-11-10 179 views
0

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

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。任何想法,为什么它不工作,或任何想法,我可以通过任何其他方式?非常感谢。

回答

0
mov al,[di] 

不应该在这里向输入缓冲区添加偏移量吗?

+0

你可以举个例子PLZ? thnx – John 2010-11-10 22:21:44

+0

你的代码假设你的输入缓冲区从ds开始:[1]。这是真的吗? – 2010-11-11 00:01:55

+0

我的输入始于ES:di + 1 – John 2010-11-11 08:51:39

0

它打破洙..看看本作为例(它认为FN int81的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: 
+0

hmmm。我只是不知道如果bgc8088可以支持这种桌子。我想要转换字符,我做了一个电路,将显示“转换”的字符。我的A将是88h而不是41h,依此类推。 – John 2010-11-10 22:41:09

+0

int 81不带一个字符。它读取字符,直到从键盘“enter in bgc8088” – John 2010-11-11 09:12:52

+0

,所以我不知道我是否可以使用stosb。 – John 2010-11-11 10:13:18