Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; multi-segment executable file template.
  2. ;------------------------;
  3. data segment
  4. ex db '!$'
  5. ; login msgs ;
  6. PASSWORD db 3,1,5,9
  7. WORKERID db 11 dup('$')
  8. counter db 0
  9. loginmsg1 db "Please enter the password: $"
  10. loginfailmsg db "INCORRECT PASSWORD! TERMINATING!$"
  11. loginsuccessmsg db "LOGIN SUCCESSFUL!$"
  12.  
  13. workeridmsg1 db "Enter worker ID: $"
  14. welcomeworker db "Welcome worker #$"
  15. ;------------------------;
  16. ; menu msgs ;
  17. chooseoption db "Choose an option from the following menu: $"
  18. makeOrder1 db "0 - Make an order.$"
  19. showTotal1 db "1 - Show total earned & pizzas sold.$"
  20. exitmsg db "9 - Exit. (Close down the store.)$"
  21. exitmsg1 db "Closing down store systems... GOODBYE!$"
  22. incorrect db "Incorrect Input, please choose again!$"
  23. ;------------------------;
  24. ; makeOrder ;
  25. confirmation db "Press 1 to confirm making an order: $"
  26. orderName db 11 dup('$')
  27. enterName db "Enter the buyers name: $"
  28. orderName1 db "Order has been successfully made by $"
  29. orderName2 db " for $"
  30. orderName3 db " pizzas.$"
  31. quantityMsg db "How many pizzas would you like?: $"
  32. two db 2
  33. currentOrder dw 0
  34. temp db 0
  35. ten db 10
  36. invalidQuantity1 db "Invalid quantity! Please rechoose!$"
  37. ;------------------------;
  38. ; showTotal ;
  39. showTotalmsg db "You have earned $"
  40. showTotalmsg0 db " shekels for selling $"
  41. showTotalmsg1 db " pizzas.$"
  42. noPizzas db "No pizzas sold...$"
  43. pizzasSold dw 0
  44. totalEarned dw 0
  45. totalEarned1 dw 0,0,0,0
  46. cheat db 0
  47.  
  48.  
  49. newline db 0dh,0ah,'$'
  50.  
  51.  
  52. ends
  53. ;------------------------;
  54. stack segment
  55.  
  56. dw   128  dup(0)
  57.  
  58. ends
  59. ;------------------------;
  60. code segment
  61.  
  62. mov ax, data
  63. mov ds, ax
  64.  
  65. lea dx,loginmsg1
  66. call printst
  67. mov ch,0
  68. mov cl,4
  69. lea bx,PASSWORD
  70. call login
  71.  
  72. mov ax, 4ch
  73. int 21h
  74.  
  75. ; * END OF MAIN * ;
  76. ;------------------------;
  77.  
  78. printst:
  79. mov ah,09h
  80. int 21h
  81. ret
  82.  
  83. enter:
  84. lea dx,newline
  85. call printst
  86. ret
  87.  
  88. makeNum:
  89. call getch
  90. sub al,'0'
  91. ret
  92.  
  93. getch:
  94. mov ah, 01h
  95. int 21h
  96. ret
  97.  
  98. printch:
  99. mov ah,02h
  100. int 21h
  101. ret
  102.  
  103. ;-------------------------;
  104.  
  105. ;START OF ACTUAL FUNCTIONS;
  106.  
  107. login:
  108. call makeNum
  109. cmp al,[bx]
  110. jnz loginFail
  111. inc bx
  112. loop login
  113.  
  114.  
  115. loginSuccess:
  116. call enter
  117. lea dx,loginsuccessmsg
  118. call printst
  119. lea bx,WORKERID
  120. call enter
  121. lea dx,workeridmsg1
  122. call printst
  123. mov cl,10
  124. jmp getWorkerID
  125.  
  126. loginFail:
  127. call enter
  128. lea dx, loginfailmsg
  129. call printst
  130. ret
  131.  
  132. getWorkerID:
  133. call getch
  134. cmp al,newline
  135. je printWorkerID1
  136. mov [bx],al
  137. inc bx
  138. inc counter
  139. loop getWorkerID
  140.  
  141. printWorkerID1:
  142. call enter
  143. lea dx,welcomeworker
  144. lea bx,WORKERID
  145. call printst
  146. mov ch,0
  147. mov cl,counter
  148.  
  149. printWorkerID2:
  150. cmp [bx],'$'
  151. je continue
  152. mov dl,[bx]
  153. call printch
  154. inc bx
  155. loop printWorkerID2
  156.  
  157. continue:
  158. lea dx,ex
  159. call printst
  160. call enter
  161.  
  162. menu:
  163. call enter
  164. call enter
  165. ; Prints Menu msgs ;
  166.  
  167. lea dx,makeOrder1
  168. call printst
  169. call enter
  170. lea dx,showTotal1
  171. call printst
  172. call enter
  173. lea dx,exitmsg
  174. call printst
  175. call enter
  176.  
  177. ; Get option ;
  178.  
  179. lea dx,chooseoption
  180. call printst
  181. call makeNum
  182.  
  183. ; Check option;
  184.  
  185. cmp al,0
  186. je makeOrder
  187.  
  188. cmp al,1
  189. je showTotal
  190.  
  191. cmp al,9
  192. je exit
  193.  
  194. call enter
  195. lea dx,incorrect
  196. call printst
  197.  
  198. jmp menu
  199. ; In case choosing to exit ;
  200.  
  201. exit:
  202. call enter
  203. lea dx,exitmsg1
  204. call printst
  205. ret
  206.  
  207. ;------------------------------------------------;
  208.  
  209. makeOrder:
  210.  
  211. ; Asking for confirmation of order making ;
  212.  
  213. call enter
  214. lea dx,confirmation
  215. call printst
  216. call makeNum
  217. cmp al, 1
  218. jne menu
  219. mov counter,0
  220. jmp requestQuantity
  221.  
  222. ; Asking for quantity ;
  223.  
  224. invalidQuantity0:
  225. call enter
  226. lea dx,invalidQuantity1
  227. call printst
  228. call enter
  229. jmp requestQuantity
  230.  
  231.  
  232. requestQuantity:
  233. call enter          ; Print quantity msg
  234. lea dx,quantityMsg
  235. call printst
  236.  
  237. getQuantity0:
  238. call getch          ; Get first num
  239. sub al,'0'
  240. mov ah,0
  241. cmp al,0
  242. jle invalidQuantity0
  243. cmp al,9
  244. jg invalidQuantity0
  245. mov currentOrder,ax
  246.  
  247. GetQuantity1:
  248. call getch          ; Try to get another num, if not enter con
  249. cmp al,newline
  250. je endPrice
  251. sub al,'0'
  252. cmp al,0
  253. jl invalidQuantity0
  254. cmp al,9
  255. jg invalidQuantity0
  256.  
  257. ; Getting another number, multiplying by 10
  258. mov temp,al
  259. mov ax,currentOrder
  260. mul ten
  261. mov currentOrder,ax
  262. mov al,temp
  263. add currentOrder,ax
  264.  
  265. endPrice:
  266. mov ax,currentOrder
  267. add pizzasSold,ax
  268. mul two
  269. add totalEarned,ax
  270.  
  271. getName0:
  272. call enter
  273. lea dx,enterName
  274. call printst
  275. mov al,0
  276. lea bx,orderName
  277. mov cx,10
  278.  
  279. getName1:
  280. call getch
  281. cmp al,newline
  282. je conOrder
  283.  
  284. getName2:
  285. mov [bx],al
  286. inc bx
  287. loop getName1
  288.  
  289. conOrder:
  290. call enter
  291. lea dx,orderName1
  292. call printst
  293.  
  294. printName:
  295. mov cx,10
  296. lea bx,orderName
  297.  
  298. printName0:
  299. cmp [bx],'$'
  300. je endOrder
  301. mov dl,[bx]
  302. call printch
  303. inc bx
  304. loop printName0
  305.  
  306. endOrder:
  307. lea dx,ex
  308. call printst
  309. call enter
  310. jmp menu
  311. ;------------------------------------------------;
  312. showTotal:
  313. call enter
  314. cmp pizzasSold,0
  315. je noPizzasSold
  316. lea dx,showTotalmsg
  317. call printst
  318.  
  319. mov bx,totalEarned
  320.  
  321. ; Taking care of BH (YYXX TAKING CARE OF YY)
  322.  
  323. ; Taking care of BL (YYXX TAKING CARE OF XX)
  324.  
  325. mov al,bl
  326. mov ah,0
  327. AAM
  328. add al,'0'
  329. mov cl,al
  330. cmp ah,10
  331. jge resplit
  332.  
  333. afterSplit:
  334. add ah,'0'
  335. mov dl,ah
  336. call printch
  337. mov dl,cl
  338. call printch
  339. mov ah,0
  340. mov al,0
  341. jmp moreMsgs
  342.  
  343. resplit:
  344. mov al,ah
  345. mov ah,0
  346. AAM
  347. add al,'0'
  348. mov bl,al
  349. add ah,'0'
  350. mov dl,ah
  351. call printch
  352. mov dl,bl
  353. call printch
  354. mov dl,cl
  355. call printch
  356.  
  357. moreMsgs:
  358. lea dx,showtotalmsg0
  359. call printst
  360.  
  361. printPizzaAmount:
  362. mov bx,pizzasSold
  363.  
  364. mov al,bl
  365. mov ah,0
  366. AAM
  367. add al,'0'
  368. mov cl,al
  369. cmp ah,10
  370. jge resplit1
  371.  
  372. afterSplit1:
  373. add ah,'0'
  374. mov dl,ah
  375. call printch
  376. mov dl,cl
  377. call printch
  378. mov ah,0
  379. mov al,0
  380.  
  381. jmp menuJump
  382.  
  383. resplit1:
  384. mov al,ah
  385. mov ah,0
  386. AAM
  387. add al,'0'
  388. mov bl,al
  389. add ah,'0'
  390. mov dl,ah
  391. call printch
  392. mov dl,bl
  393. call printch
  394. mov dl,cl
  395. call printch
  396.  
  397. menuJump:
  398. lea dx,showtotalmsg1
  399. call printst
  400. jmp menu
  401. ret
  402.  
  403. noPizzasSold:
  404. call enter
  405. lea dx,noPizzas
  406. call printst
  407. jmp menu
  408. ret
  409.  
  410. ends
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement