Mikrosha. Chapter Two ROM and BSVV


In the previous chapter, I described the iron part of my Microsha PC SD card controller. And this chapter came out program-philosophical. Who cares - welcome!


ROM write

As I wrote in the previous part, I have an old ROM programmer for LPT. I did not want to communicate with LPT emulation, in addition, I would have to understand how the programmer works, how it is controlled, all its commands and time delays.

Then I called my brother, who is a community service worker and works. I asked him to call me at work and pick up my first IBM ThinkPad 760ed laptop there. And the next day I had the beech.


However, I was not yet ready to flash. I needed to change all addresses from 6xxx to Fxxx, where xxx is 12 bits of the firmware address. This was necessary because of the architecture of the KP580VM80A processor; its command system does not involve code transfer from one memory area to another, which causes some difficulties.
By the way, because of this, it took me a lot of time to general edit the firmware, because as a result of low-level code optimization, “holes” began to form between the subprograms. The size of these unused sections sometimes reached 10 bytes, and I could not afford such squandering. I had to shift the joints and make sure that the code "did not move out" on calls and transitions.

Ultimately, I put together a minimally viable firmware. This is still a crude option, which can normally load the laid down code in additional RAM and transfer control. The dampness of the firmware lies in the fact that so far I have not come up with a good optimization and convenient device of the functionality that I call "bridges". This functionality is needed for the full use of all additional RAM. But I got confused in working with the stack I caught a lot of glitches and decided to leave the problem for later, but for now, using only 4 KB of new RAM should be enough for a start. And after that it will be possible to add this functionality, when it will become clear what requirements are needed for the Operating System. And besides the space left under the "bridges", I had about 600 bytes of free space.

I filled all the free space with 0xFF bytes, this will allow me to “finish” new blocks into ROM in the future without erasing all the memory with ultraviolet radiation. The fact is that these "EPROMs" are arranged so that the firmware consists in changing 1 in a bit to 0. Thus, 0xFF can be turned into any code. In addition, after a couple of key transitions “JMP” I left 3 codes 0xFF. This will allow you to turn the JMP codes themselves into 0x00 (NOP) and the transition will be canceled, but put another transition after it, making it from these three 0xFF.

Next, I needed 12-volt power. At first I wanted to connect to the Mikrosh PSU, but then I saw a twist in the middle of the ThinkPad’s power cable. I remember how this twist appeared, this beech was powered from a car, for chip tuning of all sorts of “January” and “Bosh”, when the first injection “chisels” appeared.
Having twisted the twist, I wrapped a cable with a DJK-11b connector there and the red LED on the programmer lighted up merrily.

After turning on the laptop, I saw the following:

At the same time, “dzzzzz-CLAT !!!” was heard once a second.
Yes! This meant that the HDD in the laptop was not working. I was sad for 10-15 minutes, and then I realized that not everything was lost, and that this ThinkPad has a CD-ROM. Rummaging through the junk, I found 3 DVD blanks, but I need a CD!

Then I called my brother again and asked to buy 3 CD-R discs in Auchan. To describe the creation of a CD-ROM with MS-DOS 6.22 here, I think it makes no sense, I’ll just add that in addition to MS-DOS, I placed the sewing program “PGM02101” (it’s just under dos) and the firmware itself in the form of the file “ROM_V1.BIN "And" Norton Commander "version 5.0.

So take two. After turning on the beech, I put the blank in the CD-ROM, and press "F1". A yellow LED lights up on the CD-ROM and I hear “kva-kva-kva-kva-pyk!”, Then a pause and again “kva-kva-kva-kva-pyk!” This happens about twenty times, and then a mysterious inscription appears:


Most likely this means that the “sidyuk” is also bent.

There was no other way out but to disassemble the CD-ROM drive. It turned out to be a lot of dust and still not clear to me black powder, where it came from, it was not clear to me, especially since at least five years had passed since the last use of this beech and all this time it was lying on a shelf in cellophane. Then I decided that it was Tangris, and boldly cleaned it from the drive. In addition, he slightly smeared the guiding heads with lithol and rubbed the lens with a cotton “ear” stick with alcohol.

