I will hold my hands up here, my spelling and grammar is not very good.

Here i think you underestimate the power of fasm macros.

Both Encryption/decryption.

Code: Select all

```
macro rijndael_fasm_init key_size,block_size
{ if (key_size mod 32) | (key_size<128) | (key_size>256)
halt - Bad key size
else if (block_size mod 32) | (block_size<128) | (block_size>256)
halt - Bad block size
end if
rijndael_fasm_blocks=block_size/32
rijndael_fasm_keys=key_size/32
if block_size>key_size
rijndael_fasm_rounds=block_size/32+6
else
rijndael_fasm_rounds=key_size/32+6
end if
rijndael_fasm_shift1=1
if rijndael_fasm_blocks <= 7
rijndael_fasm_shift2=2
else
rijndael_fasm_shift2=3
end if
if rijndael_fasm_blocks <= 6
rijndael_fasm_shift3=3
else
rijndael_fasm_shift3=4
end if
}
macro rijndael_fasm_s_box the_byte
{ virtual at 0
db 063h,07Ch,077h,07Bh,0F2h,06Bh,06Fh,0C5h,030h,001h,067h,02Bh,0FEh,0D7h,0ABh,076h
db 0CAh,082h,0C9h,07Dh,0FAh,059h,047h,0F0h,0ADh,0D4h,0A2h,0AFh,09Ch,0A4h,072h,0C0h
db 0B7h,0FDh,093h,026h,036h,03Fh,0F7h,0CCh,034h,0A5h,0E5h,0F1h,071h,0D8h,031h,015h
db 004h,0C7h,023h,0C3h,018h,096h,005h,09Ah,007h,012h,080h,0E2h,0EBh,027h,0B2h,075h
db 009h,083h,02Ch,01Ah,01Bh,06Eh,05Ah,0A0h,052h,03Bh,0D6h,0B3h,029h,0E3h,02Fh,084h
db 053h,0D1h,000h,0EDh,020h,0FCh,0B1h,05Bh,06Ah,0CBh,0BEh,039h,04Ah,04Ch,058h,0CFh
db 0D0h,0EFh,0AAh,0FBh,043h,04Dh,033h,085h,045h,0F9h,002h,07Fh,050h,03Ch,09Fh,0A8h
db 051h,0A3h,040h,08Fh,092h,09Dh,038h,0F5h,0BCh,0B6h,0DAh,021h,010h,0FFh,0F3h,0D2h
db 0CDh,00Ch,013h,0ECh,05Fh,097h,044h,017h,0C4h,0A7h,07Eh,03Dh,064h,05Dh,019h,073h
db 060h,081h,04Fh,0DCh,022h,02Ah,090h,088h,046h,0EEh,0B8h,014h,0DEh,05Eh,00Bh,0DBh
db 0E0h,032h,03Ah,00Ah,049h,006h,024h,05Ch,0C2h,0D3h,0ACh,062h,091h,095h,0E4h,079h
db 0E7h,0C8h,037h,06Dh,08Dh,0D5h,04Eh,0A9h,06Ch,056h,0F4h,0EAh,065h,07Ah,0AEh,008h
db 0BAh,078h,025h,02Eh,01Ch,0A6h,0B4h,0C6h,0E8h,0DDh,074h,01Fh,04Bh,0BDh,08Bh,08Ah
db 070h,03Eh,0B5h,066h,048h,003h,0F6h,00Eh,061h,035h,057h,0B9h,086h,0C1h,01Dh,09Eh
db 0E1h,0F8h,098h,011h,069h,0D9h,08Eh,094h,09Bh,01Eh,087h,0E9h,0CEh,055h,028h,0DFh
db 08Ch,0A1h,089h,00Dh,0BFh,0E6h,042h,068h,041h,099h,02Dh,00Fh,0B0h,054h,0BBh,016h
load rijndael_fasm_s_box_result byte from the_byte
end virtual
}
macro rijndael_fasm_si_box the_byte
{ virtual at 0
db 052h,009h,06Ah,0D5h,030h,036h,0A5h,038h,0BFh,040h,0A3h,09Eh,081h,0F3h,0D7h,0FBh
db 07Ch,0E3h,039h,082h,09Bh,02Fh,0FFh,087h,034h,08Eh,043h,044h,0C4h,0DEh,0E9h,0CBh
db 054h,07Bh,094h,032h,0A6h,0C2h,023h,03Dh,0EEh,04Ch,095h,00Bh,042h,0FAh,0C3h,04Eh
db 008h,02Eh,0A1h,066h,028h,0D9h,024h,0B2h,076h,05Bh,0A2h,049h,06Dh,08Bh,0D1h,025h
db 072h,0F8h,0F6h,064h,086h,068h,098h,016h,0D4h,0A4h,05Ch,0CCh,05Dh,065h,0B6h,092h
db 06Ch,070h,048h,050h,0FDh,0EDh,0B9h,0DAh,05Eh,015h,046h,057h,0A7h,08Dh,09Dh,084h
db 090h,0D8h,0ABh,000h,08Ch,0BCh,0D3h,00Ah,0F7h,0E4h,058h,005h,0B8h,0B3h,045h,006h
db 0D0h,02Ch,01Eh,08Fh,0CAh,03Fh,00Fh,002h,0C1h,0AFh,0BDh,003h,001h,013h,08Ah,06Bh
db 03Ah,091h,011h,041h,04Fh,067h,0DCh,0EAh,097h,0F2h,0CFh,0CEh,0F0h,0B4h,0E6h,073h
db 096h,0ACh,074h,022h,0E7h,0ADh,035h,085h,0E2h,0F9h,037h,0E8h,01Ch,075h,0DFh,06Eh
db 047h,0F1h,01Ah,071h,01Dh,029h,0C5h,089h,06Fh,0B7h,062h,00Eh,0AAh,018h,0BEh,01Bh
db 0FCh,056h,03Eh,04Bh,0C6h,0D2h,079h,020h,09Ah,0DBh,0C0h,0FEh,078h,0CDh,05Ah,0F4h
db 01Fh,0DDh,0A8h,033h,088h,007h,0C7h,031h,0B1h,012h,010h,059h,027h,080h,0ECh,05Fh
db 060h,051h,07Fh,0A9h,019h,0B5h,04Ah,00Dh,02Dh,0E5h,07Ah,09Fh,093h,0C9h,09Ch,0EFh
db 0A0h,0E0h,03Bh,04Dh,0AEh,02Ah,0F5h,0B0h,0C8h,0EBh,0BBh,03Ch,083h,053h,099h,061h
db 017h,02Bh,004h,07Eh,0BAh,077h,0D6h,026h,0E1h,069h,014h,063h,055h,021h,00Ch,07Dh
load rijndael_fasm_si_box_result byte from the_byte
end virtual
}
macro rijndael_fasm_te the_dword
{ virtual at 0
dd 0A56363C6h,0847C7CF8h,0997777EEh,08D7B7BF6h,00DF2F2FFh,0BD6B6BD6h,0B16F6FDEh,054C5C591h
dd 050303060h,003010102h,0A96767CEh,07D2B2B56h,019FEFEE7h,062D7D7B5h,0E6ABAB4Dh,09A7676ECh
dd 045CACA8Fh,09D82821Fh,040C9C989h,0877D7DFAh,015FAFAEFh,0EB5959B2h,0C947478Eh,00BF0F0FBh
dd 0ECADAD41h,067D4D4B3h,0FDA2A25Fh,0EAAFAF45h,0BF9C9C23h,0F7A4A453h,0967272E4h,05BC0C09Bh
dd 0C2B7B775h,01CFDFDE1h,0AE93933Dh,06A26264Ch,05A36366Ch,0413F3F7Eh,002F7F7F5h,04FCCCC83h
dd 05C343468h,0F4A5A551h,034E5E5D1h,008F1F1F9h,0937171E2h,073D8D8ABh,053313162h,03F15152Ah
dd 00C040408h,052C7C795h,065232346h,05EC3C39Dh,028181830h,0A1969637h,00F05050Ah,0B59A9A2Fh
dd 00907070Eh,036121224h,09B80801Bh,03DE2E2DFh,026EBEBCDh,06927274Eh,0CDB2B27Fh,09F7575EAh
dd 01B090912h,09E83831Dh,0742C2C58h,02E1A1A34h,02D1B1B36h,0B26E6EDCh,0EE5A5AB4h,0FBA0A05Bh
dd 0F65252A4h,04D3B3B76h,061D6D6B7h,0CEB3B37Dh,07B292952h,03EE3E3DDh,0712F2F5Eh,097848413h
dd 0F55353A6h,068D1D1B9h,000000000h,02CEDEDC1h,060202040h,01FFCFCE3h,0C8B1B179h,0ED5B5BB6h
dd 0BE6A6AD4h,046CBCB8Dh,0D9BEBE67h,04B393972h,0DE4A4A94h,0D44C4C98h,0E85858B0h,04ACFCF85h
dd 06BD0D0BBh,02AEFEFC5h,0E5AAAA4Fh,016FBFBEDh,0C5434386h,0D74D4D9Ah,055333366h,094858511h
dd 0CF45458Ah,010F9F9E9h,006020204h,0817F7FFEh,0F05050A0h,0443C3C78h,0BA9F9F25h,0E3A8A84Bh
dd 0F35151A2h,0FEA3A35Dh,0C0404080h,08A8F8F05h,0AD92923Fh,0BC9D9D21h,048383870h,004F5F5F1h
dd 0DFBCBC63h,0C1B6B677h,075DADAAFh,063212142h,030101020h,01AFFFFE5h,00EF3F3FDh,06DD2D2BFh
dd 04CCDCD81h,0140C0C18h,035131326h,02FECECC3h,0E15F5FBEh,0A2979735h,0CC444488h,03917172Eh
dd 057C4C493h,0F2A7A755h,0827E7EFCh,0473D3D7Ah,0AC6464C8h,0E75D5DBAh,02B191932h,0957373E6h
dd 0A06060C0h,098818119h,0D14F4F9Eh,07FDCDCA3h,066222244h,07E2A2A54h,0AB90903Bh,08388880Bh
dd 0CA46468Ch,029EEEEC7h,0D3B8B86Bh,03C141428h,079DEDEA7h,0E25E5EBCh,01D0B0B16h,076DBDBADh
dd 03BE0E0DBh,056323264h,04E3A3A74h,01E0A0A14h,0DB494992h,00A06060Ch,06C242448h,0E45C5CB8h
dd 05DC2C29Fh,06ED3D3BDh,0EFACAC43h,0A66262C4h,0A8919139h,0A4959531h,037E4E4D3h,08B7979F2h
dd 032E7E7D5h,043C8C88Bh,05937376Eh,0B76D6DDAh,08C8D8D01h,064D5D5B1h,0D24E4E9Ch,0E0A9A949h
dd 0B46C6CD8h,0FA5656ACh,007F4F4F3h,025EAEACFh,0AF6565CAh,08E7A7AF4h,0E9AEAE47h,018080810h
dd 0D5BABA6Fh,0887878F0h,06F25254Ah,0722E2E5Ch,0241C1C38h,0F1A6A657h,0C7B4B473h,051C6C697h
dd 023E8E8CBh,07CDDDDA1h,09C7474E8h,0211F1F3Eh,0DD4B4B96h,0DCBDBD61h,0868B8B0Dh,0858A8A0Fh
dd 0907070E0h,0423E3E7Ch,0C4B5B571h,0AA6666CCh,0D8484890h,005030306h,001F6F6F7h,0120E0E1Ch
dd 0A36161C2h,05F35356Ah,0F95757AEh,0D0B9B969h,091868617h,058C1C199h,0271D1D3Ah,0B99E9E27h
dd 038E1E1D9h,013F8F8EBh,0B398982Bh,033111122h,0BB6969D2h,070D9D9A9h,0898E8E07h,0A7949433h
dd 0B69B9B2Dh,0221E1E3Ch,092878715h,020E9E9C9h,049CECE87h,0FF5555AAh,078282850h,07ADFDFA5h
dd 08F8C8C03h,0F8A1A159h,080898909h,0170D0D1Ah,0DABFBF65h,031E6E6D7h,0C6424284h,0B86868D0h
dd 0C3414182h,0B0999929h,0772D2D5Ah,0110F0F1Eh,0CBB0B07Bh,0FC5454A8h,0D6BBBB6Dh,03A16162Ch
load rijndael_fasm_te_result dword from (the_dword)*4
end virtual
}
macro rijndael_fasm_td the_dword
{ virtual at 0
dd 050A7F451h,05365417Eh,0C3A4171Ah,0965E273Ah,0CB6BAB3Bh,0F1459D1Fh,0AB58FAACh,09303E34Bh
dd 055FA3020h,0F66D76ADh,09176CC88h,0254C02F5h,0FCD7E54Fh,0D7CB2AC5h,080443526h,08FA362B5h
dd 0495AB1DEh,0671BBA25h,0980EEA45h,0E1C0FE5Dh,002752FC3h,012F04C81h,0A397468Dh,0C6F9D36Bh
dd 0E75F8F03h,0959C9215h,0EB7A6DBFh,0DA595295h,02D83BED4h,0D3217458h,02969E049h,044C8C98Eh
dd 06A89C275h,078798EF4h,06B3E5899h,0DD71B927h,0B64FE1BEh,017AD88F0h,066AC20C9h,0B43ACE7Dh
dd 0184ADF63h,082311AE5h,060335197h,0457F5362h,0E07764B1h,084AE6BBBh,01CA081FEh,0942B08F9h
dd 058684870h,019FD458Fh,0876CDE94h,0B7F87B52h,023D373ABh,0E2024B72h,0578F1FE3h,02AAB5566h
dd 00728EBB2h,003C2B52Fh,09A7BC586h,0A50837D3h,0F2872830h,0B2A5BF23h,0BA6A0302h,05C8216EDh
dd 02B1CCF8Ah,092B479A7h,0F0F207F3h,0A1E2694Eh,0CDF4DA65h,0D5BE0506h,01F6234D1h,08AFEA6C4h
dd 09D532E34h,0A055F3A2h,032E18A05h,075EBF6A4h,039EC830Bh,0AAEF6040h,0069F715Eh,051106EBDh
dd 0F98A213Eh,03D06DD96h,0AE053EDDh,046BDE64Dh,0B58D5491h,0055DC471h,06FD40604h,0FF155060h
dd 024FB9819h,097E9BDD6h,0CC434089h,0779ED967h,0BD42E8B0h,0888B8907h,0385B19E7h,0DBEEC879h
dd 0470A7CA1h,0E90F427Ch,0C91E84F8h,000000000h,083868009h,048ED2B32h,0AC70111Eh,04E725A6Ch
dd 0FBFF0EFDh,05638850Fh,01ED5AE3Dh,027392D36h,064D90F0Ah,021A65C68h,0D1545B9Bh,03A2E3624h
dd 0B1670A0Ch,00FE75793h,0D296EEB4h,09E919B1Bh,04FC5C080h,0A220DC61h,0694B775Ah,0161A121Ch
dd 00ABA93E2h,0E52AA0C0h,043E0223Ch,01D171B12h,00B0D090Eh,0ADC78BF2h,0B9A8B62Dh,0C8A91E14h
dd 08519F157h,04C0775AFh,0BBDD99EEh,0FD607FA3h,09F2601F7h,0BCF5725Ch,0C53B6644h,0347EFB5Bh
dd 07629438Bh,0DCC623CBh,068FCEDB6h,063F1E4B8h,0CADC31D7h,010856342h,040229713h,02011C684h
dd 07D244A85h,0F83DBBD2h,01132F9AEh,06DA129C7h,04B2F9E1Dh,0F330B2DCh,0EC52860Dh,0D0E3C177h
dd 06C16B32Bh,099B970A9h,0FA489411h,02264E947h,0C48CFCA8h,01A3FF0A0h,0D82C7D56h,0EF903322h
dd 0C74E4987h,0C1D138D9h,0FEA2CA8Ch,0360BD498h,0CF81F5A6h,028DE7AA5h,0268EB7DAh,0A4BFAD3Fh
dd 0E49D3A2Ch,00D927850h,09BCC5F6Ah,062467E54h,0C2138DF6h,0E8B8D890h,05EF7392Eh,0F5AFC382h
dd 0BE805D9Fh,07C93D069h,0A92DD56Fh,0B31225CFh,03B99ACC8h,0A77D1810h,06E639CE8h,07BBB3BDBh
dd 0097826CDh,0F418596Eh,001B79AECh,0A89A4F83h,0656E95E6h,07EE6FFAAh,008CFBC21h,0E6E815EFh
dd 0D99BE7BAh,0CE366F4Ah,0D4099FEAh,0D67CB029h,0AFB2A431h,031233F2Ah,03094A5C6h,0C066A235h
dd 037BC4E74h,0A6CA82FCh,0B0D090E0h,015D8A733h,04A9804F1h,0F7DAEC41h,00E50CD7Fh,02FF69117h
dd 08DD64D76h,04DB0EF43h,0544DAACCh,0DF0496E4h,0E3B5D19Eh,01B886A4Ch,0B81F2CC1h,07F516546h
dd 004EA5E9Dh,05D358C01h,0737487FAh,02E410BFBh,05A1D67B3h,052D2DB92h,0335610E9h,01347D66Dh
dd 08C61D79Ah,07A0CA137h,08E14F859h,0893C13EBh,0EE27A9CEh,035C961B7h,0EDE51CE1h,03CB1477Ah
dd 059DFD29Ch,03F73F255h,079CE1418h,0BF37C773h,0EACDF753h,05BAAFD5Fh,0146F3DDFh,086DB4478h
dd 081F3AFCAh,03EC468B9h,02C342438h,05F40A3C2h,072C31D16h,00C25E2BCh,08B493C28h,041950DFFh
dd 07101A839h,0DEB30C08h,09CE4B4D8h,090C15664h,06184CB7Bh,070B632D5h,0745C6C48h,04257B8D0h
load rijndael_fasm_td_result dword from (the_dword)*4
end virtual
}
macro rijndael_fasm_rcon the_byte
{ virtual at 0
db 001h,002h,004h,008h,010h,020h,040h,080h,01Bh,036h,06Ch,0D8h,0ABh,04Dh,09Ah,02Fh
db 05Eh,0BCh,063h,0C6h,097h,035h,06Ah,0D4h,0B3h,07Dh,0FAh,0EFh,0C5h,091h
load rijndael_fasm_rcon_result byte from the_byte
end virtual
}
macro rijndael_fasm_shifts_e the_byte
{ virtual at 0
repeat rijndael_fasm_blocks
db (%-1)
db (%-1+rijndael_fasm_shift1) mod rijndael_fasm_blocks
db (%-1+rijndael_fasm_shift2) mod rijndael_fasm_blocks
db (%-1+rijndael_fasm_shift3) mod rijndael_fasm_blocks
end repeat
load rijndael_fasm_shifts_e_result byte from the_byte
end virtual
}
macro rijndael_fasm_shifts_d the_byte
{ virtual at 0
repeat rijndael_fasm_blocks
db (%-1)
db (%-1+rijndael_fasm_blocks-rijndael_fasm_shift1) mod rijndael_fasm_blocks
db (%-1+rijndael_fasm_blocks-rijndael_fasm_shift2) mod rijndael_fasm_blocks
db (%-1+rijndael_fasm_blocks-rijndael_fasm_shift3) mod rijndael_fasm_blocks
end repeat
load rijndael_fasm_shifts_d_result byte from the_byte
end virtual
}
macro ror_dword_8 variable {variable=(variable shr 8) or ((variable and 0ffh) shl 24)}
macro rijndael_fasm_key_schedule [keys]
{ common
virtual at 0
if ~ keys eq
dd keys
end if
rq 60
repeat rijndael_fasm_blocks*(rijndael_fasm_rounds+1)-rijndael_fasm_keys
load rijndael_fasm_temp dword from (rijndael_fasm_keys+%-1)*4-4
if ((rijndael_fasm_keys>6)&(((%-1) mod rijndael_fasm_keys) and 3)=0)|\
((rijndael_fasm_keys<=6)&((%-1) mod rijndael_fasm_keys)=0)
rijndael_fasm_s_box (rijndael_fasm_temp and 0ffh)
rijndael_fasm_temp2=rijndael_fasm_s_box_result
rijndael_fasm_s_box ((rijndael_fasm_temp shr 8) and 0ffh)
rijndael_fasm_temp2=rijndael_fasm_temp2+(rijndael_fasm_s_box_result shl 8)
rijndael_fasm_s_box ((rijndael_fasm_temp shr 16) and 0ffh)
rijndael_fasm_temp2=rijndael_fasm_temp2+(rijndael_fasm_s_box_result shl 16)
rijndael_fasm_s_box ((rijndael_fasm_temp shr 24) and 0ffh)
rijndael_fasm_temp=rijndael_fasm_temp2+(rijndael_fasm_s_box_result shl 24)
if ((%-1) mod rijndael_fasm_keys)=0
ror_dword_8 rijndael_fasm_temp
rijndael_fasm_rcon (%-1)/rijndael_fasm_keys
rijndael_fasm_temp=rijndael_fasm_temp xor rijndael_fasm_rcon_result
end if
end if
load rijndael_fasm_temp2 dword from (%-1)*4
rijndael_fasm_temp=rijndael_fasm_temp xor rijndael_fasm_temp2
store dword rijndael_fasm_temp at (rijndael_fasm_keys+%-1)*4
end repeat
rept 60 rept_loop:0 \{ load rijndael_fasm_rk_e_\#rept_loop qword from rept_loop*8 \}
repeat rijndael_fasm_blocks*(rijndael_fasm_rounds-1)
load rijndael_fasm_temp dword from (rijndael_fasm_blocks+%-1)*4
rijndael_fasm_s_box (rijndael_fasm_temp and 0ffh)
rijndael_fasm_td rijndael_fasm_s_box_result
rijndael_fasm_temp2=rijndael_fasm_td_result
ror_dword_8 rijndael_fasm_temp2
rijndael_fasm_s_box ((rijndael_fasm_temp shr 8) and 0ffh)
rijndael_fasm_td rijndael_fasm_s_box_result
rijndael_fasm_temp2=rijndael_fasm_temp2 xor rijndael_fasm_td_result
ror_dword_8 rijndael_fasm_temp2
rijndael_fasm_s_box ((rijndael_fasm_temp shr 16) and 0ffh)
rijndael_fasm_td rijndael_fasm_s_box_result
rijndael_fasm_temp2=rijndael_fasm_temp2 xor rijndael_fasm_td_result
ror_dword_8 rijndael_fasm_temp2
rijndael_fasm_s_box ((rijndael_fasm_temp shr 24) and 0ffh)
rijndael_fasm_td rijndael_fasm_s_box_result
rijndael_fasm_temp=rijndael_fasm_temp2 xor rijndael_fasm_td_result
ror_dword_8 rijndael_fasm_temp
store dword rijndael_fasm_temp at (rijndael_fasm_blocks+%-1)*4
end repeat
rept 60 rept_loop:0 \{ load rijndael_fasm_rk_d_\#rept_loop qword from rept_loop*8 \}
end virtual
}
macro rijndael_fasm_encrypt_block block_address
{ local ..src,..key,..dst
rept 8 rept_loop:0 \{ load rijndael_fasm_block_\#rept_loop dword from block_address+(rept_loop mod rijndael_fasm_blocks)*4 \}
virtual at 0
..src=$
rept 8 rept_loop:0 \{dd rijndael_fasm_block_\#rept_loop\}
..key=$
rept 60 rept_loop:0 \{dq rijndael_fasm_rk_e_\#rept_loop\}
..dst=$
rd 8
repeat rijndael_fasm_blocks
load rijndael_fasm_temp dword from ..src+(%-1)*4
load rijndael_fasm_temp2 dword from ..key+(%-1)*4
rijndael_fasm_temp=rijndael_fasm_temp2 xor rijndael_fasm_temp
store dword rijndael_fasm_temp at ..src+(%-1)*4
end repeat
repeat (rijndael_fasm_rounds-1)
rijndael_fasm_round=%
repeat rijndael_fasm_blocks
rijndael_fasm_shifts_e (%-1)*4+0
load rijndael_fasm_temp byte from ..src+rijndael_fasm_shifts_e_result*4+0
rijndael_fasm_te rijndael_fasm_temp
rijndael_fasm_temp2=rijndael_fasm_te_result
ror_dword_8 rijndael_fasm_temp2
rijndael_fasm_shifts_e (%-1)*4+1
load rijndael_fasm_temp byte from ..src+rijndael_fasm_shifts_e_result*4+1
rijndael_fasm_te rijndael_fasm_temp
rijndael_fasm_temp2=rijndael_fasm_temp2 xor rijndael_fasm_te_result
ror_dword_8 rijndael_fasm_temp2
rijndael_fasm_shifts_e (%-1)*4+2
load rijndael_fasm_temp byte from ..src+rijndael_fasm_shifts_e_result*4+2
rijndael_fasm_te rijndael_fasm_temp
rijndael_fasm_temp2=rijndael_fasm_temp2 xor rijndael_fasm_te_result
ror_dword_8 rijndael_fasm_temp2
rijndael_fasm_shifts_e (%-1)*4+3
load rijndael_fasm_temp byte from ..src+rijndael_fasm_shifts_e_result*4+3
rijndael_fasm_te rijndael_fasm_temp
rijndael_fasm_temp2=rijndael_fasm_temp2 xor rijndael_fasm_te_result
ror_dword_8 rijndael_fasm_temp2
load rijndael_fasm_temp dword from ..key+(rijndael_fasm_round*rijndael_fasm_blocks+%-1)*4
rijndael_fasm_temp=rijndael_fasm_temp2 xor rijndael_fasm_temp
store dword rijndael_fasm_temp at ..dst+(%-1)*4
end repeat
repeat 4
load rijndael_fasm_temp qword from ..dst+(%-1)*8
store qword rijndael_fasm_temp at ..src+(%-1)*8
end repeat
end repeat
repeat rijndael_fasm_blocks
rijndael_fasm_shifts_e (%-1)*4+0
load rijndael_fasm_temp byte from ..src+rijndael_fasm_shifts_e_result*4+0
rijndael_fasm_s_box rijndael_fasm_temp
rijndael_fasm_temp2=rijndael_fasm_s_box_result
rijndael_fasm_shifts_e (%-1)*4+1
load rijndael_fasm_temp byte from ..src+rijndael_fasm_shifts_e_result*4+1
rijndael_fasm_s_box rijndael_fasm_temp
rijndael_fasm_temp2=rijndael_fasm_temp2+(rijndael_fasm_s_box_result shl 8)
rijndael_fasm_shifts_e (%-1)*4+2
load rijndael_fasm_temp byte from ..src+rijndael_fasm_shifts_e_result*4+2
rijndael_fasm_s_box rijndael_fasm_temp
rijndael_fasm_temp2=rijndael_fasm_temp2+(rijndael_fasm_s_box_result shl 16)
rijndael_fasm_shifts_e (%-1)*4+3
load rijndael_fasm_temp byte from ..src+rijndael_fasm_shifts_e_result*4+3
rijndael_fasm_s_box rijndael_fasm_temp
rijndael_fasm_temp2=rijndael_fasm_temp2+(rijndael_fasm_s_box_result shl 24)
load rijndael_fasm_temp dword from ..key+(rijndael_fasm_rounds*rijndael_fasm_blocks+%-1)*4
rijndael_fasm_temp=rijndael_fasm_temp2 xor rijndael_fasm_temp
store dword rijndael_fasm_temp at ..dst+(%-1)*4
end repeat
rept 8 rept_loop:0 \{ load rijndael_fasm_block_\#rept_loop dword from ..dst+rept_loop*4 \}
end virtual
rept 8 rept_loop:0 \{ if rept_loop<rijndael_fasm_blocks
store dword rijndael_fasm_block_\#rept_loop at block_address+rept_loop*4
end if
\}
}
macro rijndael_fasm_decrypt_block block_address
{ local ..src,..key,..dst
rept 8 rept_loop:0 \{ load rijndael_fasm_block_\#rept_loop dword from block_address+(rept_loop mod rijndael_fasm_blocks)*4 \}
virtual at 0
..src=$
rept 8 rept_loop:0 \{dd rijndael_fasm_block_\#rept_loop\}
..key=$
rept 60 rept_loop:0 \{dq rijndael_fasm_rk_d_\#rept_loop\}
..dst=$
rd 8
repeat rijndael_fasm_blocks
load rijndael_fasm_temp dword from ..src+(%-1)*4
load rijndael_fasm_temp2 dword from ..key+(rijndael_fasm_rounds*rijndael_fasm_blocks+%-1)*4
rijndael_fasm_temp=rijndael_fasm_temp2 xor rijndael_fasm_temp
store dword rijndael_fasm_temp at ..src+(%-1)*4
end repeat
repeat (rijndael_fasm_rounds-1)
rijndael_fasm_round=rijndael_fasm_rounds-%
repeat rijndael_fasm_blocks
rijndael_fasm_shifts_d (%-1)*4+0
load rijndael_fasm_temp byte from ..src+rijndael_fasm_shifts_d_result*4+0
rijndael_fasm_td rijndael_fasm_temp
rijndael_fasm_temp2=rijndael_fasm_td_result
ror_dword_8 rijndael_fasm_temp2
rijndael_fasm_shifts_d (%-1)*4+1
load rijndael_fasm_temp byte from ..src+rijndael_fasm_shifts_d_result*4+1
rijndael_fasm_td rijndael_fasm_temp
rijndael_fasm_temp2=rijndael_fasm_temp2 xor rijndael_fasm_td_result
ror_dword_8 rijndael_fasm_temp2
rijndael_fasm_shifts_d (%-1)*4+2
load rijndael_fasm_temp byte from ..src+rijndael_fasm_shifts_d_result*4+2
rijndael_fasm_td rijndael_fasm_temp
rijndael_fasm_temp2=rijndael_fasm_temp2 xor rijndael_fasm_td_result
ror_dword_8 rijndael_fasm_temp2
rijndael_fasm_shifts_d (%-1)*4+3
load rijndael_fasm_temp byte from ..src+rijndael_fasm_shifts_d_result*4+3
rijndael_fasm_td rijndael_fasm_temp
rijndael_fasm_temp2=rijndael_fasm_temp2 xor rijndael_fasm_td_result
ror_dword_8 rijndael_fasm_temp2
load rijndael_fasm_temp dword from ..key+(rijndael_fasm_round*rijndael_fasm_blocks+%-1)*4
rijndael_fasm_temp=rijndael_fasm_temp2 xor rijndael_fasm_temp
store dword rijndael_fasm_temp at ..dst+(%-1)*4
end repeat
repeat 4
load rijndael_fasm_temp qword from ..dst+(%-1)*8
store qword rijndael_fasm_temp at ..src+(%-1)*8
end repeat
end repeat
repeat rijndael_fasm_blocks
rijndael_fasm_shifts_d (%-1)*4+0
load rijndael_fasm_temp byte from ..src+rijndael_fasm_shifts_d_result*4+0
rijndael_fasm_si_box rijndael_fasm_temp
rijndael_fasm_temp2=rijndael_fasm_si_box_result
rijndael_fasm_shifts_d (%-1)*4+1
load rijndael_fasm_temp byte from ..src+rijndael_fasm_shifts_d_result*4+1
rijndael_fasm_si_box rijndael_fasm_temp
rijndael_fasm_temp2=rijndael_fasm_temp2+(rijndael_fasm_si_box_result shl 8)
rijndael_fasm_shifts_d (%-1)*4+2
load rijndael_fasm_temp byte from ..src+rijndael_fasm_shifts_d_result*4+2
rijndael_fasm_si_box rijndael_fasm_temp
rijndael_fasm_temp2=rijndael_fasm_temp2+(rijndael_fasm_si_box_result shl 16)
rijndael_fasm_shifts_d (%-1)*4+3
load rijndael_fasm_temp byte from ..src+rijndael_fasm_shifts_d_result*4+3
rijndael_fasm_si_box rijndael_fasm_temp
rijndael_fasm_temp2=rijndael_fasm_temp2+(rijndael_fasm_si_box_result shl 24)
load rijndael_fasm_temp dword from ..key+(%-1)*4
rijndael_fasm_temp=rijndael_fasm_temp2 xor rijndael_fasm_temp
store dword rijndael_fasm_temp at ..dst+(%-1)*4
end repeat
rept 8 rept_loop:0 \{ load rijndael_fasm_block_\#rept_loop dword from ..dst+rept_loop*4 \}
end virtual
rept 8 rept_loop:0 \{ if rept_loop<rijndael_fasm_blocks
store dword rijndael_fasm_block_\#rept_loop at block_address+rept_loop*4
end if
\}
}
macro rijndael_fasm_encrypt_blocks_ecb block_address,bytes
{ repeat (bytes-1)/(rijndael_fasm_blocks*4)+1
rijndael_fasm_encrypt_block block_address+(%-1)*rijndael_fasm_blocks*4
end repeat
}
macro rijndael_fasm_decrypt_blocks_ecb block_address,bytes
{ repeat (bytes-1)/(rijndael_fasm_blocks*4)+1
rijndael_fasm_decrypt_block block_address+(%-1)*rijndael_fasm_blocks*4
end repeat
}
macro rijndael_fasm_encrypt_blocks_cbc block_address,bytes,[iv]
{ common
virtual at 0
if ~ iv eq
dd iv
end if
dd 8 dup (0)
rept 8 rept_loop:0 \{ load rijndael_fasm_iv_\#rept_loop dword from rept_loop*4 \}
end virtual
repeat (bytes-1)/(rijndael_fasm_blocks*4)+1
rijndael_fasm_cbc=block_address+(%-1)*rijndael_fasm_blocks*4
rept 8 rept_loop:0 \{ if rept_loop<rijndael_fasm_blocks
load rijndael_fasm_temp dword from rijndael_fasm_cbc+rept_loop*4
rijndael_fasm_temp=rijndael_fasm_temp xor rijndael_fasm_iv_\#rept_loop
store dword rijndael_fasm_temp at rijndael_fasm_cbc+rept_loop*4
end if
\}
rijndael_fasm_encrypt_block rijndael_fasm_cbc
rept 8 rept_loop:0 \{ load rijndael_fasm_iv_\#rept_loop dword from rijndael_fasm_cbc+(rept_loop mod rijndael_fasm_blocks)*4 \}
end repeat
}
macro rijndael_fasm_decrypt_blocks_cbc block_address,bytes,[iv]
{ common
virtual at 0
if ~ iv eq
dd iv
end if
dd 8 dup (0)
rept 8 rept_loop:0 \{ load rijndael_fasm_iv_new_\#rept_loop dword from rept_loop*4 \}
end virtual
repeat (bytes-1)/(rijndael_fasm_blocks*4)+1
rijndael_fasm_cbc=block_address+(%-1)*rijndael_fasm_blocks*4
rept 8 rept_loop:0 \{ load rijndael_fasm_iv_last_\#rept_loop dword from rijndael_fasm_cbc+(rept_loop mod rijndael_fasm_blocks)*4 \}
rijndael_fasm_decrypt_block rijndael_fasm_cbc
rept 8 rept_loop:0 \{ if rept_loop<rijndael_fasm_blocks
load rijndael_fasm_temp dword from rijndael_fasm_cbc+rept_loop*4
rijndael_fasm_temp=rijndael_fasm_temp xor rijndael_fasm_iv_new_\#rept_loop
store dword rijndael_fasm_temp at rijndael_fasm_cbc+rept_loop*4
end if
\}
rept 8 rept_loop:0 \{ rijndael_fasm_iv_new_\#rept_loop=rijndael_fasm_iv_last_\#rept_loop \}
end repeat
}
```

Note: i have only use simple examples so as not to scare beginners away.

Anything you can do in basic, would be easy possible using this method.

DexBasic language will grow to be has fully featured as any other basic.

But i may use some parts of assembly instead, if they are more powerful and just as easy to understand.

I may even add a DexBasic interpreter if needed.

Also i am not sure there is a need for a bare metal OS that let's you program on the PI its self, linux is good for that.

I am looking to make (and i think theres more a need) for using the R-PI to be a more powerful arduino, that runs one program in real-time, eg: robots.