Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- START movea.l #0x2300000,a0 ;copy 0x2300000 into a0 (where we read)
- movea.l #0x2310000,a1 ;copy 0x2310000 into a1 (where we write)
- LOOP cmp.l #0x0D, (%a0) ;exit program if enter key is found
- beq EXIT ;exit program
- cmp.l #0x30, (%a0) ;check the range from [30,39]
- blt INVALID_ASCII
- cmp.l #0x39,(%a0)
- bgt GT_39 ;if it's greater than 39
- move.l (%a0),%d0 ;temp variable
- sub.l #0x30,%d0 ;it's within 30-39 range subtract 30 then store result
- move.l %d0,(%a1) ;copy temp content into result address
- adda #4,%a1 ;increment by 4 bytes
- adda #4,%a0 ;increment by 4 bytes
- clr.l %d0 ;clear content in d0
- bra LOOP ;branch back to LOOP
- GT_39: cmp.l #0x41, (%a0) ;if it's less than 41 but greater than 39 then invalid
- ble INVALID_ASCII
- cmp.l #0x46, (%a0)
- bgt GT_46
- move.l (%a0),%d0 ;temp variable
- sub.l #0x31,%d0 ;it's within 41-46 range subtract 31 then store result
- move.l %d0,(%a1) ;copy temp content into result address
- adda #4,%a1 ;increment by 4 bytes
- adda #4,%a0 ;increment by 4 bytes
- clr.l %d0 ;clear content in d0
- bra LOOP ;branch back to LOOP
- GT_46: cmp.l #0x61, (%a0) ;if it's less than 61 but greater than 46 then invalid
- ble INVALID_ASCII
- cmp.l #0x66, (%a0)
- bgt INVALID_ASCII ;if larger than 66 then it's automatically invalid
- move.l (%a0),%d0 ;temp variable
- sub.l #0x87,%d0 ;it's within 61-66 range subtract 87 then store result
- move.l %d0,(%a1) ;copy temp content into result address
- adda #4,%a1 ;increment by 4 bytes
- adda #4,%a0 ;increment by 4 bytes
- clr.l %d0 ;clear content in d0
- bra LOOP ;branch back to LOOP
- INVALID_ASCII: move.l #0xFFFFFFFF, (a1) ;copy the error code into location of a1
- adda #4,%a1 ;increment address by 4 bytes
- bra loop ;branch back to the loop
- EXIT:
Add Comment
Please, Sign In to add comment