It helped, the drive blinked, croaked, and I saw a DOS prompt on the screen. HOORAY!
“Norton” did not start, a “Disk error reading (or writing) drive A:” error occurred. I thought that he was recording something for his own purposes, but could not write to the CD-ROM. Well, to hell with him, now I can’t even understand why I needed him.
In general, “DIR”, and then “pgm02101.exe” and now on the screen the long-awaited program PGM02 offers to choose an LPT port. Choose LPT 1 (0x378).

K573RF5 firmware requires an additional + 25V power supply. I was fortunate enough to find a unit with such voltage. I have an HP Deskjet 2050a printer, so it is powered by a 30V power supply. Fortunately, I had a multimeter and it was easy to find out the polarity on the connector.

After the firmware process, it turned out that the firmware does not work. That is, the process ends, but in the ROM chip 0xFF is still read at all addresses. The method of poking with a multimeter in the socket showed that there is no programming voltage on the PGM pin. It turned out that the VT17 transistor (KT815G) “flew” in the programmer, and I had to change it.

It has been done! And read correctly!

Unexpected foot failure

When the ROM chip got into the controller, I wanted to check its readability. I wanted to use the System Monitor and display the area 0xF000-0xF7FF using the "D" directive. I pressed “DF0” ... When I pressed “0” nothing happened, the key did not work.
Then I typed “DEFFF, F7FF” and after pressing “VK” I saw what I wanted on the screen. But to start the download from the SD card, it was required to enter “GF000” and press “VK”.

At first I thought that the matter was in the contacts, but as it turned out a number of keys did not work. These were the keys "8", "space", "Yu", "X", "P", "b" and the up arrow.
Opening the diagram, I saw that this is the first vertical column of keys. The PB0 pin of the D39 chip (KR580BB55) was responsible for this column. By the way, diodes are indicated in the circuit for decoupling the columns, but in fact, 300 Ohm resistors are installed.


What is it? The hack of the manufacturer?
When repairing, replace these resistors with diodes. But how do I test the controller?

New Hope

I had to deploy the ThinkPad and the programmer with power supplies again. At the addresses 0xF7CE - 0xF7D0 I "finished" the codes 0xC3, 0x00, 0xF0; which means JMP F000.

Now starting is possible not only with the “GF000” command, but also with the “GF7CE”, where non-working keys are not involved. After starting, everything worked out, and instead of the OS, a program was loaded that brought “MIKROSHA OS” to the screen.

I can’t carry out repairs now, but there are two pieces in the KR580VV55 microchip, and the second one is practically not used. There is an idea to swap them, and then replace the faulty one. Therefore, the third time I called my brother, and asked me to bring a desoldering pump, flux "LTI-120", solder and ... another Mikrosha.

Yes, I don’t have Mikrosh alone, and the one that he brought is almost a museum example “in oil”. The thing is that when my father bought me Mikrosha, he was asked to buy another one, and he bought it. But something went wrong, and the man for some reason refused to take it.
So she lay for 30 years.


By the way, on this second Mikrosha there are also resistors instead of diodes, and since both cars are from the same batch, I suppose that is the case in the whole batch.



It will be necessary to carefully change the resistors to diodes in this.
In the meantime, I will use it to finish this project. Yes, there is also the third Mikrosha, but I will talk about her some other time. I can only say that it was severely disfigured by one of my classmates "in those days" and I am slowly restoring it, but it will not be authentic, but on the contrary modified to super capabilities, and already using microcontrollers and CPLD. This will be a different project.

Listings and Codes


