Advertisement
Guest User

Question about GOLF-CPU

a guest
Feb 14th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1.  
  2. # It seems that t=1 regardless of whether "first" or "second" is bigger
  3. # I was hoping you could shed some light on what is happening here.
  4.  
  5. #first = "5"
  6. #second = "4"
  7.  
  8. first = "4"
  9. second = "5"
  10.  
  11.  
  12. mov a, data(first) # a = &first (address of first)
  13. mov b, data(second) # b = &second
  14. lw c, a # c = *a ( c becomes the object at address a)
  15. lw d, b # d = *b
  16. sub c, c, 48 # change ascii to the true number value
  17. sub d, d, 48 # ^
  18.  
  19. #---------------v # print c and d
  20. #
  21. add c, c, 48 #
  22. sw -1, c #
  23. add d, d, 48 #
  24. sw -1, 62 # >
  25. sw -1, 61 # =
  26. sw -1, d #
  27. sub c, c, 48 #
  28. sub d, d, 48 #
  29. sw -1,10 # LF
  30. #
  31. #---------------^
  32.  
  33.  
  34. geq t, c, d # t = c>=d
  35.  
  36. #--------------v # print t
  37. #
  38. add t, t, 48
  39. sw -1, t
  40. sub t, t, 48
  41. sw -1, 10 # LF
  42. #
  43. #--------------^
  44.  
  45.  
  46.  
  47. halt 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement