Guest User

Untitled

a guest
Jan 12th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. START           movea.l #0x2300000,a0           ;copy 0x2300000 into a0 (where we read)
  2.             movea.l #0x2310000,a1           ;copy 0x2310000 into a1 (where we write)
  3.  
  4.  
  5. LOOP            cmp.l #0x0D, (%a0)          ;exit program if enter key is found
  6.             beq EXIT                ;exit program
  7.  
  8.             cmp.l #0x30, (%a0)          ;check the range from [30,39]
  9.             blt INVALID_ASCII          
  10.  
  11.             cmp.l #0x39,(%a0)
  12.             bgt GT_39               ;if it's greater than 39
  13.  
  14.             move.l (%a0),%d0            ;temp variable
  15.             sub.l #0x30,%d0             ;it's within 30-39 range subtract 30 then store result
  16.             move.l %d0,(%a1)            ;copy temp content into result address
  17.             adda #4,%a1             ;increment by 4 bytes
  18.             adda #4,%a0             ;increment by 4 bytes
  19.             clr.l %d0               ;clear content in d0
  20.             bra LOOP                ;branch back to LOOP
  21.    
  22.  
  23. GT_39:          cmp.l #0x41, (%a0)          ;if it's less than 41 but greater than 39 then invalid
  24.             ble INVALID_ASCII
  25.             cmp.l #0x46, (%a0)
  26.             bgt GT_46
  27.  
  28.             move.l (%a0),%d0            ;temp variable
  29.             sub.l #0x31,%d0             ;it's within 41-46 range subtract 31 then store result
  30.             move.l %d0,(%a1)            ;copy temp content into result address
  31.             adda #4,%a1             ;increment by 4 bytes
  32.             adda #4,%a0             ;increment by 4 bytes
  33.             clr.l %d0               ;clear content in d0
  34.             bra LOOP                ;branch back to LOOP
  35.            
  36.  
  37.  
  38. GT_46:          cmp.l #0x61, (%a0)          ;if it's less than 61 but greater than 46 then invalid
  39.             ble INVALID_ASCII
  40.             cmp.l #0x66, (%a0)
  41.             bgt INVALID_ASCII           ;if larger than 66 then it's automatically invalid
  42.  
  43.             move.l (%a0),%d0            ;temp variable
  44.             sub.l #0x87,%d0             ;it's within 61-66 range subtract 87 then store result
  45.             move.l %d0,(%a1)            ;copy temp content into result address
  46.             adda #4,%a1             ;increment by 4 bytes
  47.             adda #4,%a0             ;increment by 4 bytes
  48.             clr.l %d0               ;clear content in d0
  49.             bra LOOP                ;branch back to LOOP
  50.            
  51.  
  52.  
  53. INVALID_ASCII:      move.l #0xFFFFFFFF, (a1)        ;copy the error code into location of a1
  54.             adda #4,%a1             ;increment address by 4 bytes
  55.             bra loop                ;branch back to the loop
  56.  
  57.  
  58. EXIT:
Add Comment
Please, Sign In to add comment