1
0
mirror of synced 2026-01-28 21:10:46 +00:00

Add INT13h handling for SD Card.

This commit is contained in:
Matthieu Bucchianeri
2025-01-18 15:55:44 -08:00
committed by Ted Fried
parent d2f95788e5
commit 1e800f94c5
7 changed files with 1628 additions and 132 deletions

View File

@@ -39,12 +39,13 @@
// - Refactor SD card I/O // - Refactor SD card I/O
// - Add support for 16-bit EMS page offsets // - Add support for 16-bit EMS page offsets
// //
// Revision 8 01/18/2024
// - Add support for BIOS ROM extension (Boot ROM)
//
// Revision 8 01/20/2025 // Revision 8 01/20/2025
// - Added chip select for a second PSRAM to allow access to 16 MB of Expanded RAM // - Added chip select for a second PSRAM to allow access to 16 MB of Expanded RAM
// //
// Revision 9 01/26/2024
// - Add support for BIOS ROM extension (Boot ROM)
// - Add scrach registers for Boot ROM hooking
//
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// //
// Copyright (c) 2024 Ted Fried // Copyright (c) 2024 Ted Fried
@@ -171,7 +172,7 @@
#define EMS_TOTAL_SIZE (16*1024*1024) #define EMS_TOTAL_SIZE (16*1024*1024)
#define SD_BASE 0x280 // Must be a multiple of 2. #define SD_BASE 0x280 // Must be a multiple of 8.
// -------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------
@@ -196,6 +197,7 @@ uint8_t spi_shift_out =0;
uint8_t sd_spi_datain =0; uint8_t sd_spi_datain =0;
uint32_t sd_spi_cs_n = 0x0; uint32_t sd_spi_cs_n = 0x0;
uint32_t sd_spi_dataout =0; uint32_t sd_spi_dataout =0;
uint8_t sd_scratch_register[4] = {0, 0, 0, 0};
uint8_t XTMax_MEM_Response_Array[16]; uint8_t XTMax_MEM_Response_Array[16];
@@ -674,12 +676,16 @@ inline void IO_Read_Cycle() {
} }
else if ((isa_address&0x0FFE)==SD_BASE ) { // Location of SD Card registers else if ((isa_address&0x0FF8)==SD_BASE ) { // Location of SD Card registers
// Both registers serve the same function (to allow use of Word I/O) switch (isa_address) {
sd_spi_dataout = 0xff; case SD_BASE: // First two registers serve the same function (to allow use of Word I/O)
SD_SPI_Cycle(); case SD_BASE+1: sd_spi_dataout = 0xff; SD_SPI_Cycle(); isa_data_out = sd_spi_datain; break;
isa_data_out = sd_spi_datain; case SD_BASE+4: isa_data_out = sd_scratch_register[0]; break;
case SD_BASE+5: isa_data_out = sd_scratch_register[1]; break;
case SD_BASE+6: isa_data_out = sd_scratch_register[2]; break;
case SD_BASE+7: isa_data_out = sd_scratch_register[3]; break;
}
GPIO7_DR = GPIO7_DATA_OUT_UNSCRAMBLE + MUX_ADDR_n_LOW + CHRDY_OUT_LOW + trigger_out; GPIO7_DR = GPIO7_DATA_OUT_UNSCRAMBLE + MUX_ADDR_n_LOW + CHRDY_OUT_LOW + trigger_out;
GPIO8_DR = sd_pin_outputs + MUX_DATA_n_HIGH + CHRDY_OE_n_HIGH + DATA_OE_n_LOW; GPIO8_DR = sd_pin_outputs + MUX_DATA_n_HIGH + CHRDY_OE_n_HIGH + DATA_OE_n_LOW;
@@ -727,7 +733,7 @@ inline void IO_Write_Cycle() {
} }
else if ((isa_address&0x0FFC)==SD_BASE ) { // Location of SD Card registers else if ((isa_address&0x0FF8)==SD_BASE ) { // Location of SD Card registers
GPIO7_DR = GPIO7_DATA_OUT_UNSCRAMBLE + MUX_ADDR_n_HIGH + CHRDY_OUT_LOW + trigger_out; GPIO7_DR = GPIO7_DATA_OUT_UNSCRAMBLE + MUX_ADDR_n_HIGH + CHRDY_OUT_LOW + trigger_out;
GPIO8_DR = sd_pin_outputs + MUX_DATA_n_LOW + CHRDY_OE_n_HIGH + DATA_OE_n_HIGH; GPIO8_DR = sd_pin_outputs + MUX_DATA_n_LOW + CHRDY_OE_n_HIGH + DATA_OE_n_HIGH;
@@ -739,6 +745,10 @@ inline void IO_Write_Cycle() {
case SD_BASE: // First two registers serve the same function (to allow use of Word I/O) case SD_BASE: // First two registers serve the same function (to allow use of Word I/O)
case SD_BASE+1: sd_spi_dataout = data_in; SD_SPI_Cycle(); break; case SD_BASE+1: sd_spi_dataout = data_in; SD_SPI_Cycle(); break;
case SD_BASE+2: sd_spi_cs_n = data_in&0x1; break; case SD_BASE+2: sd_spi_cs_n = data_in&0x1; break;
case SD_BASE+4: sd_scratch_register[0] = data_in; break;
case SD_BASE+5: sd_scratch_register[1] = data_in; break;
case SD_BASE+6: sd_scratch_register[2] = data_in; break;
case SD_BASE+7: sd_scratch_register[3] = data_in; break;
} }
//gpio9_int = GPIO9_DR; //gpio9_int = GPIO9_DR;

