Dividing in Assembler x86

前端 未结 4 1750
余生分开走
余生分开走 2020-12-22 10:10

My college gave me a exercise:

1. Create a new document in Jasmin

2. Use the AL-Register to to add 9 to 8.

3. Subtract 2.

4条回答
  •  [愿得一人]
    2020-12-22 11:02

    This code works for only single digit numbers division.

    .model small
    .data
     msg1 db 'enter dividend:$'
     msg2 db 10,13,'enter divisor:$'
     result db 10,13,'result is:$'
     dividend db ?
     divisor db ?
    .code
    .startup
    mov ax,@data
    mov ds,ax
    mov ah,9
    lea dx,msg1
    int 21h
    mov ah,1
    int 21h
    sub al,30h
    mov dividend ,al
    mov ah,9
    lea dx,msg2
    int 21h
    mov ah,1
    int 21h
    sub al,30h
    mov divisor , al
    mov al,dividend
    mov bl,divisor
    mov ah,0
    div bl
    mov ah,9
    lea dx,result
    int 21h
    mov ah,2
    add al,30h
    mov dl,al
    int 21h
    mov ah,4ch
    int 21h
    end
    

提交回复
热议问题