MCPcopy Create free account
hub / github.com/CE-Programming/CEmu / sha256_read

Function sha256_read

core/sha256.c:99–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97}
98
99static uint8_t sha256_read(uint16_t pio, bool peek) {
100 uint16_t index = pio >> 2;
101 uint8_t bit_offset = (pio & 3) << 3;
102
103 if (!peek) {
104 if (protected_ports_unlocked()) {
105 sha256.last = index;
106 } else {
107 index = sha256.last;
108 }
109 }
110
111 if (index == 0x0C >> 2) {
112 return read8(sha256.state[7], bit_offset);
113 } else if (index >= 0x10 >> 2 && index < 0x50 >> 2) {
114 return read8(sha256.block[index - (0x10 >> 2)], bit_offset);
115 } else if (index >= 0x60 >> 2 && index < 0x80 >> 2) {
116 return read8(sha256.state[index - (0x60 >> 2)], bit_offset);
117 }
118 /* Return 0 if invalid */
119 return 0;
120}
121
122static void sha256_write(uint16_t pio, uint8_t byte, bool poke) {
123 uint16_t index = pio >> 2;

Callers

nothing calls this directly

Calls 1

protected_ports_unlockedFunction · 0.85

Tested by

no test coverage detected