Addition, Subtraction & Multiplication of two numbers submitted, until the program terminates by user. The termination process is actually maintained by 0 and 1, 0 terminates the program and 1 continues.
Limitations of the code is the initial two numbers and the resultant numbers must be between 0 to 9. "emu8086" compiler was used. This is my 5th code in assembly language I have done in my lab.
Limitations of the code is the initial two numbers and the resultant numbers must be between 0 to 9. "emu8086" compiler was used. This is my 5th code in assembly language I have done in my lab.
; Date: October 10, 2012
; Author: Md. Nabid Imteaj
; Tag: Add, Substract, Multiplication as user want
TITLE ANOTHER_DAY_IN_CLASS
.model small
.stack 100h
.code
.data
msg1 db 'ENTER Hex Value: $'
msg2 db 'Equivalent Decimal: $'
msg3 db 'INVALID :($'
msg10 db '0 to exit, 1 to continue?: $'
msg11 db 'THANK YOU :D$'
main proc
mov ax, @data
mov ds, ax
mov cx, 3
AGAIN_PAIN:
; new line
mov ah, 2
mov dl, 0dh
int 21h
mov dl, 0ah
int 21h
cmp cl, 0
je TERMINATE
dec cx
; message print
lea dx, msg1
mov ah, 9
int 21h
; enter character
mov ah, 1
int 21h
mov bl, al
; new line
mov ah, 2
mov dl, 0dh
int 21h
mov dl, 0ah
int 21h
; cmpareing
cmp bl, 'A'
je print_A
cmp bl, 'B'
je print_B
cmp bl, 'C'
je print_C
cmp bl, 'D'
je print_D
cmp bl, 'E'
je print_E
cmp bl, 'F'
je print_F
cmp bl, 30
jge over_0
over_0:
cmp bl, 39
jle less_9
jmp print_invalid
less_9:
mov ah, 2
mov dl, bl
int 21h
jmp EXIT_
print_A:
lea dx, msg2
mov ah, 9
int 21h
mov ah, 2
mov dl, '1'
int 21h
mov ah, 2
mov dl, '0'
int 21h
jmp EXIT_
print_B:
lea dx, msg2
mov ah, 9
int 21h
mov ah, 2
mov dl, '1'
int 21h
mov ah, 2
mov dl, '1'
int 21h
jmp EXIT_
print_C:
lea dx, msg2
mov ah, 9
int 21h
mov ah, 2
mov dl, '1'
int 21h
mov ah, 2
mov dl, '2'
int 21h
jmp EXIT_
print_D:
lea dx, msg2
mov ah, 9
int 21h
mov ah, 2
mov dl, '1'
int 21h
mov ah, 2
mov dl, '3'
int 21h
jmp EXIT_
print_E:
lea dx, msg2
mov ah, 9
int 21h
mov ah, 2
mov dl, '1'
int 21h
mov ah, 2
mov dl, '4'
int 21h
jmp EXIT_
print_F:
lea dx, msg2
mov ah, 9
int 21h
mov ah, 2
mov dl, '1'
int 21h
mov ah, 2
mov dl, '5'
int 21h
jmp EXIT_
print_invalid:
lea dx, msg3
mov ah, 9
int 21h
jmp EXIT_
EXIT_:
; new line
mov ah, 2
mov dl, 0dh
int 21h
mov dl, 0ah
int 21h
; operation message
lea dx, msg10
mov ah, 9
int 21h
; gets character
mov bl, '1'
mov ah, 1
int 21h
cmp al, bl
je AGAIN_PAIN
; new line
mov ah, 2
mov dl, 0dh
int 21h
mov dl, 0ah
int 21h
TERMINATE:
; operation message
lea dx, msg11
mov ah, 9
int 21h
mov ah, 4ch
int 21h
main endp
end main
No comments:
Post a Comment