View File

@@ -1,9 +1,97 @@
#define BOOTROM_ADDR 0xCE000 #define BOOTROM_ADDR 0xCE000
unsigned char BOOTROM[] = { unsigned char BOOTROM[] = {
85, 170, 4, 184, 0, 192, 142, 216, 142, 192, 190, 33, 224, 232, 1, 0, 85, 170, 4, 6, 80, 82, 250, 184, 200, 228, 232, 54, 4, 232, 57, 3,
203, 83, 49, 219, 172, 8, 192, 116, 6, 180, 14, 205, 16, 235, 245, 91, 115, 3, 233, 130, 0, 184, 10, 229, 232, 40, 4, 49, 192, 142, 192, 38,
195, 66, 111, 111, 116, 82, 79, 77, 32, 102, 111, 114, 32, 88, 84, 77, 161, 78, 0, 186, 132, 2, 239, 232, 55, 4, 184, 181, 229, 232, 19, 4,
97, 120, 32, 118, 48, 46, 49, 13, 10, 0, 0, 0, 0, 0, 0, 0, 38, 161, 76, 0, 186, 134, 2, 239, 232, 38, 4, 184, 185, 229, 232, 2,
4, 184, 31, 229, 232, 252, 3, 184, 0, 192, 38, 163, 78, 0, 232, 16,
4, 184, 181, 229, 232, 236, 3, 184, 156, 224, 38, 163, 76, 0, 232, 0,
4, 184, 185, 229, 232, 220, 3, 184, 52, 229, 232, 214, 3, 184, 0, 192,
38, 163, 6, 1, 232, 234, 3, 184, 181, 229, 232, 198, 3, 184, 81, 225,
38, 163, 4, 1, 232, 218, 3, 184, 185, 229, 232, 182, 3, 184, 64, 0,
142, 192, 38, 254, 6, 117, 0, 251, 90, 88, 7, 203, 85, 86, 128, 250,
128, 116, 28, 137, 197, 137, 214, 156, 14, 184, 189, 224, 80, 156, 186, 132,
2, 237, 80, 186, 134, 2, 237, 80, 137, 232, 137, 242, 207, 235, 56, 128,
252, 21, 126, 5, 232, 112, 0, 235, 34, 128, 252, 1, 116, 10, 128, 252,
21, 116, 5, 190, 235, 224, 235, 3, 190, 247, 224, 86, 83, 136, 227, 48,
255, 208, 227, 137, 222, 91, 46, 255, 164, 11, 225, 6, 190, 64, 0, 142,
198, 38, 136, 38, 116, 0, 7, 137, 229, 139, 118, 8, 156, 131, 230, 254,
157, 131, 214, 0, 86, 157, 94, 93, 202, 2, 0, 221, 226, 97, 225, 117,
225, 248, 225, 156, 226, 55, 225, 55, 225, 55, 225, 183, 226, 221, 226, 55,
225, 55, 225, 207, 226, 221, 226, 55, 225, 55, 225, 221, 226, 221, 226, 55,
225, 55, 225, 221, 226, 223, 226, 80, 184, 152, 229, 232, 5, 3, 88, 80,
136, 224, 48, 228, 232, 26, 3, 184, 185, 229, 232, 246, 2, 88, 233, 155,
1, 0, 4, 16, 0, 0, 255, 255, 0, 200, 0, 0, 0, 0, 0, 63,
0, 6, 189, 64, 0, 142, 197, 48, 228, 38, 134, 38, 116, 0, 132, 228,
116, 1, 249, 7, 195, 132, 192, 117, 3, 233, 112, 1, 80, 48, 228, 137,
198, 83, 232, 115, 1, 137, 197, 1, 240, 137, 222, 131, 211, 0, 232, 154,
1, 91, 88, 115, 3, 233, 88, 1, 83, 81, 82, 87, 80, 137, 193, 48,
237, 137, 223, 186, 130, 2, 176, 0, 238, 81, 137, 232, 137, 243, 177, 81,
232, 90, 2, 114, 50, 186, 128, 2, 185, 232, 3, 235, 3, 232, 117, 2,
236, 60, 254, 224, 248, 117, 32, 185, 0, 1, 252, 237, 171, 226, 252, 237,
131, 197, 1, 131, 214, 0, 89, 226, 208, 186, 130, 2, 176, 1, 238, 88,
95, 90, 89, 91, 233, 13, 1, 186, 130, 2, 176, 1, 238, 89, 88, 40,
200, 95, 90, 89, 91, 233, 240, 0, 132, 192, 117, 3, 233, 237, 0, 80,
48, 228, 137, 198, 83, 232, 240, 0, 137, 197, 1, 240, 137, 222, 131, 211,
0, 232, 23, 1, 91, 88, 115, 3, 233, 213, 0, 30, 83, 81, 82, 87,
80, 137, 193, 48, 237, 137, 223, 140, 192, 142, 216, 186, 130, 2, 176, 0,
238, 81, 137, 232, 137, 243, 177, 88, 232, 210, 1, 114, 78, 186, 128, 2,
176, 254, 238, 185, 0, 1, 135, 247, 252, 173, 239, 226, 252, 135, 254, 186,
128, 2, 185, 196, 9, 235, 3, 232, 219, 1, 236, 60, 255, 225, 248, 36,
31, 60, 5, 117, 38, 185, 196, 9, 235, 3, 232, 200, 1, 236, 132, 192,
225, 248, 116, 23, 131, 197, 1, 131, 214, 0, 89, 226, 180, 186, 130, 2,
176, 1, 238, 88, 95, 90, 89, 91, 31, 235, 105, 186, 130, 2, 176, 1,
238, 89, 88, 40, 200, 95, 90, 89, 91, 31, 235, 76, 132, 192, 116, 76,
80, 48, 228, 137, 197, 83, 232, 79, 0, 1, 232, 131, 211, 0, 232, 122,
0, 91, 88, 114, 59, 235, 61, 182, 15, 6, 184, 64, 0, 142, 192, 38,
138, 22, 117, 0, 7, 254, 194, 181, 254, 177, 255, 49, 192, 248, 195, 80,
83, 232, 36, 0, 232, 84, 0, 91, 88, 114, 21, 235, 23, 235, 21, 180,
3, 232, 94, 0, 135, 209, 248, 195, 180, 170, 249, 195, 180, 1, 249, 195,
180, 4, 249, 195, 48, 228, 248, 195, 49, 192, 49, 219, 82, 81, 82, 136,
200, 36, 192, 209, 224, 209, 224, 136, 232, 185, 16, 0, 247, 225, 90, 136,
241, 48, 237, 1, 200, 177, 63, 247, 225, 89, 81, 48, 237, 128, 225, 63,
73, 1, 200, 131, 210, 0, 137, 211, 89, 90, 195, 81, 82, 232, 18, 0,
57, 211, 114, 10, 119, 4, 57, 200, 114, 4, 249, 90, 89, 195, 248, 90,
89, 195, 186, 15, 0, 185, 16, 188, 195, 80, 30, 83, 81, 82, 86, 184,
0, 192, 142, 216, 186, 130, 2, 176, 1, 238, 49, 201, 186, 232, 3, 180,
134, 205, 21, 186, 128, 2, 176, 255, 185, 80, 0, 238, 226, 253, 186, 130,
2, 176, 0, 238, 190, 245, 227, 185, 1, 0, 180, 1, 232, 79, 0, 114,
54, 190, 251, 227, 185, 5, 0, 180, 1, 232, 66, 0, 114, 41, 187, 100,
0, 190, 1, 228, 185, 1, 0, 180, 1, 232, 50, 0, 190, 7, 228, 185,
1, 0, 180, 0, 232, 39, 0, 115, 14, 156, 49, 201, 186, 232, 3, 180,
134, 205, 21, 157, 75, 117, 218, 94, 90, 89, 91, 31, 114, 8, 184, 86,
229, 232, 127, 0, 88, 195, 184, 121, 229, 232, 119, 0, 88, 195, 186, 128,
2, 176, 255, 238, 81, 185, 6, 0, 252, 172, 238, 226, 252, 185, 8, 0,
236, 60, 255, 225, 251, 89, 56, 224, 118, 3, 249, 235, 4, 248, 236, 226,
253, 176, 255, 238, 195, 64, 0, 0, 0, 0, 149, 72, 0, 0, 1, 170,
135, 119, 0, 0, 0, 0, 1, 105, 64, 0, 0, 0, 1, 186, 128, 2,
80, 176, 255, 238, 136, 200, 238, 136, 248, 238, 136, 216, 238, 88, 134, 224,
238, 134, 224, 238, 176, 1, 238, 185, 8, 0, 236, 60, 255, 225, 251, 132,
192, 116, 1, 249, 195, 81, 82, 49, 201, 186, 100, 0, 180, 134, 205, 21,
90, 89, 195, 156, 30, 83, 86, 137, 198, 184, 0, 192, 142, 216, 180, 14,
49, 219, 252, 172, 8, 192, 116, 4, 205, 16, 235, 247, 94, 91, 31, 157,
195, 156, 30, 83, 81, 82, 86, 137, 194, 184, 0, 192, 142, 216, 49, 219,
252, 137, 214, 177, 12, 211, 238, 131, 230, 15, 138, 132, 184, 228, 180, 14,
205, 16, 137, 214, 177, 8, 211, 238, 131, 230, 15, 138, 132, 184, 228, 180,
14, 205, 16, 137, 214, 177, 4, 211, 238, 131, 230, 15, 138, 132, 184, 228,
180, 14, 205, 16, 137, 214, 131, 230, 15, 138, 132, 184, 228, 180, 14, 205,
16, 94, 90, 89, 91, 31, 157, 195, 48, 49, 50, 51, 52, 53, 54, 55,
56, 57, 65, 66, 67, 68, 69, 70, 66, 111, 111, 116, 82, 79, 77, 32,
102, 111, 114, 32, 88, 84, 77, 97, 120, 32, 118, 49, 46, 48, 13, 10,
67, 111, 112, 121, 114, 105, 103, 104, 116, 32, 40, 99, 41, 32, 50, 48,
50, 53, 32, 77, 97, 116, 116, 104, 105, 101, 117, 32, 66, 117, 99, 99,
104, 105, 97, 110, 101, 114, 105, 13, 10, 0, 79, 108, 100, 32, 73, 78,
84, 49, 51, 104, 32, 86, 101, 99, 116, 111, 114, 32, 61, 32, 0, 78,
101, 119, 32, 73, 78, 84, 49, 51, 104, 32, 86, 101, 99, 116, 111, 114,
32, 61, 32, 0, 78, 101, 119, 32, 70, 105, 120, 101, 100, 32, 68, 105,
115, 107, 32, 80, 97, 114, 97, 109, 101, 116, 101, 114, 32, 84, 97, 98,
108, 101, 32, 61, 32, 0, 83, 68, 32, 67, 97, 114, 100, 32, 105, 110,
105, 116, 105, 97, 108, 105, 122, 101, 100, 32, 115, 117, 99, 99, 101, 115,
115, 102, 117, 108, 108, 121, 13, 10, 0, 83, 68, 32, 67, 97, 114, 100,
32, 102, 97, 105, 108, 101, 100, 32, 116, 111, 32, 105, 110, 105, 116, 105,
97, 108, 105, 122, 101, 13, 10, 0, 85, 110, 115, 117, 112, 112, 111, 114,
116, 101, 100, 32, 73, 78, 84, 49, 51, 104, 32, 70, 117, 110, 99, 116,
105, 111, 110, 32, 0, 58, 0, 32, 0, 13, 10, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 93};

View File

@@ -1,2 +1,3 @@
bootrom bootrom
bootrom.com bootrom.com
*.exe

File diff suppressed because it is too large Load Diff

View File

@@ -1,2 +1,2 @@
..\Driver_Build_Tools\NASM\nasm.exe -f bin -o bootrom.com -DAS_COM .\bootrom.asm ..\Driver_Build_Tools\NASM\nasm.exe -f bin -o bootrom.com -DAS_COM_PROGRAM .\bootrom.asm
..\Driver_Build_Tools\NASM\nasm.exe -f bin -o bootrom .\bootrom.asm & python checksum.py ..\Driver_Build_Tools\NASM\nasm.exe -f bin -o bootrom .\bootrom.asm & python checksum.py

View File

@@ -0,0 +1,168 @@
;
; This is test code invoked when building with AS_COM
;
;%define REAL_INT13
%define DUMP_REGS
xor ax, ax
lahf
mov ax, 0x1122
mov bx, 0x3344
mov cx, 0x5566
mov dx, 0x7788
mov si, 0x99aa
mov di, 0xbbcc
mov bp, 0xddee
mov dl, 0x80
mov ah, 0x08
;mov bx, buf_write
;mov ch, 0
;mov cl, 1
;mov dh, 0
;mov al, 1
call do_int13h
mov dl, 0x80
mov ah, 0x02
mov bx, ds
mov es, bx
mov bx, buf_read
mov ch, 0
mov cl, 1
mov dh, 0
mov al, 1
call do_int13h
%if 1
mov cx, 256
mov si, buf_read
.dump:
lodsw
call print_hex
mov ax, space
call print_string
loop .dump
mov ax, newline
call print_string
; wait for kbd
mov ah, 0x01
int 0x21
%endif
mov ah, 0x01
call do_int13h
mov ah, 0x01
call do_int13h
;mov ax, newline
;call print_string
;mov ch, 255
;mov cl, 255
;mov dh, NUM_HEADS-1
;call compute_lba
;push ax
;mov ax, bx
;call print_hex
;pop ax
;call print_hex
;mov ax, newline
;call print_string
jmp end
do_int13h:
%ifdef DUMP_REGS
call dump_regs
%endif
pushf ; save flags (to compare)
%ifndef REAL_INT13
; simulate vector call
pushf
push cs
call int13h_entry
%else
int 0x13
%endif
pushf ; save flags (to compare)
push ax
jnc .success
.error:
mov ax, test_failed_msg
call print_string
jmp .finish
.success:
mov ax, test_success_msg
call print_string
.finish:
pop ax
push ax
mov al, ah
xor ah, ah
call print_hex
mov ax, newline
call print_string
pop ax
; dump registers
%ifdef DUMP_REGS
call dump_regs
pop ax
call print_hex
mov ax, colon
call print_string
pop ax
call print_hex
mov ax, newline
call print_string
%else
popf
popf
%endif
; wait for kbd
mov ah, 0x01
int 0x21
ret
;
; A fake INT13h handler to test redirection of floppy service
;
fake_int13h_entry:
push ax
mov ax, fake_handler_msg
call print_string
pop ax
push ax
mov al, ah
xor ah, ah
call print_hex
mov ax, newline
call print_string
pop ax
mov ah, 0xaa
push bp
mov bp, sp
or byte [bp+6], 0x1 ; set carry of flags for iret
pop bp
iret
buf_write db 1, 2, 3, 4, 5, 6, 7, 8
times 496 db 0
db 248, 249, 250, 251, 252, 253, 254, 255
times 512 db 0
buf_read times 1024 db 0
fake_handler_msg db 'BIOS INT13h Function ', 0
test_success_msg db 'Call succeeded ', 0
test_failed_msg db 'Call failed ', 0
end:

View File

@@ -0,0 +1,139 @@
;
; Display a string.
; in: AX = string pointer
; out: AX = <TRASH>
;
print_string:
pushf
push ds
push bx
push si
mov si, ax
%ifndef AS_COM_PROGRAM
mov ax, ROM_SEGMENT
mov ds, ax
%endif
mov ah, 0xe
xor bx, bx
cld
.loop:
lodsb
or al, al
jz .done
int 0x10
jmp .loop
.done:
pop si
pop bx
pop ds
popf
ret
;
; Display a 16-bit value in hex.
; in: AX = value
; out: AX = <TRASH>
;
print_hex:
pushf
push ds
push bx
push cx
push dx
push si
mov dx, ax
%ifndef AS_COM_PROGRAM
mov ax, ROM_SEGMENT
mov ds, ax
%endif
xor bx, bx
cld
.nibble1:
mov si, dx
mov cl, 12
shr si, cl
and si, 0xf
mov al, [hex_map+si]
mov ah, 0xe
int 0x10
.nibble2:
mov si, dx
mov cl, 8
shr si, cl
and si, 0xf
mov al, [hex_map+si]
mov ah, 0xe
int 0x10
.nibble3:
mov si, dx
mov cl, 4
shr si, cl
and si, 0xf
mov al, [hex_map+si]
mov ah, 0xe
int 0x10
.nibble4:
mov si, dx
and si, 0xf
mov al, [hex_map+si]
mov ah, 0xe
int 0x10
pop si
pop dx
pop cx
pop bx
pop ds
popf
ret
hex_map db '0123456789ABCDEF'
%if %isdef(EXTRA_DEBUG) || %isdef(AS_COM_PROGRAM)
dump_regs:
push ax
mov ax, registers_msg
call print_string
pop ax
push ax
call print_hex
mov ax, space
call print_string
mov ax, bx
call print_hex
mov ax, space
call print_string
mov ax, cx
call print_hex
mov ax, space
call print_string
mov ax, dx
call print_hex
mov ax, space
call print_string
mov ax, ds
call print_hex
mov ax, space
call print_string
mov ax, si
call print_hex
mov ax, space
call print_string
mov ax, es
call print_hex
mov ax, space
call print_string
mov ax, di
call print_hex
mov ax, space
call print_string
mov ax, bp
call print_hex
mov ax, space
call print_string
mov ax, newline
call print_string
pop ax
ret
registers_msg db ' AX BX CX DX DS SI ES DI BP', 0xD, 0xA, 0
%endif