Prn Hex Str
Solving Loops in Assembly first may help you to prepare for this problem better.
Let us now learn extensions for working with console
which our emulator provides. Please note that such input-output operations are dependent on specific hardware implementation
(i.e. how Intel 4004 CPU and other chips are connected to keyboard and display, types of these peripherals etc) - so if you
ever get real device with
c4004 inside, you should not expect these extensions to work in the same way.
So we have two of them:
$3f0reads a character into
$3e0prints the character from the same registers.
I.e. if we write a simple program:
loop: jms $3f0 jms $3e0 jun loop
It will copy data from standard input to standard output without termination.
The goal is to write a program which:
What we'll see in
r2:r3 after reading a character? It is
8-bit ASCII-code - for
example it would be
"A" (their decimal values are
So for each char you read, you need to convert its higher and lower nibbles (values of
r3) into code of
respective character from set
0123456789ABCDEF, load this code into the same pair again and call print. You may stop
when you read a character whith higher nibble equal to
0 (it is either new-line with code
$0A or carriage-return with
Note that for this problem input is not given as sequence of
16 digits as for previous tasks, so it is not regarded
as initial states of registers and instead is simply used to feed your program from virtual console.
Input would be short text string.
Output should contain hex codes of the characters of the string.
input: A0! output: 413021 input: Hi, People output: 48692C2050656F706C65