Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Assembly nasm中实现闰年时的逻辑错误_Assembly_X86_Nasm - Fatal编程技术网

Assembly nasm中实现闰年时的逻辑错误

Assembly nasm中实现闰年时的逻辑错误,assembly,x86,nasm,Assembly,X86,Nasm,我在上面附上了我的代码。因为,我给出的每一个输入,比如说1993年,输出都是闰年 谢谢您忘了将year加载到ecx中,您忘了将其从文本转换成数字。您也没有使用调试器。PS:作为对他人的礼貌,请注意使用正确的格式。如果你看到它坏掉了,通过编辑来修复它。谢谢你的回复。我已将年份加载到eac中,但在输出中未发现任何变化。我不明白如何将文本转换成数字。你想让我把它放在哪里,因为我已经看到了一些程序,它们在不将文本更改为文本的情况下工作number@Jester section .data msg d

我在上面附上了我的代码。因为,我给出的每一个输入,比如说1993年,输出都是闰年


谢谢

您忘了将
year
加载到
ecx
中,您忘了将其从文本转换成数字。您也没有使用调试器。PS:作为对他人的礼貌,请注意使用正确的格式。如果你看到它坏掉了,通过编辑来修复它。谢谢你的回复。我已将年份加载到eac中,但在输出中未发现任何变化。我不明白如何将文本转换成数字。你想让我把它放在哪里,因为我已经看到了一些程序,它们在不将文本更改为文本的情况下工作number@Jester
section .data

 msg db 'Enter a year ' , 10

    msglen equ $-msg

    leapYear db ' is a leap year.', 10
    leapYearLenght equ $-leapYear
    noLeapYear db ' is not a leap year.', 10 
    noLeapYearLenght equ $-noLeapYear
section .bss

    year resd 1

section .text

    global main

main:

    mov eax,4
    mov ebx, 0
    mov ecx, msg
    mov edx, msglen
    int 0x80

    mov eax, 3 
    mov ebx, 0  
    mov ecx, year   
    mov edx, 4  
    int 0x80    

    mov eax, 4  
    mov ebx, 1  
    int 0x80    

    mov edx, 0  
    mov eax, ecx    
    mov ebx, 4h   
    div ebx         ; step 3
    mov eax, edx
    cmp eax, 0  
    jne NoLeapYear
    je L1

L1: 
    mov edx, 0  

    mov eax, ecx    

    mov ebx, 64h    

    div ebx     ; step 2

    mov eax, edx

    cmp eax, 0   

    je L2

    jne LeapYear

L2: 

    mov edx, 0 

    mov eax, ecx    

    mov ebx, 190h

    div ebx     ;step 1

    mov eax, edx

    cmp eax, 0  

    je LeapYear     

    jne NoLeapYear

LeapYear:               ; step4

    mov eax, 4      

    mov ebx, 1     

    mov ecx, leapYear   

    mov edx, leapYearLenght 

    int 0x80      

    jmp Exit        

NoLeapYear:         ; step 5

    mov eax, 4          

    mov ebx, 1          

    mov ecx, noLeapYear     

    mov edx, noLeapYearLenght   

    int 0x80            

    jmp Exit            
Exit:

    mov eax, 1  

    mov ebx, 0  

    int 0x80