Assembly (Two)
August 31, 2018
题目说明:
某学生利用暑期到快递公司打工,该公司以底薪加计件工资的形式,并以周为结算周期给实习学生发工资。具体计薪办法是:实习学生一周工作6天,每周基本工资800元,每天送快递60件为基本要求,每天多送1件增加1.5元,每天不足60件则每少1件扣1.2元。某同学某周内各天的快递量分别为102,90,57,89,48,79。编程计算该实习学生本周能领到多少工资(元)?
代码:
DATA SEGMENT NUM DW 102,90,57,89,48,79 DUO DB 15 SHAO DB 12 SALARY DW ? STRING DB 'THE SALARY SHOULD BE : $' DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA START: MOV AX,DATA MOV DS,AX MOV SALARY,8000 ; multiply ten to ensure all nums are integers. MOV CX,6 ; loop six times LEA BX,NUM ; address of num ONE: CALL DAY INC BX INC BX ; index add two LOOP ONE JMP THREE DAY: MOV AX,60 ; the standard nums of items MOV DX,[BX] CMP DX,AX ; compare with 60 JC TWO ; if the number is larger than 60 SUB DX,AX ; get the difference MOV AL,DL IMUL DUO MOV DX,SALARY ADD DX,AX MOV SALARY,DX RET TWO: SUB AX,DX ; get the difference IMUL SHAO MOV DX,SALARY SUB DX,AX MOV SALARY,DX RET THREE: LEA DX,STRING ; output the prompt message MOV AH,9 INT 21H MOV AX,SALARY XOR DX,DX MOV BX,10 DIV BX CALL SHOW ; convert to decimal number MOV AH,7 INT 21H EXIT: MOV AH,4CH INT 21H SHOW: MOV BX,10 XOR CX,CX Q0: XOR DX,DX DIV BX OR DX,0E30H PUSH DX INC CX CMP AX,0 JNZ Q0 Q1: POP AX INT 10H LOOP Q1 RET CODE ENDS END START