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
|
- `HELLO.ASM`: A simple "Hello World" program, that uses the print screen
|
||||||
routine, calling BDOS.
|
routine, calling BDOS.
|
||||||
|
- `DIVTEST.ASM`: Tests the division function on the machine.
|
||||||
- `GRAPHTST.ASM`: Tests simple escape sequences, such as clearing the screen.
|
- `GRAPHTST.ASM`: Tests simple escape sequences, such as clearing the screen.
|
||||||
- `CIRCLE.ASM`: Draws a circle on the screen, by printing the escape sequences
|
- `CIRCLE.ASM`: Draws a circle on the screen, by printing the escape sequences
|
||||||
on the screen.
|
on the screen.
|
||||||
|
|||||||
@@ -64,9 +64,50 @@ DIV2: RAL ; rotate left
|
|||||||
RAR ; rotate the A register.
|
RAR ; rotate the A register.
|
||||||
RET ; return to the caller
|
RET ; return to the caller
|
||||||
; SETCUR: Places the cursor anywhere on the screen.
|
; SETCUR: Places the cursor anywhere on the screen.
|
||||||
; Coordinates are stored in a memory location that
|
; Expects 2 16-bit values on the stack.
|
||||||
; is referred to by HL
|
; Writes a longer sequence. It first creates an ESC
|
||||||
; Start of the main code block
|
; 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
|
START: LXI H, 0 ; blank out HL
|
||||||
DAD SP ; HL = SP
|
DAD SP ; HL = SP
|
||||||
SHLD Stack ; save the original stack
|
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
|
SPHL ; set SP to point to our new stack
|
||||||
CALL CLS ; clear the screen
|
CALL CLS ; clear the screen
|
||||||
CALL HOME ; place cursor in the top left
|
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
|
LXI H, MsgStr ; load the string addr into HL
|
||||||
CALL PRINTF ; call our self defined print routine
|
CALL PRINTF ; call our self defined print routine
|
||||||
LHLD Stack ; load original stack addr into HL
|
LHLD Stack ; load original stack addr into HL
|
||||||
|
|||||||
Reference in New Issue
Block a user