Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- QUESTION ONE
- MOV AL, 5A #This is hex for 'Z'
- #Move this value to the A Register
- MOV BL, D3 #It says VDU starts at D3 in the Q
- LOOP: #Begin LOOP
- MOV [BL], AL #Move the A Reg value into memory (B Register tells us where in mem)
- DEC AL #Decrement A Reg as its reverse order
- #A now has hex value for 'Y'
- INC BL #Increment B Reg as next character must be displayed on next VDU mem addr
- #B now has hex value D4
- CMP AL, 40 #This is hex for character BEFORE 'A'
- #See if A register is at charcter before alphabet
- JNZ LOOP #If flag is not set go back to start of loop
- #i.e A register is still alphabetical charcater
- JMP END #Otherwise we'll execute this line that jumps to end label
- END:
- END #End label calls end
- QUESTION TWO
- #Similar to one but must check if VDU is full
- #FF is 255 in decimal. 255 - 25 (26 letters in the alphabet)
- #This will give us the last possible memory adress we should use
- #255 - 25 = 230
- #230 in hex is E6
- MOV AL, 5A
- MOV BL, D3
- LOOP:
- CMP BL, E7 #Is BL in our unacceptable range? (E6 + 1)
- #S flag will be set if in acceptable range (less than or equal)
- JNS CHANGEVAL #If S flag not set, fix BL
- MOV [BL], AL
- DEC AL
- INC BL
- CMP AL, 40
- JNZ LOOP
- JMP END
- CHANGEVAL:
- MOV BL, E6 #Put BL in acceptable range
- JMP LOOP #Go back to loop
- END:
- END
- QUESTION THREE
- MOV AL, 04
- ADD AL, 30 #30 is the ascii hex code for the character '0'
- #We are using a numeric four and we need to convert it to ascii 4
- MOV BL, 03
- ADD BL, 30 #30 is the ascii hex code for the character '0'
- #We are using a numeric four and we need to convert it to ascii 3
- ADD AL, BL #Result is 7 which is less than 9
- MOV [C0], AL
- #Algorithm explanation:
- # By getting the number modulus 10 (i.e., 0a hex) the units portion of the number can be determined.
- # This can be written to the
- # appropriate place in the VDU after adding 30hex to determine
- # its corresponding character value.
- # By dividing the number by 10 (i.e., 0a hex) the 10s portion of the number can be determined. This can be written to the
- # appropriate place in the VDU after adding 30hex to determine its corresponding character value.
- #Write:
- #push al ; place the number on the stack for save keeping since the al value will change
- #mod al, 0a ; determine the units portion of the number
- #add al, 30 ; convert to numeric character
- #mov [c1], al; place in appropriate place in VDU
- #pop al ; retrieve original number from stack
- #div al, 0a ; determine the 10s portion of the number
- #add al, 30 ; convert ot numeric character11
- #mov [c0], al ; place in appropriate place on the stack
- #end
- QUESTION FOUR
- MOV AL, 0C #12
- MOV BL, 03 #3
- MUL AL, BL
- MOV CL, AL
- PUSH CL
- MOV AL, 08
- MOV BL, 06
- MUL AL, BL
- MOV DL, AL
- DIV CL, 04
- ADD CL, DL
- POP DL
- SUB CL, DL
- PUSH CL
- MOD CL, 0a
- ADD CL, 30
- MOV [c1], a
- POP CL
- DIV CL, 0a
- ADD CL, 30
- MOV [c0], CL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement