Given an 8086 segmented ("logical") memory address, output its actual linear physical address.
A segmented memory address has format xxxx:xxxx
, where each of x
is one of 0-9A-F
, and the two parts are parsed as hexadecimal integers. Both parts are exactly 4 digits.
To get its actual linear address, multiply the first part by sixteen and add the second part. You can return it in a reasonable format, e.g. integer or a length=5 string. You can choose whether to modulo the result by \$2^{20}\$ (like 8086, or 286+ with the A20 gate closed). Yet input format is fixed.
This is code-golf, shortest code in each language wins.
Test cases
0000:0000 -> 0x00000
1111:1111 -> 0x12221
FFFF:0000 -> 0xFFFF0
FFFF:0010 -> 0x00000 or 0x100000
"1111:1111" -> [4369, 4369]
? \$\endgroup\$[4369, 4368]
is a base 16 representation of the result - just wondering what "reasonable" is and how far we can push it :) \$\endgroup\$