The code
:20000000CDD0F0FE00CA1AF021D5F4CD18F8C39DF821E9F4CD18F8C39DF821FAEF977723F4
:20002000772377237711F5EF123EE01B12CD2FF4FE00C208F03A00E0FEEBCA69F03AFFE1DB
:20004000FEAAC211F001C6E111FDEF0A12031B0A12031B0A12031B0A12CD2FF4FE00C2080E
:20006000F03A00E0FEEBC211F03AFFE1FEAAC211F001CEF411BBE1CDDBF7FE00C211F00174
:20008000FAEF1A0213031A0213031A0213031A02CD2FF4FE00C208F006063AF4EF3C3C324A
:2000A000F4EFCDB9F0C5CD2FF4C1FE00C208F005C29AF0C300E0FFFFFF21FDEF7E3C77FE8C
:2000C00000C2CBF02B7DFEF9C2BCF0C9000000001E20CD87F5FE01CAE1F01DC2D2F03EE0ED
:2000E000C9CDC8F51E60CD00F5FE00CAF5F01DC2E6F03EE1C91E20CD50F5FE00CA06F11DF7
:20010000C2F7F03EE2C97A32FEEF97C9FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF68
:20012000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDF
:20014000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBF
:20016000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF9F
:20018000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7F
:2001A000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5F
:2001C000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF3F
:2001E000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1F
:20020000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE
:20022000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDE
:20024000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBE
:20026000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF9E
:20028000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7E
:2002A000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5E
:2002C000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF3E
:2002E000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1E
:20030000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD
:20032000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDD
:20034000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBD
:20036000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF9D
:20038000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7D
:2003A000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D
:2003C000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF3D
:2003E000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1D
:20040000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC
:20042000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF3AFEEFE640FE40C259F43E51CD00F63AFAAB
:20044000EFCD00F63AFBEFCD00F63AFCEFCD00F63AFDEFCD00F6C38BF43AFDEF373F17320B
:20046000F2EF3AFCEF1732F1EF3AFBEF1732F0EF3E51CD00F63AF0EFCD00F63AF1EFCD00EC
:20048000F63AF2EFCD00F697CD00F63E95CD00F616FFCD6CF6FE00CAA1F415C292F43EFD5F
:2004A000C9CD6CF6FEFECAB0F415C2A1F43EFCC921F4EF56235E2600CD6CF61213CD6CF6E7
:2004C000121325C2B8F4CD6CF6CD6CF697C94D6963724F53000D0A6F7B69626B612053442A
:2004E000206B617274790D0A000D0A6F7B69626B61207A616772757A6B69204F530D0A0092
:200500003E77CD00F697CD00F6CD00F6CD00F6CD00F63DCD00F616FFCD6CF6FE01CA27F597
:2005200015C218F53EE0C93E69CD00F63E40CD00F697CD00F6CD00F6CD00F63CCD00F61650
:20054000FFCD6CF6FEFFC24FF515C241F53EE1C93E7ACD00F697CD00F6CD00F6CD00F6CD4D
:2005600000F63CCD00F616FFCD6CF6FEFFC277F515C268F53EE2C94FCD6CF657CD6CF6CD29
:200580006CF6CD6CF679C93EB032FFEF164C3EF032FFEF3EB032EEEF15C28EF59732FFEFBC
:2005A0003E40CD00F697CD00F6CD00F6CD00F6CD00F63E95CD00F616FFCD6CF6FE01CAC7ED
:2005C000F515C2B9F53EFFC93E48CD00F697CD00F6CD00F63CCD00F63EAACD00F63E87CDF9
:2005E00000F616FFCD6CF6FEFFC2F0F515C2E4F5CD6CF6CD6CF6CD6CF6CD6CF6C9000000E8
:2006000047C5473AFFEFE60E4FE521FFEF78E68077F65077780747E68077F65077780747F0
:20062000E68077F65077780747E68077F65077780747E68077F65077780747E68077F65077
:2006400077780747E68077F65077780747E68077F650777932FFEFE1C178C90000000000E7
:20066000000000000000000000000000D5E521FFEF1190D073727EE601074773727EE6015E
:20068000B0074773727EE601B0074773727EE601B0074773727EE601B0074773727EE6013A
:2006A000B0074773727EE601B0074773727EE601B0E1D1C9FFFFFFFFFFFFFFFFFFFFFFFF8B
:2006C000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF3A
:2006E000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1A
:20070000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF9
:20072000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD9
:20074000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFB9
:20076000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF99
:20078000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF79
:2007A000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF59
:2007C000FFFFFFFFFFFFFFFFFFFFFFFFFFFFC300F032FFEFC300E032FFEFE90A03FE00CAD3
:2007E000EBF7671A13BCCADBF73EFFC9E521FFEF5E720A73E1C9E521FFEF5E720273E1C957
:00000001FF
Here is the full firmware code in HEX format (2048 bytes). To get the binary, you can use the HEX2BIN utility.

