Advertisement
heavenriver

ExEsonero.asm

Jun 19th, 2012
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;Exercise from: http://i46.tinypic.com/2whm49u.jpg
  2.  
  3. org 400h
  4. disp equ 0h           ;Interrupts every 30 seconds and interruption programs DMAC
  5. dmac equ 1h           ;DMAC, acquires 512B from an external drive and stores them in #buffer
  6. car equ 2h            ;DMAC's current address register
  7. wc equ 3h             ;DMAC's word counter
  8. buffer equ 0BCBCh     ;Memory buffer starting address
  9. datac equ 0CCh        ;Binary number 11001100, if present less than 11 times in buffer disp is masked
  10. code
  11. jsr init
  12. seti
  13. main: jmp main        ;Loops until interrupt
  14. halt
  15. init: inl #30, disp   ;Sets counter to 30 seconds and starts disp
  16. start disp
  17. ret
  18. driver 0, 700h        ;Display driver
  19. push R0
  20. movl #512, R0
  21. outl R0, wc           ;Sets word counter to 512
  22. movl #0BCBCh, R0
  23. outl R0, car          ;Sets initial memory location to buffer
  24. start dmac
  25. pop R0
  26. rti
  27. driver 1, 900h        ;DMAC driver
  28. push R0
  29. push R1
  30. push R2
  31. push R3
  32. movl #512, R0         ;Serves as word counter
  33. movl #0BCBCh, R1      ;Serves as current address register
  34. movb #0CCh, R2        ;Stores data to compare
  35. xorl R3, R3           ;Serves as counter, stores how many times the word is found in memory
  36. find: cmpb (R1)+, R2  ;Compares data contained in memory with data to find
  37. jnz notfound
  38. addl #1, R3           ;Adds to the counter when the data is found
  39. notfound: subl #1, R0 ;Updates word counter
  40. jz exit               ;Exits when counter hits zero
  41. jmp find
  42. exit: cmpl #10, R3
  43. jz ok                 ;If data appears 10 times, deactivates disp
  44. jnn skip              ;If data appears more than 10 times, deactivation is skipped
  45. ok: clear disp
  46. skip: pop R3          ;Returns from subroutine
  47. pop R2
  48. pop R1
  49. pop R0
  50. rti
  51. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement