SHOW:
|
|
- or go back to the newest paste.
| 1 | SYSEXIT = 1 | |
| 2 | SYSREAD = 3 | |
| 3 | SYSWRITE = 4 | |
| 4 | ||
| 5 | STDIN = 0 | |
| 6 | STDOUT = 1 | |
| 7 | ||
| 8 | SYSCALL = 0x80 | |
| 9 | EXIT_SUCCESS = 0 | |
| 10 | ||
| 11 | BUFFOR_SIZE = 1 | |
| 12 | CESAR_SHIFT = 25 | |
| 13 | ||
| 14 | A_ASCII = 0x41 | |
| 15 | Z_ASCII = 0x5A | |
| 16 | AZ_DIFF = 0x1A | |
| 17 | ||
| 18 | .align 32 | |
| 19 | ||
| 20 | .data | |
| 21 | currentByte: .byte 0x00 | |
| 22 | ||
| 23 | .text | |
| 24 | ||
| 25 | .global _start | |
| 26 | ||
| 27 | _start: | |
| 28 | # start pętli głownej - wczytanie 1 bajtu do currentByte | |
| 29 | mainLoop: | |
| 30 | mov $SYSREAD, %eax | |
| 31 | mov $STDIN, %ebx | |
| 32 | mov $currentByte, %ecx | |
| 33 | mov $BUFFOR_SIZE, %edx | |
| 34 | ||
| 35 | int $SYSCALL | |
| 36 | ||
| 37 | # jesli w akumulatorze jest 0 - koniec, skok do końca pętli | |
| 38 | cmp $0, %eax | |
| 39 | je end | |
| 40 | ||
| 41 | cmpb $A_ASCII, currentByte | |
| 42 | jl writeByte | |
| 43 | ||
| 44 | cmpb $Z_ASCII, currentByte | |
| 45 | jg writeByte | |
| 46 | ||
| 47 | #przetwarzanie A-Z | |
| 48 | ||
| 49 | addb $CESAR_SHIFT, currentByte | |
| 50 | ||
| 51 | cmpb $Z_ASCII, currentByte | |
| 52 | jle writeByte | |
| 53 | ||
| 54 | subb $AZ_DIFF, currentByte | |
| 55 | ||
| 56 | #koniec przetwarzania A-Z | |
| 57 | ||
| 58 | writeByte: | |
| 59 | ||
| 60 | mov $SYSWRITE, %eax | |
| 61 | mov $STDOUT, %ebx | |
| 62 | mov $currentByte, %ecx | |
| 63 | mov $BUFFOR_SIZE, %edx | |
| 64 | ||
| 65 | int $SYSCALL | |
| 66 | ||
| 67 | # skok do początku pętli głównej | |
| 68 | jmp mainLoop | |
| 69 | ||
| 70 | end: | |
| 71 | mov $SYSEXIT, %eax | |
| 72 | mov $EXIT_SUCCESS, %ebx | |
| 73 | ||
| 74 | int $SYSCALL |