Listing
F000: CALL F0D0
F003: CPI A,00
F005: JZ F01A
F008: LXI H,F4D5
F00B: CALL F818
F00E: JMP F89D
F011: LXI H,F4E9
F014: CALL F818
F017: JMP F89D
F01A: LXI H,EFFA
F01D: SUB A
F01E: MOV M,A
F01F: INX H
F020: MOV M,A
F021: INX H
F022: MOV M,A
F023: INX H
F024: MOV M,A
F025: LXI D,EFF5
F028: STAX D
F029: MVI A,E0
F02B: DCX D
F02C: STAX D
F02D: CALL F42F
F030: CPI A,00
F032: JNZ F008
F035: LDA E000
F038: CPI A,EB
F03A: JZ F069
F03D: LDA E1FF
F040: CPI A,AA
F042: JNZ F011
F045: LXI B,E1C6
F048: LXI D,EFFD
F04B: LDAX B
F04C: STAX D
F04D: INX B
F04E: DCX D
F04F: LDAX B
F050: STAX D
F051: INX B
F052: DCX D
F053: LDAX B
F054: STAX D
F055: INX B
F056: DCX D
F057: LDAX B
F058: STAX D
F059: CALL F42F
F05C: CPI A,00
F05E: JNZ F008
F061: LDA E000
F064: CPI A,EB
F066: JNZ F011
F069: LDA E1FF
F06C: CPI A,AA
F06E: JNZ F011
F071: LXI B,F4CE
F074: LXI D,E1BB
F077: CALL F7DB
F07A: CPI A,00
F07C: JNZ F011
F07F: LXI B,EFFA
F082: LDAX D
F083: STAX B
F084: INX D
F085: INX B
F086: LDAX D
F087: STAX B
F088: INX D
F089: INX B
F08A: LDAX D
F08B: STAX B
F08C: INX D
F08D: INX B
F08E: LDAX D
F08F: STAX B
F090: CALL F42F
F093: CPI A,00
F095: JNZ F008
F098: MVI B,06
F09A: LDA EFF4
F09D: INR A
F09E: INR A
F09F: STA EFF4
F0A2: CALL F0B9
F0A5: PUSH B
F0A6: CALL F42F
F0A9: POP B
F0AA: CPI A,00
F0AC: JNZ F008
F0AF: DCR B
F0B0: JNZ F09A
F0B3: JMP E000
F0B6: RST 7
F0B7: RST 7
F0B8: RST 7
F0B9: LXI H,EFFD
F0BC: MOV A,M
F0BD: INR A
F0BE: MOV M,A
F0BF: CPI A,00
F0C1: JNZ F0CB
F0C4: DCX H
F0C5: MOV A,L
F0C6: CPI A,F9
F0C8: JNZ F0BC
F0CB: RET
F0CC: NOP
F0CD: NOP
F0CE: NOP
F0CF: NOP
F0D0: MVI E,20
F0D2: CALL F587
F0D5: CPI A,01
F0D7: JZ F0E1
F0DA: DCR E
F0DB: JNZ F0D2
F0DE: MVI A,E0
F0E0: RET
F0E1: CALL F5C8
F0E4: MVI E,60
F0E6: CALL F500
F0E9: CPI A,00
F0EB: JZ F0F5
F0EE: DCR E
F0EF: JNZ F0E6
F0F2: MVI A,E1
F0F4: RET
F0F5: MVI E,20
F0F7: CALL F550
F0FA: CPI A,00
F0FC: JZ F106
F0FF: DCR E
F100: JNZ F0F7
F103: MVI A,E2
F105: RET
F106: MOV A,D
F107: STA EFFE
F10A: SUB A
F10B: RET
F10C: RST 7
-------------------
F42E: RST 7
F42F: LDA EFFE
F432: ANI40
F434: CPI A,40
F436: JNZ F459
F439: MVI A,51
F43B: CALL F600
F43E: LDA EFFA
F441: CALL F600
F444: LDA EFFB
F447: CALL F600
F44A: LDA EFFC
F44D: CALL F600
F450: LDA EFFD
F453: CALL F600
F456: JMP F48B
F459: LDA EFFD
F45C: STC
F45D: CMC
F45E: RAL
F45F: STA EFF2
F462: LDA EFFC
F465: RAL
F466: STA EFF1
F469: LDA EFFB
F46C: RAL
F46D: STA EFF0
F470: MVI A,51
F472: CALL F600
F475: LDA EFF0
F478: CALL F600
F47B: LDA EFF1
F47E: CALL F600
F481: LDA EFF2
F484: CALL F600
F487: SUB A
F488: CALL F600
F48B: MVI A,95
F48D: CALL F600
F490: MVI D,FF
F492: CALL F66C
F495: CPI A,00
F497: JZ F4A1
F49A: DCR D
F49B: JNZ F492
F49E: MVI A,FD
F4A0: RET
F4A1: CALL F66C
F4A4: CPI A,FE
F4A6: JZ F4B0
F4A9: DCR D
F4AA: JNZ F4A1
F4AD: MVI A,FC
F4AF: RET
F4B0: LXI H,EFF4
F4B3: MOV D,M
F4B4: INX H
F4B5: MOV E,M
F4B6: MVI H,00
F4B8: CALL F66C
F4BB: STAX D
F4BC: INX D
F4BD: CALL F66C
F4C0: STAX D
F4C1: INX D
F4C2: DCR H
F4C3: JNZ F4B8
F4C6: CALL F66C
F4C9: CALL F66C
F4CC: SUB A
F4CD: RET
F4CE: MOV C,L
F4CF: MOV L,C
F4D0: MOV H,E
F4D1: MOV M,D
F4D2: MOV C,A
F4D3: MOV D,E
F4D4: NOP
F4D5: DCR C
F4D6: LDAX B
F4D7: MOV L,A
F4D8: MOV A,E
F4D9: MOV L,C
F4DA: MOV H,D
F4DB: MOV L,E
F4DC: MOV H,C
F4DD: ENOP
F4DE: MOV D,E
F4DF: MOV B,H
F4E0: ENOP
F4E1: MOV L,E
F4E2: MOV H,C
F4E3: MOV M,D
F4E4: MOV M,H
F4E5: MOV A,C
F4E6: DCR C
F4E7: LDAX B
F4E8: NOP
F4E9: DCR C
F4EA: LDAX B
F4EB: MOV L,A
F4EC: MOV A,E
F4ED: MOV L,C
F4EE: MOV H,D
F4EF: MOV L,E
F4F0: MOV H,C
F4F1: ENOP
F4F2: MOV A,D
F4F3: MOV H,C
F4F4: MOV H,A
F4F5: MOV M,D
F4F6: MOV M,L
F4F7: MOV A,D
F4F8: MOV L,E
F4F9: MOV L,C
F4FA: ENOP
F4FB: MOV C,A
F4FC: MOV D,E
F4FD: DCR C
F4FE: LDAX B
F4FF: NOP
F500: MVI A,77
F502: CALL F600
F505: SUB A
F506: CALL F600
F509: CALL F600
F50C: CALL F600
F50F: CALL F600
F512: DCR A
F513: CALL F600
F516: MVI D,FF
F518: CALL F66C
F51B: CPI A,01
F51D: JZ F527
F520: DCR D
F521: JNZ F518
F524: MVI A,E0
F526: RET
F527: MVI A,69
F529: CALL F600
F52C: MVI A,40
F52E: CALL F600
F531: SUB A
F532: CALL F600
F535: CALL F600
F538: CALL F600
F53B: INR A
F53C: CALL F600
F53F: MVI D,FF
F541: CALL F66C
F544: CPI A,FF
F546: JNZ F54F
F549: DCR D
F54A: JNZ F541
F54D: MVI A,E1
F54F: RET
F550: MVI A,7A
F552: CALL F600
F555: SUB A
F556: CALL F600
F559: CALL F600
F55C: CALL F600
F55F: CALL F600
F562: INR A
F563: CALL F600
F566: MVI D,FF
F568: CALL F66C
F56B: CPI A,FF
F56D: JNZ F577
F570: DCR D
F571: JNZ F568
F574: MVI A,E2
F576: RET
F577: MOV C,A
F578: CALL F66C
F57B: MOV D,A
F57C: CALL F66C
F57F: CALL F66C
F582: CALL F66C
F585: MOV A,C
F586: RET
F587: MVI A,B0
F589: STA EFFF
F58C: MVI D,4C
F58E: MVI A,F0
F590: STA EFFF
F593: MVI A,B0
F595: STA EFEE
F598: DCR D
F599: JNZ F58E
F59C: SUB A
F59D: STA EFFF
F5A0: MVI A,40
F5A2: CALL F600
F5A5: SUB A
F5A6: CALL F600
F5A9: CALL F600
F5AC: CALL F600
F5AF: CALL F600
F5B2: MVI A,95
F5B4: CALL F600
F5B7: MVI D,FF
F5B9: CALL F66C
F5BC: CPI A,01
F5BE: JZ F5C7
F5C1: DCR D
F5C2: JNZ F5B9
F5C5: MVI A,FF
F5C7: RET
F5C8: MVI A,48
F5CA: CALL F600
F5CD: SUB A
F5CE: CALL F600
F5D1: CALL F600
F5D4: INR A
F5D5: CALL F600
F5D8: MVI A,AA
F5DA: CALL F600
F5DD: MVI A,87
F5DF: CALL F600
F5E2: MVI D,FF
F5E4: CALL F66C
F5E7: CPI A,FF
F5E9: JNZ F5F0
F5EC: DCR D
F5ED: JNZ F5E4
F5F0: CALL F66C
F5F3: CALL F66C
F5F6: CALL F66C
F5F9: CALL F66C
F5FC: RET
F5FD: NOP
F5FE: NOP
F5FF: NOP
F600: MOV B,A
F601: PUSH B
F602: MOV B,A
F603: LDA EFFF
F606: ANI0E
F608: MOV C,A
F609: PUSH H
F60A: LXI H,EFFF
F60D: MOV A,B
F60E: ANI80
F610: MOV M,A
F611: ORI50
F613: MOV M,A
F614: MOV A,B
F615: RLC
F616: MOV B,A
F617: ANI80
F619: MOV M,A
F61A: ORI50
F61C: MOV M,A
F61D: MOV A,B
F61E: RLC
F61F: MOV B,A
F620: ANI80
F622: MOV M,A
F623: ORI50
F625: MOV M,A
F626: MOV A,B
F627: RLC
F628: MOV B,A
F629: ANI80
F62B: MOV M,A
F62C: ORI50
F62E: MOV M,A
F62F: MOV A,B
F630: RLC
F631: MOV B,A
F632: ANI80
F634: MOV M,A
F635: ORI50
F637: MOV M,A
F638: MOV A,B
F639: RLC
F63A: MOV B,A
F63B: ANI80
F63D: MOV M,A
F63E: ORI50
F640: MOV M,A
F641: MOV A,B
F642: RLC
F643: MOV B,A
F644: ANI80
F646: MOV M,A
F647: ORI50
F649: MOV M,A
F64A: MOV A,B
F64B: RLC
F64C: MOV B,A
F64D: ANI80
F64F: MOV M,A
F650: ORI50
F652: MOV M,A
F653: MOV A,C
F654: STA EFFF
F657: POP H
F658: POP B
F659: MOV A,B
F65A: RET
F65B: NOP
F65C: NOP
F65D: NOP
F65E: NOP
F65F: NOP
F660: NOP
F661: NOP
F662: NOP
F663: NOP
F664: NOP
F665: NOP
F666: NOP
F667: NOP
F668: NOP
F669: NOP
F66A: NOP
F66B: NOP
F66C: PUSH D
F66D: PUSH H
F66E: LXI H,EFFF
F671: LXI D,D090
F674: MOV M,E
F675: MOV M,D
F676: MOV A,M
F677: ANI01
F679: RLC
F67A: MOV B,A
F67B: MOV M,E
F67C: MOV M,D
F67D: MOV A,M
F67E: ANI01
F680: ORA B
F681: RLC
F682: MOV B,A
F683: MOV M,E
F684: MOV M,D
F685: MOV A,M
F686: ANI01
F688: ORA B
F689: RLC
F68A: MOV B,A
F68B: MOV M,E
F68C: MOV M,D
F68D: MOV A,M
F68E: ANI01
F690: ORA B
F691: RLC
F692: MOV B,A
F693: MOV M,E
F694: MOV M,D
F695: MOV A,M
F696: ANI01
F698: ORA B
F699: RLC
F69A: MOV B,A
F69B: MOV M,E
F69C: MOV M,D
F69D: MOV A,M
F69E: ANI01
F6A0: ORA B
F6A1: RLC
F6A2: MOV B,A
F6A3: MOV M,E
F6A4: MOV M,D
F6A5: MOV A,M
F6A6: ANI01
F6A8: ORA B
F6A9: RLC
F6AA: MOV B,A
F6AB: MOV M,E
F6AC: MOV M,D
F6AD: MOV A,M
F6AE: ANI01
F6B0: ORA B
F6B1: POP H
F6B2: POP D
F6B3: RET
F6B4: RST 7
---------------------
F7CD: RST 7
F7CE: JMP F000
F7D1: STA EFFF
F7D4: JMP E000
F7D7: STA EFFF
F7DA: PCHL
F7DB: LDAX B
F7DC: INX B
F7DD: CPI A,00
F7DF: JZ F7EB
F7E2: MOV H,A
F7E3: LDAX D
F7E4: INX D
F7E5: CMP H
F7E6: JZ F7DB
F7E9: MVI A,FF
F7EB: RET
F7EC: PUSH H
F7ED: LXI H,EFFF
F7F0: MOV E,M
F7F1: MOV M,D
F7F2: LDAX B
F7F3: MOV M,E
F7F4: POP H
F7F5: RET
F7F6: PUSH H
F7F7: LXI H,EFFF
F7FA: MOV E,M
F7FB: MOV M,D
F7FC: STAX B
F7FD: MOV M,E
F7FE: POP H
F7FF: RET
Here is a listing, empty places have been removed from it for convenience.

