| | |
calculator needed...
Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Mar 2007
Posts: 3
Reputation:
Solved Threads: 0
•
•
•
•
hello...
I'm looking for a calculator program written in assembler... it needs to do all the basic functions of a calculator eg add, subract, multiply, devide...
if anyone can point me in the right direction of where to find one it would be greatly apprecitaed...!
thanx...
neil...
You can copy simple calc from here..
#make_com#
include 'emu8086.inc'
ORG 100h
JMP start
msg1 DB 'Enter operation number[1~4]: $'
msg2 DB 'Enter 1st No: $'
msg3 DB 'Enter 2nd No: $'
msg4 DB 'The result is: $'
msg5 db 'Thank you for using My Calculator Program ', 13, 10, '$'
calcOP DB '?', 0
num1 DW ?
num2 DW ?
opr DW ?
start:
PRINTN 'Welcome to My Calculator Program'
PRINTN '[Loading...]'
PRINTN ''
PRINTN ''
PRINTN 'Please select type of arithmetic operation:'
PRINTN '1. Addition'
PRINTN '2. Subtraction'
PRINTN '3. Multiplication'
PRINTN '4. Division'
LEA DX, msg1 ; output of a string at DS
XMOV AH, 09h
INT 21h
MOV DX, 2
LEA DI, calcOP
CALL GET_STRING
PUTC 13
PUTC 10
LEA DX, msg2 ; first number
MOV AH, 09h
INT 21h
CALL scan_num
MOV num1, CX
PUTC 13
PUTC 10
LEA DX, msg3 ; second number
MOV AH, 09h
INT 21h
CALL scan_num
MOV num2, CX
PUTC 13
PUTC 10
LEA DX, msg4 ; result
MOV AH, 09h
INT 21h
CMP calcOP, '1'
JE do_plus
CMP calcOP, '2'
JE do_minus
CMP calcOP, '3'
JE do_mult
CMP calcOP, '4'
JE do_div
end:
PUTC 13
PUTC 10
LEA DX, msg5
MOV AH, 09h
INT 21h
RET
do_plus:
MOV AX, num1
ADD AX, num2
CALL PRINT_NUM
JMP end
do_minus:
MOV AX, num1
SUB AX, num2
CALL PRINT_NUM
JMP end
do_mult:
MOV AX, num1
IMUL num2
CALL PRINT_NUM
JMP end
do_div:
MOV DX, 0
MOV AX, num1
IDIV num2
CALL PRINT_NUM
JMP end
DEFINE_SCAN_NUM
DEFINE_PRINT_NUM
DEFINE_PRINT_NUM_UNS
DEFINE_GET_STRING
END
![]() |
Other Threads in the Assembly Forum
- Previous Thread: HELP in MIPS
- Next Thread: msgsrv32
| Thread Tools | Search this Thread |
Tag cloud for Assembly
3d 68hc11 6811 80386 adress array asm assembler assembly boot bootloader buffer compression cursor debug directory division docs dos draw emulator endtask error exceptions file int10h integer intel interrupt interrupts language loop nohau osdevelopment print program range read remainder shape string text theory tsr x86





