How to loop in assembly language

后端 未结 3 937
遥遥无期
遥遥无期 2021-02-11 08:39

How would I calculate the first 12 values in the Fibonacci number sequence and be able to place it in EAX reg. and display calling DumpRegs? Using Indirect addressing I know I n

3条回答
  •  独厮守ぢ
    2021-02-11 09:26

    .model small
    .stack 100h
    .data
       msg db 'Enter height of the square form 1-9: $'
       hash db '#$'
       height db 1
       length db 0
       ctr dw 0
       msgagain db 13,10,'Do you want to repeat the program? $'
       msgend db 13,10,'Program Terminated! Press any key to exit..$'
    .code
       mov ax, @data
       mov ds, ax
    REPEAT:   
       mov ax, 03
       int 10h
    
       mov ah, 09
       lea dx, msg
       int 21h
    
       mov ah, 01
       int 21h
    
       cmp al, '1'
       jl REPEAT
       cmp al, '9'
       jg REPEAT
    
       sub al, 48
       mov length, al
       mov bl, 1
       mul bl
    
       mov height, 1  
       mov di, 1 
       mov ctr, ax
    
       mov cx, ax
       nextline:
          dec length
    
          mov ah, 02
          mov bh, 00
          mov dl, length
          mov dh, height
          int 10h
    
          mov cx, di
          hashtags:
             mov ah, 09
             lea dx, hash
             int 21h
          loop hashtags      
    
          inc di
          inc height
          mov cx, ctr
          dec ctr
       loop nextline
    
       mov ah, 09
       lea dx, msgagain
       int 21h
    
       mov ah, 01
       int 21h
    
       cmp al, 'Y'
       je REPEAT
       cmp al, 'y'
       je REPEAT   
    
       mov ah, 09
       lea dx, msgend
       int 21h
    
       mov ah, 01
       int 21h
    
       mov ah, 4ch
       int 21h
    
    END
    

提交回复
热议问题