The byte sending and reading byte subroutines are located at the addresses 0xF600 and 0xF66C, respectively, they are written in expanded form without loops, this gives a high speed of the program.

I’ll mention once again that this is a raw, first version, which will noticeably change and be supplemented. But now I do not need acoustic loading through the “I” directive.

Boot device

As already mentioned, in the boot sector at address 0x1BB is the signature “MicrOS”, and after it 4 bytes with the address of the OS program. BSVV loads 7 sectors of 512 bytes in the area 0xE000 - 0xEDFF and transfers control to the address 0xE000. Loading is carried out in the zero page. The rest of the pages will already be filled in by the OS, if necessary (and when I will build bridges). For the correct "Installation" of the OS on the SD card, after formatting, write the file from the OS. Then find the number of the first sector of this file and write the signature and address in the boot sector. The address must be specified in sectors (and not in bytes). The Big-endian byte order, i.e. the low byte last (with high address).

By the way, I’m going to automate this OS installation process, maybe even using Mikroshi tools, then there will be another subroutine in BSVV.

What's next?

Now I should start writing OS, but before that I decided to write another program. SD cards are now worth a penny, and I wanted to make a separate SD card with games. That is, record all-all games that I can find on the Internet on this card, and instead of OS make a program that shows me a large list of games. You can also search for a game by name when entering from the keyboard. After choosing a game, it is loaded into RAM and launched.

