Difference between revisions of "Programming:An example boot sector (executed with rsx command CPM)"

From CPCWiki - THE Amstrad CPC encyclopedia!
Jump to: navigation, search
Line 1: Line 1:
<pre>
+
<pre>;; An example boot sector.
;; An example boot sector.
+
 
;;
 
;;
;; The boot sector is located on track 0, side 0,sector &41, and  
+
;; The boot sector is located on track 0, side 0,sector &amp;41, and  
;; is executed with a |CPM command. A maximum of 512 bytes will be loaded to &100
+
;; is executed with a |CPM command. A maximum of 512 bytes will be loaded to &amp;100
 
;; in RAM. This sector *must* exist for the disc to be started with the |CPM command.
 
;; in RAM. This sector *must* exist for the disc to be started with the |CPM command.
 
;;  
 
;;  
 
;; If the disc is formatted to SYSTEM or VENDOR format, then the directory  
 
;; If the disc is formatted to SYSTEM or VENDOR format, then the directory  
;; will start on track 2, side 0, sector &41. Otherwise, the disc may use
+
;; will start on track 2, side 0, sector &amp;41. Otherwise, the disc may use
 
;; a custom format for the remainder of track 0 and subsequent tracks.
 
;; a custom format for the remainder of track 0 and subsequent tracks.
 
;;
 
;;
Line 14: Line 13:
 
;;
 
;;
  
;; The boot sector is loaded to &100 in memory and executed.
+
;; The boot sector is loaded to &amp;100 in memory and executed.
  
org &100
+
org &amp;100
  
.km_wait_char equ &bb06
+
.km_wait_char equ &amp;bb06
.txt_output equ &bb5a
+
.txt_output equ &amp;bb5a
  
 
;;------------------------------------------------------
 
;;------------------------------------------------------
Line 25: Line 24:
 
;; display a message
 
;; display a message
 
ld hl,message
 
ld hl,message
call print
+
call display_message
 
;; wait for a keypress
 
;; wait for a keypress
 
call km_wait_char
 
call km_wait_char
Line 45: Line 44:
 
.message  
 
.message  
 
defb "Hello, this is a boot sector program",0
 
defb "Hello, this is a boot sector program",0
</Pre>
+
</pre>
 
+
 
[[Category:Programming]]
 
[[Category:Programming]]

Revision as of 16:40, 7 November 2008

;; An example boot sector.
;;
;; The boot sector is located on track 0, side 0,sector &41, and 
;; is executed with a |CPM command. A maximum of 512 bytes will be loaded to &100
;; in RAM. This sector *must* exist for the disc to be started with the |CPM command.
;; 
;; If the disc is formatted to SYSTEM or VENDOR format, then the directory 
;; will start on track 2, side 0, sector &41. Otherwise, the disc may use
;; a custom format for the remainder of track 0 and subsequent tracks.
;;
;; If a directory doesn't exist, then you must use sector read/write functions to load
;; data.
;;

;; The boot sector is loaded to &100 in memory and executed.

org &100

.km_wait_char equ &bb06
.txt_output equ &bb5a

;;------------------------------------------------------

;; display a message
ld hl,message
call display_message
;; wait for a keypress
call km_wait_char
;; soft-reset CPC
rst 0

;;------------------------------------------------------

.display_message
ld a,(hl)
inc hl
or a
ret z
call txt_output
jp display_message

;;------------------------------------------------------

.message 
defb "Hello, this is a boot sector program",0