我的程序集“测验乘"代码不起作用? [英] My assembly "quiz Multiply" code is not working?

查看:108
本文介绍了我的程序集“测验乘"代码不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的汇编代码.它不工作.. 我试图用另一种方式写它,但这给了我其他错误 我使用emu8086 .....在第一页中将有3页(1,2,3),您必须选择 页面.

this is my assembly code . it not working .. I tried to write it in another way but it gives me other mistakes I use emu8086..... in first page there will be 3 pages (1,2,3) and you have to choose which page.

1-学习2次考试3次退出

1- study 2-exam 3-exit

  1. 研究:将从0-9开始学习乘法表
  2. 考试:有关0-9岁多人的问题
  3. 从测验中退出

,完成测验后将出现标记.

and after finish quiz there will be mark.

multi-segment executable file template.

data segment                                      
    firstpage db "welcome to learn  math ",10,13,"create by:saad ",10,13,"1.study",10,13,"2.exam",10,13,"3.exit" ,10,13,"$"
    q1 db "2*1=$"
    q2 db "2*2=$"
    q3 db "2*3=$"
    q4 db "2*4=$"
    q5  db "2*5=$"  
  std1 db "2*1=1 $"
  std2 db "2*2=4 $"
  std3 db "2*3=6 $"
  std4 db "2*4=8 $"
  std5 db "2*5=10 $"
  nl    db ,10,13,"$"
  mark0 db "your mark us:0 $"
  mark1 db "your mark us:20 $"
  mark2 db "your mark us:40 $"
  mark3 db "your mark us:60 $"
  mark4 db "your mark us:80 $"
  mark5 db "your mark us:100 $"
count db 0
ends

stack segment
    dw   128  dup(0)
ends

code segment
start:

    mov ax, data
    mov dx, ax                                                          
    lea dx, firstpage
    mov ah, 9
    int 21h          
    mov ah,7
    int 21h  
    cmp al,3
    je t1


    t1: mov ax,3
    int 21h
    lea dx,std1
    int 21h
    mov ah,7
    int 21h
    lea dx ,nl
    mov ah,9
    int 21h    
       lea dx,std2
    int 21h
    mov ah,7
    int 21h
    lea dx ,nl
    mov ah,9
    int 21h
       lea dx,std3
    int 21h
    mov ah,7
    int 21h
    lea dx ,nl
    mov ah,9
    int 21h
       lea dx,std4
    int 21h
    mov ah,7
    int 21h
    lea dx ,nl
    mov ah,9
    int 21h
       lea dx,std5
    int 21h
    mov ah,7
    int 21h
    lea dx ,nl
    mov ah,9
    int 21h
    mov ah,7
    int 21h
    lea dx ,q1
    mov ah,9
    int 21h
    lea dx ,nl
    mov ah ,9
    int 21h
     lea dx ,q2
    mov ah,9
    int 21h
    lea dx ,nl
    mov ah ,9
    int 21h
     lea dx ,q3
    mov ah,9
    int 21h
    lea dx ,nl
    mov ah ,9
    int 21h
     lea dx ,q4
    mov ah,9
    int 21h
    lea dx ,nl
    mov ah ,9
    int 21h
     lea dx ,q5
    mov ah,9
    int 21h
    lea dx ,nl
    mov ah ,9
    int 21h
    mov ah,1
    int 21h
    cmp count,0
    je mark0
    cmp count,1
    je mark1
    cmp count, 2
    je mark2
     cmp count,3
    je mark3
     cmp count,4
    je mark4
     cmp count,5
    je mark5

      mark0:lea dx,mark0
    mov ah,9
    int 21h
    jmp soof
      mark1:lea dx,mark1
    mov ah,9
    int 21h
    jmp soof
      mark2:lea dx,mark2
    mov ah,9
    int 21h
    jmp soof
      mark3:lea dx,mark3
    mov ah,9
    int 21h
    jmp soof
      mark4:lea dx,mark4
    mov ah,9
    int 21h
    jmp soof
      mark5:lea dx,mark5
    mov ah,9
    int 21h
    jmp soof









    mov ax, 4c00h
    int 21h    
ends

end start

推荐答案

错误列表:

nl    db ,10,13,"$"

多余的逗号表示多余的零.您得到的是db 0,10,13,"$"

The extra comma translates to an extra zero. What you get is db 0,10,13,"$"

mov ax, data
mov dx, ax

要设置段寄存器,您需要编写:

To setup the segment registers you need to write:

mov ax, @data
mov ds, ax      ; Do read carefully: DS


mov ah,7
int 21h  
cmp al,3
je t1

当用户按下标有"3"的键时,您将在AL中收到代码51. 因此,您的支票应该为cmp al, 51或更好的cmp al, '3'.

When the user presses the key labeled "3", you will receive the code 51 in AL.
Your check therefore should be cmp al, 51 or better cmp al, '3'.

t1: mov ax,3      <<<<<< This sets AH=0
int 21h
lea dx,std1
int 21h
mov ah,7
int 21h

由于AH=0是ProgramExit函数,因此后续代码均不会执行.

Since AH=0 is a ProgramExit function, none of the code that follows will get executed.

mov ah,7
int 21h  

您的程序包含很多这样的内容,并且您不会使用AL中的结果.如果这些是您的调试工作,则应该在此论坛上之前将其删除.现在,这对于任何阅读您的程序的人来说都是很困惑的.

Your program contains lots of these and you don't use the result from AL. If these are your debugging efforts, you should have removed them before posting on this forum. Now this is very confusing for anyone who reads your program.

这篇关于我的程序集“测验乘"代码不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