Such a program will allow me to play games on Mikrosh without bothering with work in the DOS console. I will call such a program, "Game Manager." And about her, most likely, will be the next chapter.

And on another card, I plan to make a normal DOS for programs such as Basic, Editor and Assembler, etc.

Some lyrics and popularization of programming

Somehow my brother and I sat and smoked, and he asked why I have such a thoughtful look?

At that time I was thinking over “bridges” and it was necessary to create a subprogram “LDA-Bridge”. But how to talk about such a problem to a person who knows neither about programming, nor about assembler, nor about how the processor works, and in general ...

I started like this:
Imagine, I say that there are 8 warehouses, and each one has a boss. There is a courier. The task is to arrange the shipment of goods from warehouse to warehouse, but there are limitations. And another difficulty is speed.
I tried to say that the courier code turns out to be very large, and that it turns out a lot of calls to the stack and many operations with registers. Then, for complete understanding, my brother asked me questions, and I answered them, and it worked!

Once he asked if it was possible to make 8 couriers, where each one was attached to his warehouse and he did not need to remember who to return to, he always returned to his warehouse.
This really greatly simplified and speed up operations. Now, before switching pages, you don’t need to know and remember the current page to return, you can immediately switch the page and read the data. And then switch the page to the hard-specified and return. This yielded results, although it took up a bit of space, but it significantly increased productivity.

Subtotal

My HelloWorld launches successfully on both machines. The time from pressing “VK” to the appearance of the inscription takes no more than two seconds, by 3584 bytes. Rather, about 1.5 seconds. There is nothing to measure more precisely. I think this is a good result.

That's all for now. Thank you for the attention! To be continued…

All Articles