Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. QUESTION ONE
  2. MOV AL, 5A #This is hex for 'Z'
  3. #Move this value to the A Register
  4. MOV BL, D3 #It says VDU starts at D3 in the Q
  5.  
  6. LOOP: #Begin LOOP
  7. MOV [BL], AL #Move the A Reg value into memory (B Register tells us where in mem)
  8. DEC AL #Decrement A Reg as its reverse order
  9. #A now has hex value for 'Y'
  10. INC BL #Increment B Reg as next character must be displayed on next VDU mem addr
  11. #B now has hex value D4
  12. CMP AL, 40 #This is hex for character BEFORE 'A'
  13. #See if A register is at charcter before alphabet
  14. JNZ LOOP #If flag is not set go back to start of loop
  15. #i.e A register is still alphabetical charcater
  16. JMP END #Otherwise we'll execute this line that jumps to end label
  17.  
  18. END:
  19. END #End label calls end
  20.  
  21.  
  22. QUESTION TWO
  23. #Similar to one but must check if VDU is full
  24. #FF is 255 in decimal. 255 - 25 (26 letters in the alphabet)
  25. #This will give us the last possible memory adress we should use
  26. #255 - 25 = 230
  27. #230 in hex is E6
  28.  
  29. MOV AL, 5A
  30. MOV BL, D3
  31.  
  32. LOOP:
  33. CMP BL, E7 #Is BL in our unacceptable range? (E6 + 1)
  34. #S flag will be set if in acceptable range (less than or equal)
  35. JNS CHANGEVAL #If S flag not set, fix BL
  36. MOV [BL], AL
  37. DEC AL
  38. INC BL
  39. CMP AL, 40
  40. JNZ LOOP
  41. JMP END
  42.  
  43. CHANGEVAL:
  44. MOV BL, E6 #Put BL in acceptable range
  45. JMP LOOP #Go back to loop
  46.  
  47. END:
  48. END
  49.  
  50. QUESTION THREE
  51. MOV AL, 04
  52. ADD AL, 30 #30 is the ascii hex code for the character '0'
  53. #We are using a numeric four and we need to convert it to ascii 4
  54. MOV BL, 03
  55. ADD BL, 30 #30 is the ascii hex code for the character '0'
  56. #We are using a numeric four and we need to convert it to ascii 3
  57. ADD AL, BL #Result is 7 which is less than 9
  58. MOV [C0], AL
  59.  
  60. #Algorithm explanation:
  61. # By getting the number modulus 10 (i.e., 0a hex) the units portion of the number can be determined.
  62. # This can be written to the
  63. # appropriate place in the VDU after adding 30hex to determine
  64. # its corresponding character value.
  65. # 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
  66. # appropriate place in the VDU after adding 30hex to determine its corresponding character value.
  67.  
  68. #Write:
  69. #push al ; place the number on the stack for save keeping since the al value will change
  70. #mod al, 0a ; determine the units portion of the number
  71. #add al, 30 ; convert to numeric character
  72. #mov [c1], al; place in appropriate place in VDU
  73. #pop al ; retrieve original number from stack
  74. #div al, 0a ; determine the 10s portion of the number
  75. #add al, 30 ; convert ot numeric character11
  76. #mov [c0], al ; place in appropriate place on the stack
  77. #end
  78.  
  79. QUESTION FOUR
  80. MOV AL, 0C #12
  81. MOV BL, 03 #3
  82. MUL AL, BL
  83. MOV CL, AL
  84. PUSH CL
  85. MOV AL, 08
  86. MOV BL, 06
  87. MUL AL, BL
  88. MOV DL, AL
  89. DIV CL, 04
  90. ADD CL, DL
  91. POP DL
  92. SUB CL, DL
  93. PUSH CL
  94. MOD CL, 0a
  95. ADD CL, 30
  96. MOV [c1], a
  97. POP CL
  98. DIV CL, 0a
  99. ADD CL, 30
  100. MOV [c0], CL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement