jp start
page0_trace:
- ld l,c
- ld h,b
- call print_word
- ld a,'
- call print_char
- ld hl,0
- push af
- add hl,sp
- pop af
- call print_word
- ld a,'
- call print_char
- pop hl
- push hl
- call print_word
- ld a,0xd
- call print_char
- ld a,0xa
- call print_char
- ld a,(bc)
- inc bc
- ld l,a
- ld h,page0
- jp (hl)
+ jp print_trace
page0_esc:
ld l,c
inc h ; page 1
jp (hl)
+page0_imm_xchg_w:
+ ld a,(bc)
+ inc bc
+ ld l,a
+ ld a,(bc)
+ inc bc
+ ld h,a
+ .db 0x3e ; ld a,
+page0_xchg_w:
+ pop hl
+ ex (sp),hl
+ push hl
+ ld a,(bc)
+ inc bc
+ ld l,a
+ ld h,page0
+ jp (hl)
+
page0_imm_call:
- ld a,(bc)
+ ld a,(bc)
inc bc
ld l,a
ld a,(bc)
page0_imm_jtrue:
jr nc,imm_not_taken
page0_imm_jmp:
- ld a,(bc)
+ ld a,(bc)
inc bc
ld l,a
ld a,(bc)
page0_imm_stkadj:
imm_stkadj:
- ld a,(bc)
+ ld a,(bc)
inc bc
ld l,a
ld a,(bc)
page0_imm_stkptr:
imm_stkptr:
- ld a,(bc)
+ ld a,(bc)
inc bc
ld l,a
ld a,(bc)
page0_imm_stkld_w:
imm_stkld_w:
- ld a,(bc)
+ ld a,(bc)
inc bc
ld l,a
ld a,(bc)
ld h,page1
jp (hl)
-page0_imm_stkstrev_w:
+page0_imm_xchg_stkst_w:
pop de
-imm_stkstrev_w:
- ld a,(bc)
+imm_xchg_stkst_w:
+ ld a,(bc)
inc bc
ld l,a
ld a,(bc)
page1_stkld_w:
ex de,hl
jr stkld_w
-page1_imm_stkstrev_w:
- jr imm_stkstrev_w
+page1_imm_xchg_stkst_w:
+ jr imm_xchg_stkst_w
page1_stkst_w:
jr stkst_w
page1_imm_w:
ld h,page1
jp (hl)
-page1_imm_subrev_w: ; reversed, use with argument 0 for neg, -1 for cpl
+page1_imm_xchg_sub_w: ; reversed, use with argument 0 for neg, -1 for cpl
ld a,(bc)
ld l,a
inc bc
; needed to make the result 100 + -ff..ff or 1..1ff, so that the decrements
; cannot borrow into the upcoming dividend bits also held in a, and there must
; be another shift between the scf/rla and increment/decrement so that the scf
-; is implicitly in the 100s place, making the code awkward though it's correct
+; is implicitly in the 100s place, making the code awkward though it's correct
; now optimized to only inc/dec a when doing zero-crossing, fix above analysis
; debugging
-digits:
- .ascii '0123456789abcdef'
+print_trace:
+ ld l,c
+ ld h,b
+ call print_word
+ ld a,'
+ call print_char
+ ld hl,0
+ push af
+ add hl,sp
+ pop af
+ call print_word
+ ld a,'
+ call print_char
+ pop hl
+ push hl
+ call print_word
+ ld a,0xd
+ call print_char
+ ld a,0xa
+ call print_char
+ ld a,(bc)
+ inc bc
+ ld l,a
+ ld h,page0
+ jp (hl)
print_word:
push af
pop bc
ret
+digits:
+ .ascii '0123456789abcdef'
+
; sm code
start:
.dw 0
.db <page1_imm_div_sw
.dw 10000
- .db <page1_imm_stkstrev_w
+ .db <page1_imm_xchg_stkst_w
.dw 2
.db <page0_page1
.db page1_imm_add_w
.dw 0
.db <page1_imm_div_sw
.dw 1000
- .db <page1_imm_stkstrev_w
+ .db <page1_imm_xchg_stkst_w
.dw 2
.db <page0_page1
.db page1_imm_add_w
.dw 0
.db <page1_imm_div_sw
.dw 100
- .db <page1_imm_stkstrev_w
+ .db <page1_imm_xchg_stkst_w
.dw 2
.db <page0_page1
.db page1_imm_add_w
.dw 0
.db <page1_imm_div_sw
.dw 10
- .db <page1_imm_stkstrev_w
+ .db <page1_imm_xchg_stkst_w
.dw 2
.db <page0_page1
.db page1_imm_add_w
.dw 1
.db <page0_imm_jfalse
.dw 1$
-
+
; no, set up for *result =
.db <page0_imm_stkld_w
.dw 2
; set *result = sm_factorial(argument - 1) * argument
.db <page1_st_w
- ; return
+ ; return
.db <page0_trace
.db <page0_jmp