subject... assembly language,, If you know Assembly language,,,x86,,,,,,,,asm ,,
ID: 3845625 • Letter: S
Question
subject... assembly language,,If you know Assembly language,,,x86,,,,,,,,asm ,,, then answer please,,,,
I have a question and i have an answer,,, but ineed to modify my answer,,,,
the question is:
Implement a simple 4 functios calculator for 16 or more digit ,,,,i mean for unlimited digit,,,
The user will chose between the operation type +,-,* or /
The result will be displayed.
Work with 32 bits variables and register
i have a sample answer,,,, please send me a new copyable code with output,,,,use x86,,, asm,,,,, use 32 bits variables and register,,,
Sample.
name "calcBebo"
PUTC MACRO char PUSH AX MOV AL, char MOV AH, 0Eh INT 10h POP AX ENDM ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
org 100h
jmp start
; define variables:
msg0 db "note: calculator works with integer values only.",0Dh,0Ah,'$' msg1 db 0Dh,0Ah, 0Dh,0Ah, 'enter first number: $' msg2 db "enter the operator: + - * / : $" msg3 db "enter second number: $" msg4 db 0dh,0ah , 'the approximate result of my calculations is : $' msg5 db 0dh,0ah ,'thank you for using the calculator! press any key... ', 0Dh,0Ah, '$' err1 db "wrong operator!", 0Dh,0Ah , '$' smth db " and something.... $"
; operator can be: '+','-','*','/' or 'q' to exit in the middle. opr db '?'
; first and second number: num1 dw ? num2 dw ?
start: mov dx, offset msg0 mov ah, 9 int 21h
lea dx, msg1 mov ah, 09h ; output string at ds:dx int 21h
call scan_num
; store first number: mov num1, cx
; new line: putc 0Dh putc 0Ah
lea dx, msg2 mov ah, 09h ; output string at ds:dx int 21h
; get operator: mov ah, 1 ; single char input to AL. int 21h mov opr, al
putc 0Dh putc 0Ah
cmp opr, 'q' ; q - exit in the middle. je exit
cmp opr, '*' jb wrong_opr cmp opr, '/' ja wrong_opr
lea dx, msg3 mov ah, 09h int 21h
call scan_num
mov num2, cx
lea dx, msg4 mov ah, 09h ; output string at ds:dx int 21h
cmp opr, '+' je do_plus
cmp opr, '-' je do_minus
cmp opr, '*' je do_mult
cmp opr, '/' je do_div
wrong_opr: lea dx, err1 mov ah, 09h ; output string at ds:dx int 21h
exit:
lea dx, msg5 mov ah, 09h int 21h
mov ah, 0 int 16h
ret ; return back to os. do_plus:
mov ax, num1 add ax, num2 call print_num ; print ax value.
jmp exit
do_minus:
mov ax, num1 sub ax, num2 call print_num ; print ax value.
Please. Send me a new code with output. subject... assembly language,,
If you know Assembly language,,,x86,,,,,,,,asm ,,, then answer please,,,,
I have a question and i have an answer,,, but ineed to modify my answer,,,,
the question is:
Implement a simple 4 functios calculator for 16 or more digit ,,,,i mean for unlimited digit,,,
The user will chose between the operation type +,-,* or /
The result will be displayed.
Work with 32 bits variables and register
i have a sample answer,,,, please send me a new copyable code with output,,,,use x86,,, asm,,,,, use 32 bits variables and register,,,
Sample.
name "calcBebo"
PUTC MACRO char PUSH AX MOV AL, char MOV AH, 0Eh INT 10h POP AX ENDM ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
org 100h
jmp start
; define variables:
msg0 db "note: calculator works with integer values only.",0Dh,0Ah,'$' msg1 db 0Dh,0Ah, 0Dh,0Ah, 'enter first number: $' msg2 db "enter the operator: + - * / : $" msg3 db "enter second number: $" msg4 db 0dh,0ah , 'the approximate result of my calculations is : $' msg5 db 0dh,0ah ,'thank you for using the calculator! press any key... ', 0Dh,0Ah, '$' err1 db "wrong operator!", 0Dh,0Ah , '$' smth db " and something.... $"
; operator can be: '+','-','*','/' or 'q' to exit in the middle. opr db '?'
; first and second number: num1 dw ? num2 dw ?
start: mov dx, offset msg0 mov ah, 9 int 21h
lea dx, msg1 mov ah, 09h ; output string at ds:dx int 21h
call scan_num
; store first number: mov num1, cx
; new line: putc 0Dh putc 0Ah
lea dx, msg2 mov ah, 09h ; output string at ds:dx int 21h
; get operator: mov ah, 1 ; single char input to AL. int 21h mov opr, al
putc 0Dh putc 0Ah
cmp opr, 'q' ; q - exit in the middle. je exit
cmp opr, '*' jb wrong_opr cmp opr, '/' ja wrong_opr
lea dx, msg3 mov ah, 09h int 21h
call scan_num
mov num2, cx
lea dx, msg4 mov ah, 09h ; output string at ds:dx int 21h
cmp opr, '+' je do_plus
cmp opr, '-' je do_minus
cmp opr, '*' je do_mult
cmp opr, '/' je do_div
wrong_opr: lea dx, err1 mov ah, 09h ; output string at ds:dx int 21h
exit:
lea dx, msg5 mov ah, 09h int 21h
mov ah, 0 int 16h
ret ; return back to os. do_plus:
mov ax, num1 add ax, num2 call print_num ; print ax value.
jmp exit
do_minus:
mov ax, num1 sub ax, num2 call print_num ; print ax value.
Please. Send me a new code with output. subject... assembly language,,
If you know Assembly language,,,x86,,,,,,,,asm ,,, then answer please,,,,
I have a question and i have an answer,,, but ineed to modify my answer,,,,
the question is:
Implement a simple 4 functios calculator for 16 or more digit ,,,,i mean for unlimited digit,,,
The user will chose between the operation type +,-,* or /
The result will be displayed.
Work with 32 bits variables and register
i have a sample answer,,,, please send me a new copyable code with output,,,,use x86,,, asm,,,,, use 32 bits variables and register,,,
Sample.
name "calcBebo"
PUTC MACRO char PUSH AX MOV AL, char MOV AH, 0Eh INT 10h POP AX ENDM ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
org 100h
jmp start
; define variables:
msg0 db "note: calculator works with integer values only.",0Dh,0Ah,'$' msg1 db 0Dh,0Ah, 0Dh,0Ah, 'enter first number: $' msg2 db "enter the operator: + - * / : $" msg3 db "enter second number: $" msg4 db 0dh,0ah , 'the approximate result of my calculations is : $' msg5 db 0dh,0ah ,'thank you for using the calculator! press any key... ', 0Dh,0Ah, '$' err1 db "wrong operator!", 0Dh,0Ah , '$' smth db " and something.... $"
; operator can be: '+','-','*','/' or 'q' to exit in the middle. opr db '?'
; first and second number: num1 dw ? num2 dw ?
start: mov dx, offset msg0 mov ah, 9 int 21h
lea dx, msg1 mov ah, 09h ; output string at ds:dx int 21h
call scan_num
; store first number: mov num1, cx
; new line: putc 0Dh putc 0Ah
lea dx, msg2 mov ah, 09h ; output string at ds:dx int 21h
; get operator: mov ah, 1 ; single char input to AL. int 21h mov opr, al
putc 0Dh putc 0Ah
cmp opr, 'q' ; q - exit in the middle. je exit
cmp opr, '*' jb wrong_opr cmp opr, '/' ja wrong_opr
lea dx, msg3 mov ah, 09h int 21h
call scan_num
mov num2, cx
lea dx, msg4 mov ah, 09h ; output string at ds:dx int 21h
cmp opr, '+' je do_plus
cmp opr, '-' je do_minus
cmp opr, '*' je do_mult
cmp opr, '/' je do_div
wrong_opr: lea dx, err1 mov ah, 09h ; output string at ds:dx int 21h
exit:
lea dx, msg5 mov ah, 09h int 21h
mov ah, 0 int 16h
ret ; return back to os. do_plus:
mov ax, num1 add ax, num2 call print_num ; print ax value.
jmp exit
do_minus:
mov ax, num1 sub ax, num2 call print_num ; print ax value. name "calcBebo"
PUTC MACRO char PUSH AX MOV AL, char MOV AH, 0Eh INT 10h POP AX ENDM ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
org 100h
jmp start
; define variables:
msg0 db "note: calculator works with integer values only.",0Dh,0Ah,'$' msg1 db 0Dh,0Ah, 0Dh,0Ah, 'enter first number: $' msg2 db "enter the operator: + - * / : $" msg3 db "enter second number: $" msg4 db 0dh,0ah , 'the approximate result of my calculations is : $' msg5 db 0dh,0ah ,'thank you for using the calculator! press any key... ', 0Dh,0Ah, '$' err1 db "wrong operator!", 0Dh,0Ah , '$' smth db " and something.... $"
; operator can be: '+','-','*','/' or 'q' to exit in the middle. opr db '?'
; first and second number: num1 dw ? num2 dw ?
start: mov dx, offset msg0 mov ah, 9 int 21h
lea dx, msg1 mov ah, 09h ; output string at ds:dx int 21h
call scan_num
; store first number: mov num1, cx
; new line: putc 0Dh putc 0Ah
lea dx, msg2 mov ah, 09h ; output string at ds:dx int 21h
; get operator: mov ah, 1 ; single char input to AL. int 21h mov opr, al
putc 0Dh putc 0Ah
cmp opr, 'q' ; q - exit in the middle. je exit
cmp opr, '*' jb wrong_opr cmp opr, '/' ja wrong_opr
lea dx, msg3 mov ah, 09h int 21h
call scan_num
mov num2, cx
lea dx, msg4 mov ah, 09h ; output string at ds:dx int 21h
cmp opr, '+' je do_plus
cmp opr, '-' je do_minus
cmp opr, '*' je do_mult
cmp opr, '/' je do_div
wrong_opr: lea dx, err1 mov ah, 09h ; output string at ds:dx int 21h
exit:
lea dx, msg5 mov ah, 09h int 21h
mov ah, 0 int 16h
ret ; return back to os. do_plus:
mov ax, num1 add ax, num2 call print_num ; print ax value.
jmp exit
do_minus:
mov ax, num1 sub ax, num2 call print_num ; print ax value.
Please. Send me a new code with output.
Explanation / Answer
name "calcBebo"
PUTC MACRO char
PUSH AX
MOV AL, char
MOV AH, 0Eh
INT 10h
POP AX
ENDM
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
org 100h
jmp start
; define variables:
msg0 db "note: calculator works with integer values only.",0Dh,0Ah,'$'
msg1 db 0Dh,0Ah, 0Dh,0Ah, 'enter first number: $'
msg2 db "enter the operator: + - * / : $"
msg3 db "enter second number: $"
msg4 db 0dh,0ah , 'the approximate result of my calculations is : $'
msg5 db 0dh,0ah ,'thank you for using the calculator! press any key... ', 0Dh,0Ah, '$'
err1 db "wrong operator!", 0Dh,0Ah , '$'
smth db " and something.... $"
; operator can be: '+','-','*','/' or 'q' to exit in the middle.
opr db '?'
; first and second number:
num1 dw ?
num2 dw ?
start:
mov dx, offset msg0
mov ah, 9
int 21h
lea dx, msg1
mov ah, 09h ; output string at ds:dx
int 21h
call scan_num
; store first number:
mov num1, cx
; new line:
putc 0Dh
putc 0Ah
lea dx, msg2
mov ah, 09h ; output string at ds:dx
int 21h
; get operator:
mov ah, 1 ; single char input to AL.
int 21h
mov opr, al
putc 0Dh
putc 0Ah
cmp opr, 'q' ; q - exit in the middle.
je exit
cmp opr, '*'
jb wrong_opr
cmp opr, '/'
ja wrong_opr
lea dx, msg3
mov ah, 09h
int 21h
call scan_num
mov num2, cx
lea dx, msg4
mov ah, 09h ; output string at ds:dx
int 21h
cmp opr, '+'
je do_plus
cmp opr, '-'
je do_minus
cmp opr, '*'
je do_mult
cmp opr, '/'
je do_div
wrong_opr:
lea dx, err1
mov ah, 09h ; output string at ds:dx
int 21h
exit:
lea dx, msg5
mov ah, 09h
int 21h
mov ah, 0
int 16h
ret ; return back to os.
do_plus:
mov ax, num1
add ax, num2
call print_num ; print ax value.
jmp exit
do_minus:
mov ax, num1
sub ax, num2
call print_num ; print ax value.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.