Professional Documents
Culture Documents
inc
ExitProcess proto,dwExitCode:dword
.data
bill DWORD 0
string BYTE ' WELCOME TO STATIONERY SHOP OF FAHEEM AHMAD and
MUHAMMAD SHABAN',0dh,0ah,0
string1 BYTE ' Menu:',0dh,0ah
BYTE ' Enter 1 - Registers ',0dh,0ah
BYTE ' Enter 2 - Pencils ',0dh,0ah
BYTE ' Enter 3 - Geometry ',0dh,0ah
BYTE ' Enter 4 - Colours ',0dh,0ah
BYTE ' Enter 5 - Papers ',0dh,0ah
BYTE ' Enter 6 - Exit ',0dh,0ah,0
.code
main proc
call Crlf
call Crlf
mov edx,OFFSET string
call WriteString
L1:
mov edx,OFFSET string1
call WriteString
mov edx,OFFSET spaces
call WriteString
call ReadDec
call Checkerror ; check whether user enter the number in given range
cmp eax,1 ; comparison b/w what user enter with each item of list
je L2
cmp eax,2
je L3
cmp eax,3
je L4
cmp eax,4
je L5
cmp eax,5
je L6
jmp last
Oriental PROC
; print the oriental menu and add prices into bill according to which item of what
quantity user selects
; and call another func(NaanRoti) according to requirment
; Receives: string4, buffer4
; Returns: return updated bill
;-----------------------------------------------
mov edx,OFFSET string4
call WriteString
mov edx,OFFSET spaces
call WriteString
call ReadDec
call Crlf
call Checkerror3
cmp eax,1
je L1
cmp eax,2
je L2
cmp eax,3
je L3
cmp eax,4
je L4
cmp eax,5
jmp last
L1: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer4] ; buffer4 is array contains price of oriental foods
L11: ; quantity times a loop L11 runs
add bill,ebx ; add price into bill
loop L11
call naanroti
jmp last
L2: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer4 + 4]
L22:
add bill,ebx
loop L22
jmp last
L3: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer4 + 8]
L33:
add bill,ebx
loop L33
call NaanRoti
jmp last
L4: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer4 + 12]
L44:
add bill,ebx
loop L44
last:
ret
Oriental ENDP
NaanRoti PROC
; print the menu(naan,roti) and add prices into bill according to which item of
what quantity user selects
; Receives: string3, buffer3
; Returns: return updated bill
;-----------------------------------------------
Registers PROC
; print the Registers menu and add prices into bill according to which item of what
quantity user selects
; Receives: string5, buffer5
; Returns: return updated bill
;-----------------------------------------------
mov edx,OFFSET string5
call WriteString
mov edx,OFFSET spaces
call WriteString
call ReadDec
call Crlf
call Checkerror3 ; check for error
cmp eax,1
je L1
cmp eax,2
je L2
cmp eax,3
je L3
cmp eax,4
je L4
cmp eax,5
jmp last
ret
Registers ENDP
Pencils PROC
; print the Pencils menu and add prices into bill according to which item of what
quantity user selects
; Receives: string6, buffer6
; Returns: return updated bill
;-----------------------------------------------
mov edx,OFFSET string6
call WriteString
mov edx,OFFSET spaces
call WriteString
call ReadDec
call Crlf
call Checkerror3
cmp eax,1
je L1
cmp eax,2
je L2
cmp eax,3
je L3
cmp eax,4
je L4
cmp eax,5
jmp last
L1: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer6]
L11:
add bill,ebx
loop L11
jmp last
L2: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer6 + 4]
L22:
add bill,ebx
loop L22
jmp last
L3: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer6 + 8]
L33:
add bill,ebx
loop L33
jmp last
L4: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer6 + 12]
L44:
add bill,ebx
loop L44
last:
ret
Pencils ENDP
Geometry PROC
; print the Geometry menu and add prices into bill according to which item of what
quantity user selects
; Receives: string7, buffer7
; Returns: return updated bill
;-----------------------------------------------
mov edx,OFFSET string7
call WriteString
mov edx,OFFSET spaces
call WriteString
call ReadDec
call Crlf
call Checkerror3
cmp eax,1
je L1
cmp eax,2
je L2
cmp eax,3
je L3
cmp eax,4
je L4
cmp eax,5
jmp last
L1: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer7]
L11:
add bill,ebx
loop L11
jmp last
L2: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer7 + 4]
L22:
add bill,ebx
loop L22
jmp last
L3: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer7 + 8]
L33:
add bill,ebx
loop L33
jmp last
L4: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer7 + 12]
L44:
add bill,ebx
loop L44
last:
ret
Geometry ENDP
Colour PROC
; print the Colour menu and add prices into bill according to which item of what
quantity user selects
; Receives: string8, buffer8
; Returns: return updated bill
;-----------------------------------------------
mov edx,OFFSET string8
call WriteString
mov edx,OFFSET spaces
call WriteString
call ReadDec
call Crlf
call Checkerror3
cmp eax,1
je L1
cmp eax,2
je L2
cmp eax,3
je L3
cmp eax,4
je L4
cmp eax,5
jmp last
L1: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer8]
L11:
add bill,ebx
loop L11
jmp last
L2: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer8 + 4]
L22:
add bill,ebx
loop L22
jmp last
L3: mov edx,OFFSET Quantity
call WriteString
call ReadDec
mov ecx,eax
call Crlf
mov ebx,[buffer8 + 8]
L33:
add bill,ebx
loop L33
jmp last
L4: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer8 + 12]
L44:
add bill,ebx
loop L44
last:
ret
Colour ENDP
Checkerror PROC
L2:
mov edx, OFFSET errorMsg
call WriteString
call ReadDec
jmp L1
last:
ret
Checkerror ENDP
Checkerror1 PROC
L2:
mov edx, OFFSET errorMsg
call WriteString
call ReadDec
jmp L1
last:
ret
Checkerror1 ENDP
Checkerror2 PROC
L2:
mov edx, OFFSET errorMsg
call WriteString
call ReadDec
jmp L1
last:
ret
Checkerror2 ENDP
Checkerror3 PROC
; check whether eax contains value in range 1-5
; Receives: eax
; Returns: eax contains value in range 1-6 according to user's choice
;-----------------------------------------------
L1:
cmp eax,1
jl L2
cmp eax,5
jg L2
jmp last
L2:
mov edx, OFFSET errorMsg
call WriteString
call ReadDec
jmp L1
last:
ret
Checkerror3 ENDP
end main