finish setcur subroutine
This commit is contained in:
@@ -15,6 +15,7 @@ The following example programs exist in the folder ./src
|
||||
|
||||
- `HELLO.ASM`: A simple "Hello World" program, that uses the print screen
|
||||
routine, calling BDOS.
|
||||
- `DIVTEST.ASM`: Tests the division function on the machine.
|
||||
- `GRAPHTST.ASM`: Tests simple escape sequences, such as clearing the screen.
|
||||
- `CIRCLE.ASM`: Draws a circle on the screen, by printing the escape sequences
|
||||
on the screen.
|
||||
|
||||
@@ -64,9 +64,50 @@ DIV2: RAL ; rotate left
|
||||
RAR ; rotate the A register.
|
||||
RET ; return to the caller
|
||||
; SETCUR: Places the cursor anywhere on the screen.
|
||||
; Coordinates are stored in a memory location that
|
||||
; is referred to by HL
|
||||
; Start of the main code block
|
||||
; Expects 2 16-bit values on the stack.
|
||||
; Writes a longer sequence. It first creates an ESC
|
||||
; at CurPos, then executes it, by printing.
|
||||
SETCUR: LXI H, CurPos ; load the start address into HL
|
||||
LXI A, 1B ; load the A register, with the ESC-char
|
||||
MOV M, A ; store the value in A to CurPos
|
||||
INX H ; increase HL to store at the next address
|
||||
LXI A, 5B ; store the '['-char in A
|
||||
MOV M, A
|
||||
INX H
|
||||
POP B ; read the x-pos into BC
|
||||
LXI D 000A ; load the divisor into DE
|
||||
CALL DIV ; devide the number by 10
|
||||
MOV A, C ; load the quotient into A
|
||||
ADI 30 ; make the pos a char
|
||||
MOV M, A ; store the char
|
||||
INX H ; increase HL to store the next address
|
||||
MOV A, B ; get the remainder, and do the same again
|
||||
ADI 30 ; make the int a char
|
||||
MOV M, A ; store the char
|
||||
INX H ; increase HL
|
||||
LXI A, 3B ; load the ';' sign
|
||||
MOV M, A ; store the char
|
||||
INX H ; increase HL
|
||||
POP B ; get the next value from the stack
|
||||
LXI D, 000A ; load the divisor into DE
|
||||
CALL DIV ; call the division subroutine
|
||||
MOV A, C ; load the quotient into A
|
||||
ADI 30 ; make the position a char
|
||||
MOV M, A ; store the char
|
||||
INX H ; increase the accumulator
|
||||
MOV A, B ; load the remainde to A
|
||||
ADI 30 ; make it a char
|
||||
MOV M, A ; store the char
|
||||
INX H ; increase the HL register
|
||||
LXI A, 48 ; Load the 'H' character
|
||||
MOV M, A ; store the character
|
||||
INX H ; increase HL
|
||||
LXI A, 00 ; all strings are NULL terminated
|
||||
MOV M, A ; store the NULL
|
||||
LXI H, CurPos ; reset HL
|
||||
CALL PRINTF ; print the ESC-sequence
|
||||
RET
|
||||
Start of the main code block
|
||||
START: LXI H, 0 ; blank out HL
|
||||
DAD SP ; HL = SP
|
||||
SHLD Stack ; save the original stack
|
||||
@@ -74,6 +115,11 @@ START: LXI H, 0 ; blank out HL
|
||||
SPHL ; set SP to point to our new stack
|
||||
CALL CLS ; clear the screen
|
||||
CALL HOME ; place cursor in the top left
|
||||
LXI B 0028 ; set vertical pos to 40
|
||||
PUSH B ; store the values on the stack
|
||||
LXI B 000A ; set horizontal Pos to 10
|
||||
PUSH B ; store on the stack
|
||||
CALL SETCUR ; set the cursor position
|
||||
LXI H, MsgStr ; load the string addr into HL
|
||||
CALL PRINTF ; call our self defined print routine
|
||||
LHLD Stack ; load original stack addr into HL
|
||||
|
||||
Reference in New Issue
Block a user